Example usage for com.google.common.collect Constraint checkElement

List of usage examples for com.google.common.collect Constraint checkElement

Introduction

In this page you can find the example usage for com.google.common.collect Constraint checkElement.

Prototype

E checkElement(E element);

Source Link

Document

Throws a suitable RuntimeException if the specified element is illegal.

Usage

From source file:com.clarkparsia.openrdf.ConstrainedGraph.java

private static <T> void all(final Iterable<? extends T> theObjects, final Constraint<T> theConstraint) {
    for (T aObj : theObjects) {
        theConstraint.checkElement(aObj);
    }/*from   w w  w  . j  av a  2s . c o m*/
}

From source file:com.eucalyptus.configurable.PropertyChangeListeners.java

public static void applyConstraint(final Object newValue, final Constraint<Object>... constraints)
        throws ConfigurablePropertyException {
    for (final Constraint<Object> testNewValue : constraints) {
        try {//from   ww w. ja va  2 s .  c o m
            final Object constraintedValue = testNewValue.checkElement(newValue);
        } catch (final Exception ex) {
            throw new ConfigurablePropertyException("Failed to evaluate constraint " + testNewValue
                    + " for new value: " + newValue + " because of: " + ex.getMessage());
        }
    }
}

From source file:com.prealpha.minelib.nbt.ListTag.java

public ListTag(Collection<? extends Tag> collection) {
    checkArgument(!collection.isEmpty());
    List<Tag> baseList = Lists.newArrayList(collection);
    elementType = baseList.get(0).getTagType();
    Constraint<Tag> constraint = new TypeConstraint();
    for (Tag tag : baseList) {
        constraint.checkElement(tag);
    }// w  ww. j a  va2 s .  c  o m
    value = Constraints.constrainedList(baseList, constraint);
}