List of usage examples for com.google.common.collect Constraint Constraint
Constraint
From source file:org.richfaces.cdk.util.MoreConstraints.java
public static <E> Constraint<E> cast(final Class<E> clazz) { return new Constraint<E>() { public E checkElement(E element) { return clazz.cast(element); }//from w w w.j a v a 2s .com ; }; }
From source file:com.clarkparsia.openrdf.ConstrainedGraph.java
/** * Return a {@link Constraint} which will only allow {@link OpenRdfUtil#isLiteralValid(org.openrdf.model.Literal) valid} literals into the graph. * * @return a Constraint to enforce valid literals *//*from w ww . ja va 2s .c om*/ public static Constraint<Statement> onlyValidLiterals() { return new Constraint<Statement>() { @Override public Statement checkElement(final Statement theStatement) { if (theStatement.getObject() instanceof Literal && !OpenRdfUtil.isLiteralValid((Literal) theStatement.getObject())) { throw new StatementViolatedConstraintException( theStatement.getObject() + " is not a well-formed literal value."); } return theStatement; } }; }