Example usage for com.google.common.base Predicate toString

List of usage examples for com.google.common.base Predicate toString

Introduction

In this page you can find the example usage for com.google.common.base Predicate toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.jnario.jnario.test.util.Matchers.java

public static TypeSafeMatcher<EObject> contains(final Predicate<EObject> predicate) {
    return new TypeSafeMatcher<EObject>() {

        public void describeTo(Description description) {
            description.appendText(predicate.toString());
        }//from w ww. j  a  va 2  s  .c  o  m

        @Override
        public boolean matchesSafely(EObject item) {
            try {
                find(item.eAllContents(), predicate);
                return true;
            } catch (NoSuchElementException e) {
                return false;
            }
        }
    };
}

From source file:xml.entity.mutableelement.Elements.java

/**
 * Create a predicate that matches if the node has an child that matches the
 * given predicate.//from  www.  j  a v a  2s . c  o m
 * 
 * @param matching
 *            This predicate will be applied the the children of the node.
 * @return true if any child matches.
 */
public static Predicate<Element> hasChild(final Predicate<Element> matching) {
    return new Predicate<Element>() {

        @Override
        public boolean apply(@Nullable final Element input) {
            return Iterables.any(input.children(), matching);
        }

        @Override
        public String toString() {
            return matching.toString();
        }
    };
}

From source file:xml.entity.immutableelement.ImmutableElements.java

/**
 * Test if this node has a child matching the given predicate.
 * // w  w  w  .  ja  v  a2 s  . c  om
 * @param matching
 *            This predicate will be applied to the children of the matched
 *            node.
 * @return true if any child matches the given predicate.
 */
public static Predicate<ImmutableElement> hasChild(final Predicate<ImmutableElement> matching) {
    return new Predicate<ImmutableElement>() {

        @Override
        public boolean apply(@Nullable final ImmutableElement input) {
            return Iterables.any(input.children(), matching);
        }

        @Override
        public String toString() {
            return matching.toString();
        }
    };
}

From source file:zotmc.collect.FluentPredicate.java

public static <T> FluentPredicate<T> from(final Predicate<T> predicate) {
    if (predicate instanceof FluentPredicate)
        return (FluentPredicate<T>) predicate;

    return new FluentPredicate<T>() {
        @Override//  ww w.  j  av a 2s.c  o  m
        public boolean apply(T input) {
            return predicate.apply(input);
        }

        @Override
        protected Predicate<T> unwrap() {
            return predicate;
        }

        @Override
        public int hashCode() {
            return predicate.hashCode();
        }

        @Override
        public String toString() {
            return predicate.toString();
        }
    };
}

From source file:de.iteratec.iteraplan.elasticeam.operator.filter.ToFilteredRelationshipEnd.java

private ToFilteredRelationshipEnd(RelationshipEndExpression baseRelationshipEnd, FilteredUniversalType<?> type,
        Predicate<UniversalModelExpression> predicate) {
    super(baseRelationshipEnd.getPersistentName() + "[" + predicate.toString() + "]",
            baseRelationshipEnd.getHolder(), baseRelationshipEnd.getOrigin(),
            baseRelationshipEnd.getLowerBound(), baseRelationshipEnd.getUpperBound(), type);
    this.baseRelationshipEnd = baseRelationshipEnd;
}

From source file:de.iteratec.iteraplan.elasticeam.operator.filter.FilteredUniversalType.java

public FilteredUniversalType(T baseType, Predicate<UniversalModelExpression> predicate, boolean createFromEnd) {
    super(baseType.getPersistentName() + "[" + predicate.toString() + "]");
    this.baseType = baseType;
    this.predicate = predicate;
    if (createFromEnd) {
        //No predefined from end
        this.relationshipEnds = createFromEnds(null);
        init();/*ww  w  .j  av a 2s.c o m*/
    }
}

From source file:org.fao.geonet.utils.MockXmlRequest.java

public List<String> getUnaccessedRequests() {
    List<String> missed = new ArrayList<String>();
    for (Predicate<HttpRequestBase> predicate : _unaccessed) {
        missed.add(predicate.toString());
    }/*from w  ww . ja v  a2 s .  c om*/
    return missed;
}

From source file:org.openqa.selenium.support.ui.FluentWait.java

/**
 * Repeatedly applies this instance's input value to the given predicate until the timeout expires
 * or the predicate evaluates to true.//w  w w.  j av a2s .  c  om
 *
 * @param isTrue The predicate to wait on.
 * @throws TimeoutException If the timeout expires.
 */
public void until(final Predicate<T> isTrue) {
    until(new Function<T, Boolean>() {
        public Boolean apply(T input) {
            return isTrue.apply(input);
        }

        public String toString() {
            return isTrue.toString();
        }
    });
}

From source file:org.apache.brooklyn.core.objs.ConstraintSerialization.java

public List<Object> toJsonList(Predicate<?> constraint) {
    // map twice to clean it (flatten "and" lists, etc)
    // but if not possible go with progressively simpler items
    try {//  w w w. j a  v  a2 s . c o  m
        return toExactJsonList(toPredicateFromJson(toExactJsonList(constraint)));
    } catch (Exception e) {
        Exceptions.propagateIfFatal(e);
        try {
            return toExactJsonList(constraint);
        } catch (Exception e2) {
            Exceptions.propagateIfFatal(e);
            return Collections.singletonList(constraint.toString());
        }
    }
}

From source file:com.netxforge.scoping.DynamixCDOScopeProvider.java

/**
 * This implementation resolves one or more {@link URI URI's} for the given
 * {@link EClass} with help from the URI Map which is then delegated to
 * {@link AbstractDynamixCDOResourceDescriptions} to populate and return the
 * {@link IScope}./* w  ww  . j a v a 2  s  .  c o  m*/
 * 
 */
@Override
protected IScope getScope(Resource resource, boolean ignoreCase, EClass type,
        Predicate<IEObjectDescription> filter) {

    IScope scope = IScope.NULLSCOPE;

    if (RuntimeActivator.DEBUG) {
        RuntimeActivator.TRACE.trace(RuntimeActivator.TRACE_NETXSCRIPT_SCOPING_OPTION,
                " scope provider invoked for Resource: " + resource.getURI().toFileString() + " , EClass: "
                        + type.getName() + (filter != null ? " , filter:" + filter.toString() : ", no filter"));
    }

    // prevent from accessing the global scope, if we
    if (!isInitializing()) {

        List<URI> urisForClass = urisForClass(type);
        if (urisForClass != null && urisForClass.size() > 0) {
            for (URI uri : urisForClass) {

                // the parent scope is self, so all URI's are caught.
                scope = createLazyResourceScope(scope, uri, descriptions, type, filter, ignoreCase);
            }
        } else {
            if (RuntimeActivator.DEBUG) {
                RuntimeActivator.TRACE.trace(RuntimeActivator.TRACE_NETXSCRIPT_SCOPING_OPTION,
                        "no URI's for target EClass:" + type.getName());
            }
        }
    } else {
        if (RuntimeActivator.DEBUG) {
            System.err.println(
                    "NETXSCRIPT: Global scope not available, currently Initializing...please try again later");
        }
    }
    return scope;
}