http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java index 8d4f345..7f8e5a1 100644 --- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java +++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import javax.sql.DataSource; import org.apache.zest.api.ZestAPI; import org.apache.zest.api.association.AssociationDescriptor; @@ -48,7 +49,6 @@ import org.apache.zest.api.structure.Application; import org.apache.zest.api.value.ValueComposite; import org.apache.zest.api.value.ValueDescriptor; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.index.sql.support.api.SQLIndexing; import org.apache.zest.index.sql.support.common.DBNames; import org.apache.zest.index.sql.support.common.QNameInfo; @@ -197,10 +197,10 @@ public abstract class AbstractSQLIndexing Map<Long, EntityState> statesByPK = new HashMap<>(); Map<Long, Integer> qNamePKs = new HashMap<>(); - Iterable<EntityState> relatedStates = Iterables.filter( new Specification<EntityState>() + Iterable<EntityState> relatedStates = Iterables.filter( new Predicate<EntityState>() { @Override - public boolean satisfiedBy( EntityState item ) + public boolean test( EntityState item ) { return item.entityDescriptor().queryable(); }
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java index add0581..b2da873 100644 --- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java +++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.Stack; +import java.util.function.Predicate; import org.apache.zest.api.ZestAPI; import org.apache.zest.api.common.QualifiedName; import org.apache.zest.api.composite.Composite; @@ -37,35 +38,34 @@ import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.injection.scope.Uses; import org.apache.zest.api.property.Property; -import org.apache.zest.api.query.grammar.AndSpecification; +import org.apache.zest.api.query.grammar.AndPredicate; import org.apache.zest.api.query.grammar.AssociationFunction; -import org.apache.zest.api.query.grammar.AssociationNotNullSpecification; -import org.apache.zest.api.query.grammar.AssociationNullSpecification; -import org.apache.zest.api.query.grammar.ComparisonSpecification; -import org.apache.zest.api.query.grammar.ContainsAllSpecification; -import org.apache.zest.api.query.grammar.ContainsSpecification; -import org.apache.zest.api.query.grammar.EqSpecification; -import org.apache.zest.api.query.grammar.GeSpecification; -import org.apache.zest.api.query.grammar.GtSpecification; -import org.apache.zest.api.query.grammar.LeSpecification; -import org.apache.zest.api.query.grammar.LtSpecification; -import org.apache.zest.api.query.grammar.ManyAssociationContainsSpecification; +import org.apache.zest.api.query.grammar.AssociationNotNullPredicate; +import org.apache.zest.api.query.grammar.AssociationNullPredicate; +import org.apache.zest.api.query.grammar.ComparisonPredicate; +import org.apache.zest.api.query.grammar.ContainsAllPredicate; +import org.apache.zest.api.query.grammar.ContainsPredicate; +import org.apache.zest.api.query.grammar.EqPredicate; +import org.apache.zest.api.query.grammar.GePredicate; +import org.apache.zest.api.query.grammar.GtPredicate; +import org.apache.zest.api.query.grammar.LePredicate; +import org.apache.zest.api.query.grammar.LtPredicate; +import org.apache.zest.api.query.grammar.ManyAssociationContainsPredicate; import org.apache.zest.api.query.grammar.ManyAssociationFunction; -import org.apache.zest.api.query.grammar.MatchesSpecification; -import org.apache.zest.api.query.grammar.NeSpecification; -import org.apache.zest.api.query.grammar.NotSpecification; -import org.apache.zest.api.query.grammar.OrSpecification; +import org.apache.zest.api.query.grammar.MatchesPredicate; +import org.apache.zest.api.query.grammar.NePredicate; +import org.apache.zest.api.query.grammar.Notpredicate; +import org.apache.zest.api.query.grammar.OrPredicate; import org.apache.zest.api.query.grammar.OrderBy; import org.apache.zest.api.query.grammar.OrderBy.Order; import org.apache.zest.api.query.grammar.PropertyFunction; -import org.apache.zest.api.query.grammar.PropertyNotNullSpecification; -import org.apache.zest.api.query.grammar.PropertyNullSpecification; +import org.apache.zest.api.query.grammar.PropertyNotNullPredicate; +import org.apache.zest.api.query.grammar.PropertyNullPredicate; import org.apache.zest.api.query.grammar.Variable; import org.apache.zest.api.service.ServiceDescriptor; import org.apache.zest.api.structure.Module; import org.apache.zest.api.value.ValueComposite; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.index.sql.support.api.SQLQuerying; import org.apache.zest.index.sql.support.common.DBNames; import org.apache.zest.index.sql.support.common.QNameInfo; @@ -135,17 +135,17 @@ public abstract class AbstractSQLQuerying this( func.traversedAssociation(), func.traversedManyAssociation() ); } - private TraversedAssoOrManyAssoRef( AssociationNullSpecification<?> spec ) + private TraversedAssoOrManyAssoRef( AssociationNullPredicate<?> spec ) { this( spec.association(), null ); } - private TraversedAssoOrManyAssoRef( AssociationNotNullSpecification<?> spec ) + private TraversedAssoOrManyAssoRef( AssociationNotNullPredicate<?> spec ) { this( spec.association(), null ); } - private TraversedAssoOrManyAssoRef( ManyAssociationContainsSpecification<?> spec ) + private TraversedAssoOrManyAssoRef( ManyAssociationContainsPredicate<?> spec ) { this( null, spec.manyAssociation() ); } @@ -199,7 +199,7 @@ public abstract class AbstractSQLQuerying { public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, @@ -209,11 +209,11 @@ public abstract class AbstractSQLQuerying ); } - private static final Map<Class<? extends Specification>, SQLBooleanCreator> SQL_OPERATORS; + private static final Map<Class<? extends Predicate>, SQLBooleanCreator> SQL_OPERATORS; - private static final Map<Class<? extends Specification>, JoinType> JOIN_STYLES; + private static final Map<Class<? extends Predicate>, JoinType> JOIN_STYLES; - private static final Map<Class<? extends Specification>, JoinType> NEGATED_JOIN_STYLES; + private static final Map<Class<? extends Predicate>, JoinType> NEGATED_JOIN_STYLES; private static final Map<Class<?>, BooleanExpressionProcessor> EXPRESSION_PROCESSORS; @@ -226,7 +226,7 @@ public abstract class AbstractSQLQuerying static { SQL_OPERATORS = new HashMap<>( 9 ); - SQL_OPERATORS.put( EqSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( EqPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -236,7 +236,7 @@ public abstract class AbstractSQLQuerying return factory.eq( left, right ); } } ); - SQL_OPERATORS.put( GeSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( GePredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -246,7 +246,7 @@ public abstract class AbstractSQLQuerying return factory.geq( left, right ); } } ); - SQL_OPERATORS.put( GtSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( GtPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -256,7 +256,7 @@ public abstract class AbstractSQLQuerying return factory.gt( left, right ); } } ); - SQL_OPERATORS.put( LeSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( LePredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -266,7 +266,7 @@ public abstract class AbstractSQLQuerying return factory.leq( left, right ); } } ); - SQL_OPERATORS.put( LtSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( LtPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -276,7 +276,7 @@ public abstract class AbstractSQLQuerying return factory.lt( left, right ); } } ); - SQL_OPERATORS.put( ManyAssociationContainsSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( ManyAssociationContainsPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -286,7 +286,7 @@ public abstract class AbstractSQLQuerying return factory.eq( left, right ); } } ); - SQL_OPERATORS.put( MatchesSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( MatchesPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -296,7 +296,7 @@ public abstract class AbstractSQLQuerying return factory.regexp( left, right ); } } ); - SQL_OPERATORS.put( ContainsSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( ContainsPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -306,7 +306,7 @@ public abstract class AbstractSQLQuerying return factory.eq( left, right ); } } ); - SQL_OPERATORS.put( ContainsAllSpecification.class, new SQLBooleanCreator() + SQL_OPERATORS.put( ContainsAllPredicate.class, new SQLBooleanCreator() { @Override public org.sql.generation.api.grammar.booleans.BooleanExpression getExpression( @@ -318,49 +318,49 @@ public abstract class AbstractSQLQuerying } ); JOIN_STYLES = new HashMap<>( 13 ); - JOIN_STYLES.put( EqSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( GeSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( GtSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( LeSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( LtSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( PropertyNullSpecification.class, JoinType.LEFT_OUTER ); - JOIN_STYLES.put( PropertyNotNullSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( AssociationNullSpecification.class, JoinType.LEFT_OUTER ); - JOIN_STYLES.put( AssociationNotNullSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( ManyAssociationContainsSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( MatchesSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( ContainsSpecification.class, JoinType.INNER ); - JOIN_STYLES.put( ContainsAllSpecification.class, JoinType.INNER ); + JOIN_STYLES.put( EqPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( GePredicate.class, JoinType.INNER ); + JOIN_STYLES.put( GtPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( LePredicate.class, JoinType.INNER ); + JOIN_STYLES.put( LtPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( PropertyNullPredicate.class, JoinType.LEFT_OUTER ); + JOIN_STYLES.put( PropertyNotNullPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( AssociationNullPredicate.class, JoinType.LEFT_OUTER ); + JOIN_STYLES.put( AssociationNotNullPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( ManyAssociationContainsPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( MatchesPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( ContainsPredicate.class, JoinType.INNER ); + JOIN_STYLES.put( ContainsAllPredicate.class, JoinType.INNER ); NEGATED_JOIN_STYLES = new HashMap<>( 13 ); - NEGATED_JOIN_STYLES.put( EqSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( GeSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( GtSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( LeSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( LtSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( PropertyNullSpecification.class, JoinType.INNER ); - NEGATED_JOIN_STYLES.put( PropertyNotNullSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( AssociationNullSpecification.class, JoinType.INNER ); - NEGATED_JOIN_STYLES.put( AssociationNotNullSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( ManyAssociationContainsSpecification.class, JoinType.INNER ); - NEGATED_JOIN_STYLES.put( MatchesSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( ContainsSpecification.class, JoinType.LEFT_OUTER ); - NEGATED_JOIN_STYLES.put( ContainsAllSpecification.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( EqPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( GePredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( GtPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( LePredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( LtPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( PropertyNullPredicate.class, JoinType.INNER ); + NEGATED_JOIN_STYLES.put( PropertyNotNullPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( AssociationNullPredicate.class, JoinType.INNER ); + NEGATED_JOIN_STYLES.put( AssociationNotNullPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( ManyAssociationContainsPredicate.class, JoinType.INNER ); + NEGATED_JOIN_STYLES.put( MatchesPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( ContainsPredicate.class, JoinType.LEFT_OUTER ); + NEGATED_JOIN_STYLES.put( ContainsAllPredicate.class, JoinType.LEFT_OUTER ); EXPRESSION_PROCESSORS = new HashMap<>( 17 ); - EXPRESSION_PROCESSORS.put( AndSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( AndPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { QueryBuilder result = null; - AndSpecification conjunction = (AndSpecification) expression; - for( Specification<Composite> entitySpecification : conjunction.operands() ) + AndPredicate conjunction = (AndPredicate) expression; + for( Predicate<Composite> entitySpecification : conjunction.operands() ) { if( result == null ) { @@ -380,19 +380,19 @@ public abstract class AbstractSQLQuerying return result; } } ); - EXPRESSION_PROCESSORS.put( OrSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( OrPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { QueryBuilder result = null; - OrSpecification conjunction = (OrSpecification) expression; - for( Specification<Composite> entitySpecification : conjunction.operands() ) + OrPredicate conjunction = (OrPredicate) expression; + for( Predicate<Composite> entitySpecification : conjunction.operands() ) { if( result == null ) { @@ -414,143 +414,143 @@ public abstract class AbstractSQLQuerying return result; } } ); - EXPRESSION_PROCESSORS.put( NotSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( Notpredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processBooleanExpression( - ( (NotSpecification) expression ).operand(), !negationActive, vendor, + ( (Notpredicate) expression ).operand(), !negationActive, vendor, entityTypeCondition, variables, values, valueSQLTypes ); } } ); - EXPRESSION_PROCESSORS.put( MatchesSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( MatchesPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { - return thisObject.processMatchesPredicate( (MatchesSpecification) expression, + return thisObject.processMatchesPredicate( (MatchesPredicate) expression, negationActive, vendor, entityTypeCondition, variables, values, valueSQLTypes ); } } ); - EXPRESSION_PROCESSORS.put( ManyAssociationContainsSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( ManyAssociationContainsPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processManyAssociationContainsPredicate( - (ManyAssociationContainsSpecification<?>) expression, negationActive, + (ManyAssociationContainsPredicate<?>) expression, negationActive, vendor, entityTypeCondition, variables, values, valueSQLTypes ); } } ); - EXPRESSION_PROCESSORS.put( PropertyNullSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( PropertyNullPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processPropertyNullPredicate( - (PropertyNullSpecification<?>) expression, negationActive, + (PropertyNullPredicate<?>) expression, negationActive, vendor, entityTypeCondition ); } } ); - EXPRESSION_PROCESSORS.put( PropertyNotNullSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( PropertyNotNullPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processPropertyNotNullPredicate( - (PropertyNotNullSpecification<?>) expression, negationActive, + (PropertyNotNullPredicate<?>) expression, negationActive, vendor, entityTypeCondition ); } } ); - EXPRESSION_PROCESSORS.put( AssociationNullSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( AssociationNullPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processAssociationNullPredicate( - (AssociationNullSpecification<?>) expression, negationActive, + (AssociationNullPredicate<?>) expression, negationActive, vendor, entityTypeCondition ); } } ); - EXPRESSION_PROCESSORS.put( AssociationNotNullSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( AssociationNotNullPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processAssociationNotNullPredicate( - (AssociationNotNullSpecification<?>) expression, negationActive, + (AssociationNotNullPredicate<?>) expression, negationActive, vendor, entityTypeCondition ); } } ); - EXPRESSION_PROCESSORS.put( ContainsSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( ContainsPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { - return thisObject.processContainsPredicate( (ContainsSpecification<?>) expression, + return thisObject.processContainsPredicate( (ContainsPredicate<?>) expression, negationActive, vendor, entityTypeCondition, variables, values, valueSQLTypes ); } } ); - EXPRESSION_PROCESSORS.put( ContainsAllSpecification.class, new BooleanExpressionProcessor() + EXPRESSION_PROCESSORS.put( ContainsAllPredicate.class, new BooleanExpressionProcessor() { @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processContainsAllPredicate( - (ContainsAllSpecification<?>) expression, negationActive, + (ContainsAllPredicate<?>) expression, negationActive, vendor, entityTypeCondition, variables, values, valueSQLTypes ); } } ); @@ -559,22 +559,22 @@ public abstract class AbstractSQLQuerying @Override public QueryBuilder processBooleanExpression( AbstractSQLQuerying thisObject, - Specification<Composite> expression, Boolean negationActive, SQLVendor vendor, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, BooleanExpression entityTypeCondition, Map<String, Object> variables, List<Object> values, List<Integer> valueSQLTypes ) { return thisObject.processComparisonPredicate( - (ComparisonSpecification<?>) expression, negationActive, vendor, + (ComparisonPredicate<?>) expression, negationActive, vendor, entityTypeCondition, variables, values, valueSQLTypes ); } }; - EXPRESSION_PROCESSORS.put( EqSpecification.class, comparisonProcessor ); - EXPRESSION_PROCESSORS.put( NeSpecification.class, comparisonProcessor ); - EXPRESSION_PROCESSORS.put( GeSpecification.class, comparisonProcessor ); - EXPRESSION_PROCESSORS.put( GtSpecification.class, comparisonProcessor ); - EXPRESSION_PROCESSORS.put( LeSpecification.class, comparisonProcessor ); - EXPRESSION_PROCESSORS.put( LtSpecification.class, comparisonProcessor ); + EXPRESSION_PROCESSORS.put( EqPredicate.class, comparisonProcessor ); + EXPRESSION_PROCESSORS.put( NePredicate.class, comparisonProcessor ); + EXPRESSION_PROCESSORS.put( GePredicate.class, comparisonProcessor ); + EXPRESSION_PROCESSORS.put( GtPredicate.class, comparisonProcessor ); + EXPRESSION_PROCESSORS.put( LePredicate.class, comparisonProcessor ); + EXPRESSION_PROCESSORS.put( LtPredicate.class, comparisonProcessor ); } private interface WhereClauseProcessor @@ -747,7 +747,7 @@ public abstract class AbstractSQLQuerying @Override public String constructQuery( Class<?> resultType, // - Specification<Composite> whereClause, // + Predicate<Composite> whereClause, // OrderBy[] orderBySegments, // Integer firstResult, // Integer maxResults, // @@ -816,7 +816,7 @@ public abstract class AbstractSQLQuerying protected abstract QueryExpression finalizeQuery( SQLVendor sqlVendor, QuerySpecificationBuilder specBuilder, Class<?> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, OrderBy[] orderBySegments, Integer firstResult, Integer maxResults, @@ -826,7 +826,7 @@ public abstract class AbstractSQLQuerying Boolean countOnly ); protected QueryBuilder processBooleanExpression( - Specification<Composite> expression, + Predicate<Composite> expression, Boolean negationActive, SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, @@ -881,7 +881,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processMatchesPredicate( - final MatchesSpecification predicate, + final MatchesPredicate predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, @@ -926,7 +926,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processComparisonPredicate( - final ComparisonSpecification<?> predicate, + final ComparisonPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, final Map<String, Object> variables, @@ -977,7 +977,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processManyAssociationContainsPredicate( - final ManyAssociationContainsSpecification<?> predicate, final Boolean negationActive, + final ManyAssociationContainsPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, Map<String, Object> variables, @@ -1030,7 +1030,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processPropertyNullPredicate( - final PropertyNullSpecification<?> predicate, + final PropertyNullPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition ) { @@ -1047,7 +1047,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processPropertyNotNullPredicate( - PropertyNotNullSpecification<?> predicate, + PropertyNotNullPredicate<?> predicate, boolean negationActive, SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition ) { @@ -1064,7 +1064,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processAssociationNullPredicate( - final AssociationNullSpecification<?> predicate, + final AssociationNullPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition ) { @@ -1081,7 +1081,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processAssociationNotNullPredicate( - final AssociationNotNullSpecification<?> predicate, + final AssociationNotNullPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition ) { @@ -1098,7 +1098,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processContainsPredicate( - final ContainsSpecification<?> predicate, + final ContainsPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, final Map<String, Object> variables, @@ -1180,7 +1180,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder processContainsAllPredicate( - final ContainsAllSpecification<?> predicate, final Boolean negationActive, + final ContainsAllPredicate<?> predicate, final Boolean negationActive, final SQLVendor vendor, org.sql.generation.api.grammar.booleans.BooleanExpression entityTypeCondition, final Map<String, Object> variables, final List<Object> values, @@ -1251,7 +1251,7 @@ public abstract class AbstractSQLQuerying } protected QueryBuilder singleQuery( - Specification<Composite> predicate, // + Predicate<Composite> predicate, // PropertyFunction<?> propRef, // TraversedAssoOrManyAssoRef assoRef, // Boolean includeLastAssoPathTable, // @@ -1268,7 +1268,7 @@ public abstract class AbstractSQLQuerying } protected QuerySpecification constructQueryForPredicate( - Specification<Composite> predicate, // + Predicate<Composite> predicate, // PropertyFunction<?> propRef, // TraversedAssoOrManyAssoRef assoRef, // Boolean includeLastAssoPathTable, // @@ -1343,29 +1343,29 @@ public abstract class AbstractSQLQuerying ); } - protected SQLBooleanCreator getOperator( Specification<Composite> predicate ) + protected SQLBooleanCreator getOperator( Predicate<Composite> predicate ) { return this.findFromLookupTables( SQL_OPERATORS, null, predicate, false ); } protected JoinType - getTableJoinStyle( Specification<Composite> predicate, Boolean negationActive ) + getTableJoinStyle( Predicate<Composite> predicate, Boolean negationActive ) { return this.findFromLookupTables( JOIN_STYLES, NEGATED_JOIN_STYLES, predicate, negationActive ); } protected <ReturnType> ReturnType findFromLookupTables( - Map<Class<? extends Specification>, ReturnType> normal, - Map<Class<? extends Specification>, ReturnType> negated, - Specification<Composite> predicate, Boolean negationActive ) + Map<Class<? extends Predicate>, ReturnType> normal, + Map<Class<? extends Predicate>, ReturnType> negated, + Predicate<Composite> predicate, Boolean negationActive ) { - Class<? extends Specification> predicateClass = predicate.getClass(); + Class<? extends Predicate> predicateClass = predicate.getClass(); ReturnType result = null; - Set<Map.Entry<Class<? extends Specification>, ReturnType>> entries = negationActive + Set<Map.Entry<Class<? extends Predicate>, ReturnType>> entries = negationActive ? negated.entrySet() : normal.entrySet(); - for( Map.Entry<Class<? extends Specification>, ReturnType> entry : entries ) + for( Map.Entry<Class<? extends Predicate>, ReturnType> entry : entries ) { if( entry.getKey().isAssignableFrom( predicateClass ) ) { @@ -1647,7 +1647,7 @@ public abstract class AbstractSQLQuerying protected Integer modifyFromClauseAndWhereClauseToGetValue( final QualifiedName qName, Object value, - final Specification<Composite> predicate, final Boolean negationActive, + final Predicate<Composite> predicate, final Boolean negationActive, final Integer currentTableIndex, final ModifiableInt maxTableIndex, final String columnName, final String collectionPath, http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java index f909290..8bb35ac 100644 --- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java +++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java @@ -38,6 +38,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.sql.DataSource; @@ -61,7 +62,6 @@ import org.apache.zest.api.structure.ModuleDescriptor; import org.apache.zest.api.value.ValueDescriptor; import org.apache.zest.functional.HierarchicalVisitorAdapter; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.index.reindexer.Reindexer; import org.apache.zest.index.sql.support.api.SQLAppStartup; import org.apache.zest.index.sql.support.api.SQLTypeInfo; @@ -1519,10 +1519,10 @@ public abstract class AbstractSQLStartup // TODO this doesn't understand, say, Map<String, String>, or indeed, // any // other Serializable - if( Iterables.matchesAny( new Specification<Class<?>>() + if( Iterables.matchesAny( new Predicate<Class<?>>() { @Override - public boolean satisfiedBy( Class<?> item ) + public boolean test( Class<?> item ) { return vTypeClass.isAssignableFrom( item ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java index c3469ad..5c8789f 100644 --- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java +++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java @@ -18,6 +18,7 @@ package org.apache.zest.index.sql.support.skeletons; import java.util.function.Function; +import java.util.function.Predicate; import org.apache.zest.api.association.AssociationDescriptor; import org.apache.zest.api.association.AssociationStateDescriptor; import org.apache.zest.api.common.QualifiedName; @@ -29,7 +30,6 @@ import org.apache.zest.api.type.CollectionType; import org.apache.zest.api.type.ValueCompositeType; import org.apache.zest.api.type.ValueType; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.spi.entity.EntityState; import org.apache.zest.spi.entity.EntityStatus; import org.apache.zest.spi.entity.ManyAssociationState; @@ -57,11 +57,11 @@ import org.slf4j.LoggerFactory; return new SQLCompatEntityStateWrapper( from ); } }; - private static final Specification<PropertyDescriptor> PROPERTY_SPEC = new Specification<PropertyDescriptor>() + private static final Predicate<PropertyDescriptor> PROPERTY_SPEC = new Predicate<PropertyDescriptor>() { @Override - public boolean satisfiedBy( PropertyDescriptor propertyDescriptor ) + public boolean test( PropertyDescriptor propertyDescriptor ) { boolean supported = isSupported( propertyDescriptor.valueType() ); if( !supported ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java ---------------------------------------------------------------------- diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java index 8a968b0..3cb08f4 100644 --- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java +++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java @@ -22,7 +22,7 @@ import java.beans.PropertyVetoException; import java.beans.VetoableChangeListener; import java.beans.VetoableChangeSupport; import java.util.Date; -import org.apache.zest.functional.Specification; +import java.util.function.Predicate; import org.apache.zest.functional.Specifications; import static org.apache.zest.functional.Specifications.not; @@ -40,7 +40,7 @@ public class CircuitBreaker private int threshold; private long timeout; - private Specification<Throwable> allowedThrowables; + private Predicate<Throwable> allowedThrowables; private int countDown; private long trippedOn = -1; @@ -53,7 +53,7 @@ public class CircuitBreaker PropertyChangeSupport pcs = new PropertyChangeSupport( this ); VetoableChangeSupport vcs = new VetoableChangeSupport( this ); - public CircuitBreaker( int threshold, long timeout, Specification<Throwable> allowedThrowables ) + public CircuitBreaker( int threshold, long timeout, Predicate<Throwable> allowedThrowables ) { this.threshold = threshold; this.countDown = threshold; @@ -186,7 +186,7 @@ public class CircuitBreaker { if( status == Status.on ) { - if( allowedThrowables.satisfiedBy( throwable ) ) + if( allowedThrowables.test( throwable ) ) { // Allowed throwable, so counts as success success(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java ---------------------------------------------------------------------- diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java index f7f464d..ac51134 100644 --- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java +++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java @@ -15,7 +15,7 @@ */ package org.apache.zest.library.circuitbreaker; -import org.apache.zest.functional.Specification; +import java.util.function.Predicate; import org.apache.zest.io.Output; import org.apache.zest.io.Receiver; import org.apache.zest.io.Sender; @@ -73,12 +73,12 @@ public class CircuitBreakers * @param throwables The Throwable types that are allowed. * @return A Specification that specifies the allowed Throwables. */ - public static Specification<Throwable> in( final Class<? extends Throwable>... throwables) + public static Predicate<Throwable> in( final Class<? extends Throwable>... throwables) { - return new Specification<Throwable>() + return new Predicate<Throwable>() { @Override - public boolean satisfiedBy( Throwable item ) + public boolean test( Throwable item ) { Class<? extends Throwable> throwableClass = item.getClass(); for (Class<? extends Throwable> throwable : throwables) @@ -91,14 +91,14 @@ public class CircuitBreakers }; } - public static Specification<Throwable> rootCause( final Specification<Throwable> specification) + public static Predicate<Throwable> rootCause( final Predicate<Throwable> specification) { - return new Specification<Throwable>() + return new Predicate<Throwable>() { @Override - public boolean satisfiedBy( Throwable item ) + public boolean test( Throwable item ) { - return specification.satisfiedBy( unwrap(item) ); + return specification.test( unwrap(item) ); } private Throwable unwrap(Throwable item) http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java ---------------------------------------------------------------------- diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java index 3824728..72dc033 100644 --- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java +++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java @@ -182,7 +182,7 @@ public interface EntityToValue { AssociationStateDescriptor entityState = entityDescriptor.state(); String associationName = descriptor.qualifiedName().name(); - if( STRING_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) + if( STRING_TYPE_SPEC.test( descriptor.valueType() ) ) { // Find Association and convert to string AssociationDescriptor associationDescriptor; @@ -205,7 +205,7 @@ public interface EntityToValue return null; } } - else if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) + else if( STRING_COLLECTION_TYPE_SPEC.test( descriptor.valueType() ) ) { AssociationDescriptor associationDescriptor; try @@ -225,7 +225,7 @@ public interface EntityToValue } return entities; } - else if( STRING_MAP_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) + else if( STRING_MAP_TYPE_SPEC.test( descriptor.valueType() ) ) { AssociationDescriptor associationDescriptor; try @@ -305,7 +305,7 @@ public interface EntityToValue } catch( IllegalArgumentException e ) { - if( STRING_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) + if( STRING_TYPE_SPEC.test( descriptor.valueType() ) ) { // Find Association and convert to string AssociationDescriptor associationDescriptor; @@ -329,7 +329,7 @@ public interface EntityToValue return null; } } - else if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) + else if( STRING_COLLECTION_TYPE_SPEC.test( descriptor.valueType() ) ) { AssociationDescriptor associationDescriptor; try @@ -350,7 +350,7 @@ public interface EntityToValue } return entities; } - else if( STRING_MAP_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) + else if( STRING_MAP_TYPE_SPEC.test( descriptor.valueType() ) ) { AssociationDescriptor associationDescriptor; try http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java ---------------------------------------------------------------------- diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java index 40a0d27..5581e5f 100644 --- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java +++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java @@ -15,44 +15,44 @@ */ package org.apache.zest.library.conversion.values; +import java.util.function.Predicate; import org.apache.zest.api.type.CollectionType; import org.apache.zest.api.type.MapType; import org.apache.zest.api.type.ValueType; -import org.apache.zest.functional.Specification; /** * Shared. */ final class Shared { - static final Specification<ValueType> STRING_TYPE_SPEC; - static final Specification<ValueType> STRING_COLLECTION_TYPE_SPEC; - static final Specification<ValueType> STRING_MAP_TYPE_SPEC; + static final Predicate<ValueType> STRING_TYPE_SPEC; + static final Predicate<ValueType> STRING_COLLECTION_TYPE_SPEC; + static final Predicate<ValueType> STRING_MAP_TYPE_SPEC; static { // Type Specifications - STRING_TYPE_SPEC = new Specification<ValueType>() + STRING_TYPE_SPEC = new Predicate<ValueType>() { @Override - public boolean satisfiedBy( ValueType valueType ) + public boolean test( ValueType valueType ) { return valueType.mainType().equals( String.class ); } }; - STRING_COLLECTION_TYPE_SPEC = new Specification<ValueType>() + STRING_COLLECTION_TYPE_SPEC = new Predicate<ValueType>() { @Override - public boolean satisfiedBy( ValueType valueType ) + public boolean test( ValueType valueType ) { return valueType instanceof CollectionType && ( (CollectionType) valueType ).collectedType().mainType().equals( String.class ); } }; - STRING_MAP_TYPE_SPEC = new Specification<ValueType>() + STRING_MAP_TYPE_SPEC = new Predicate<ValueType>() { @Override - public boolean satisfiedBy( ValueType valueType ) + public boolean test( ValueType valueType ) { return valueType instanceof MapType && ( (MapType) valueType ).keyType().mainType().equals( String.class ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java ---------------------------------------------------------------------- diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java index cecb4e6..2fb8c16 100644 --- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java +++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java @@ -277,7 +277,7 @@ public class ValueToEntityMixin try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); - if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) ) { String assocState = (String) vState.propertyFor( vPropDesc.accessor() ).get(); return EntityReference.parseEntityReference( assocState ); @@ -309,7 +309,7 @@ public class ValueToEntityMixin try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); - if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Collection<String> vAssocState = (Collection) vState .propertyFor( vPropDesc.accessor() ).get(); @@ -342,7 +342,7 @@ public class ValueToEntityMixin try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); - if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Map<String, String> vAssocState = (Map) vState .propertyFor( vPropDesc.accessor() ).get(); @@ -405,7 +405,7 @@ public class ValueToEntityMixin try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName ); - if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) ) { String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get(); return assocId == null ? null : EntityReference.parseEntityReference( assocId ); @@ -438,7 +438,7 @@ public class ValueToEntityMixin try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName ); - if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Collection<String> vAssocState = (Collection) vState .propertyFor( vPropDesc.accessor() ).get(); @@ -472,7 +472,7 @@ public class ValueToEntityMixin try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName ); - if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Map<String, String> vAssocState = (Map) vState .propertyFor( vPropDesc.accessor() ).get(); @@ -562,7 +562,7 @@ public class ValueToEntityMixin { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() ); - if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) ) { String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get(); if( assocId != null ) @@ -605,7 +605,7 @@ public class ValueToEntityMixin { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() ); - if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Collection<String> vAssocState = (Collection) vState.propertyFor( vPropDesc.accessor() ).get(); for( Object assoc : eManyAssoc.toList() ) @@ -653,7 +653,7 @@ public class ValueToEntityMixin { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() ); - if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Map<String, String> vAssocState = (Map) vState.propertyFor( vPropDesc.accessor() ).get(); for( String assocName : Iterables.toList( eNamedAssoc ) ) @@ -717,7 +717,7 @@ public class ValueToEntityMixin { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() ); - if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) ) { String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get(); if( assocId != null ) @@ -760,7 +760,7 @@ public class ValueToEntityMixin { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() ); - if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Collection<String> vAssocState = (Collection) vState.propertyFor( vPropDesc.accessor() ).get(); for( Object ass : eManyAssoc.toList() ) @@ -808,7 +808,7 @@ public class ValueToEntityMixin { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() ); - if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) + if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) ) { Map<String, String> vAssocState = (Map) vState.propertyFor( vPropDesc.accessor() ).get(); for( String assocName : Iterables.toList( eNamedAssoc ) ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java ---------------------------------------------------------------------- diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java index 938ae74..8197ebe 100644 --- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java +++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java @@ -17,6 +17,7 @@ package org.apache.zest.library.conversion.values; import java.util.Arrays; import java.util.Date; +import java.util.function.Predicate; import org.junit.Before; import org.junit.Test; import org.apache.zest.api.constraint.ConstraintViolationException; @@ -26,7 +27,6 @@ import org.apache.zest.api.value.ValueBuilder; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.ModuleAssembly; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.library.conversion.values.TestModel.PersonEntity; import org.apache.zest.library.conversion.values.TestModel.PersonValue; import org.apache.zest.library.conversion.values.TestModel.PersonValue2; @@ -105,10 +105,10 @@ public class ValueToEntityTest assertThat( edEntity.firstName(), equalTo( "Ed" ) ); assertThat( edEntity.lastName(), equalTo( "Flintstone" ) ); assertThat( edEntity.spouse().get().firstName(), equalTo( "Edna" ) ); - assertThat( Iterables.count( Iterables.filter( new Specification<PersonEntity>() + assertThat( Iterables.count( Iterables.filter( new Predicate<PersonEntity>() { @Override - public boolean satisfiedBy( PersonEntity child ) + public boolean test( PersonEntity child ) { return "Zeke".equals( child.firstName() ) || "Fred".equals( child.firstName() ); } @@ -139,10 +139,10 @@ public class ValueToEntityTest assertThat( edEntity.firstName(), equalTo( "Ed" ) ); assertThat( edEntity.lastName(), equalTo( "Flintstone" ) ); assertThat( edEntity.spouse().get().firstName(), equalTo( "Edna" ) ); - assertThat( Iterables.count( Iterables.filter( new Specification<PersonEntity>() + assertThat( Iterables.count( Iterables.filter( new Predicate<PersonEntity>() { @Override - public boolean satisfiedBy( PersonEntity child ) + public boolean test( PersonEntity child ) { return "Zeke".equals( child.firstName() ) || "Fred".equals( child.firstName() ); } @@ -173,10 +173,10 @@ public class ValueToEntityTest assertThat( edEntity.firstName(), equalTo( "Ed" ) ); assertThat( edEntity.lastName(), equalTo( "Flintstone" ) ); assertThat( edEntity.spouse().get().firstName(), equalTo( "Edna" ) ); - assertThat( Iterables.count( Iterables.filter( new Specification<PersonEntity>() + assertThat( Iterables.count( Iterables.filter( new Predicate<PersonEntity>() { @Override - public boolean satisfiedBy( PersonEntity child ) + public boolean test( PersonEntity child ) { return "Zeke".equals( child.firstName() ) || "Fred".equals( child.firstName() ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java ---------------------------------------------------------------------- diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java index fcc6117..fecf3cb 100644 --- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java +++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java @@ -21,9 +21,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.function.Function; +import java.util.function.Predicate; import org.apache.zest.api.util.Methods; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.io.Output; import org.apache.zest.io.Receiver; import org.apache.zest.io.Sender; @@ -61,19 +61,19 @@ public class ApplicationEvents return Iterables.flatten( events.<Iterable<ApplicationEvent>>toArray( iterables ) ); } - public static boolean matches( Specification<ApplicationEvent> specification, Iterable<TransactionApplicationEvents> transactions ) + public static boolean matches( Predicate<ApplicationEvent> specification, Iterable<TransactionApplicationEvents> transactions ) { return Iterables.filter( specification, events( transactions ) ).iterator().hasNext(); } // Common specifications - public static Specification<ApplicationEvent> withNames( final Iterable<String> names ) + public static Predicate<ApplicationEvent> withNames( final Iterable<String> names ) { - return new Specification<ApplicationEvent>() + return new Predicate<ApplicationEvent>() { @Override - public boolean satisfiedBy( ApplicationEvent event ) + public boolean test( ApplicationEvent event ) { for (String name : names) { @@ -85,12 +85,12 @@ public class ApplicationEvents }; } - public static Specification<ApplicationEvent> withNames( final String... names ) + public static Predicate<ApplicationEvent> withNames( final String... names ) { - return new Specification<ApplicationEvent>() + return new Predicate<ApplicationEvent>() { @Override - public boolean satisfiedBy( ApplicationEvent event ) + public boolean test( ApplicationEvent event ) { for (String name : names) { @@ -102,7 +102,7 @@ public class ApplicationEvents }; } - public static Specification<ApplicationEvent> withNames( final Class eventClass ) + public static Predicate<ApplicationEvent> withNames( final Class eventClass ) { return ApplicationEvents.withNames( Iterables.map( new Function<Method, String>() { @@ -114,36 +114,36 @@ public class ApplicationEvents }, Iterables.toList( Methods.METHODS_OF.apply( eventClass ) ) )); } - public static Specification<ApplicationEvent> afterDate( final Date afterDate ) + public static Predicate<ApplicationEvent> afterDate( final Date afterDate ) { - return new Specification<ApplicationEvent>() + return new Predicate<ApplicationEvent>() { @Override - public boolean satisfiedBy( ApplicationEvent event ) + public boolean test( ApplicationEvent event ) { return event.on().get().after( afterDate ); } }; } - public static Specification<ApplicationEvent> beforeDate( final Date beforeDate ) + public static Predicate<ApplicationEvent> beforeDate( final Date beforeDate ) { - return new Specification<ApplicationEvent>() + return new Predicate<ApplicationEvent>() { @Override - public boolean satisfiedBy( ApplicationEvent event ) + public boolean test( ApplicationEvent event ) { return event.on().get().before( beforeDate ); } }; } - public static Specification<ApplicationEvent> withUsecases( final String... names ) + public static Predicate<ApplicationEvent> withUsecases( final String... names ) { - return new Specification<ApplicationEvent>() + return new Predicate<ApplicationEvent>() { @Override - public boolean satisfiedBy( ApplicationEvent event ) + public boolean test( ApplicationEvent event ) { for (String name : names) { @@ -155,12 +155,12 @@ public class ApplicationEvents }; } - public static Specification<ApplicationEvent> paramIs( final String name, final String value ) + public static Predicate<ApplicationEvent> paramIs( final String name, final String value ) { - return new Specification<ApplicationEvent>() + return new Predicate<ApplicationEvent>() { @Override - public boolean satisfiedBy( ApplicationEvent event ) + public boolean test( ApplicationEvent event ) { return ApplicationEventParameters.getParameter( event, name ).equals( value ); } @@ -169,7 +169,7 @@ public class ApplicationEvents public static Output<TransactionApplicationEvents, ApplicationEventReplayException> playEvents( final ApplicationEventPlayer player, final Object eventHandler ) { - final Specification<ApplicationEvent> specification = ApplicationEvents.withNames( eventHandler.getClass() ); + final Predicate<ApplicationEvent> specification = ApplicationEvents.withNames( eventHandler.getClass() ); return new Output<TransactionApplicationEvents, ApplicationEventReplayException>() { @@ -183,7 +183,7 @@ public class ApplicationEvents { for (ApplicationEvent applicationEvent : events( item )) { - if (specification.satisfiedBy( applicationEvent )) + if (specification.test( applicationEvent )) player.playEvent( applicationEvent, eventHandler ); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java ---------------------------------------------------------------------- diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java index 5de53f0..d8d1ab0 100644 --- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java +++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java @@ -19,7 +19,7 @@ package org.apache.zest.library.eventsourcing.domain.source.helper; import java.util.LinkedHashMap; import java.util.Map; -import org.apache.zest.functional.Specification; +import java.util.function.Predicate; import org.apache.zest.io.Output; import org.apache.zest.io.Receiver; import org.apache.zest.io.Sender; @@ -35,7 +35,7 @@ import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsVa public class EventRouter<T extends Throwable> implements Output<DomainEventValue, T>, Receiver<UnitOfWorkDomainEventsValue, T> { - private Map<Specification<DomainEventValue>, Receiver<DomainEventValue, T>> routeEvent = new LinkedHashMap<Specification<DomainEventValue>, Receiver<DomainEventValue, T>>(); + private Map<Predicate<DomainEventValue>, Receiver<DomainEventValue, T>> routeEvent = new LinkedHashMap<Predicate<DomainEventValue>, Receiver<DomainEventValue, T>>(); private Receiver<DomainEventValue, T> defaultReceiver = new Receiver<DomainEventValue, T>() { @@ -46,7 +46,7 @@ public class EventRouter<T extends Throwable> } }; - public EventRouter route( Specification<DomainEventValue> specification, Receiver<DomainEventValue, T> receiver ) + public EventRouter route( Predicate<DomainEventValue> specification, Receiver<DomainEventValue, T> receiver ) { routeEvent.put( specification, receiver ); @@ -67,9 +67,9 @@ public class EventRouter<T extends Throwable> @Override public void receive( DomainEventValue item ) throws T { - for( Map.Entry<Specification<DomainEventValue>, Receiver<DomainEventValue, T>> specificationReceiverEntry : routeEvent.entrySet() ) + for( Map.Entry<Predicate<DomainEventValue>, Receiver<DomainEventValue, T>> specificationReceiverEntry : routeEvent.entrySet() ) { - if( specificationReceiverEntry.getKey().satisfiedBy( item ) ) + if( specificationReceiverEntry.getKey().test( item ) ) { specificationReceiverEntry.getValue().receive( item ); return; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java ---------------------------------------------------------------------- diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java index ff2a466..dd39f64 100644 --- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java +++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java @@ -19,9 +19,9 @@ package org.apache.zest.library.eventsourcing.domain.source.helper; import java.lang.reflect.Method; import java.util.Date; import java.util.function.Function; +import java.util.function.Predicate; import org.apache.zest.api.util.Methods; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue; import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue; @@ -50,36 +50,36 @@ public class Events } // Common specifications - public static Specification<UnitOfWorkDomainEventsValue> afterDate( final Date afterDate ) + public static Predicate<UnitOfWorkDomainEventsValue> afterDate( final Date afterDate ) { - return new Specification<UnitOfWorkDomainEventsValue>() + return new Predicate<UnitOfWorkDomainEventsValue>() { @Override - public boolean satisfiedBy( UnitOfWorkDomainEventsValue eventValue ) + public boolean test( UnitOfWorkDomainEventsValue eventValue ) { return eventValue.timestamp().get() > afterDate.getTime(); } }; } - public static Specification<UnitOfWorkDomainEventsValue> beforeDate( final Date afterDate ) + public static Predicate<UnitOfWorkDomainEventsValue> beforeDate( final Date afterDate ) { - return new Specification<UnitOfWorkDomainEventsValue>() + return new Predicate<UnitOfWorkDomainEventsValue>() { @Override - public boolean satisfiedBy( UnitOfWorkDomainEventsValue eventValue ) + public boolean test( UnitOfWorkDomainEventsValue eventValue ) { return eventValue.timestamp().get() < afterDate.getTime(); } }; } - public static Specification<UnitOfWorkDomainEventsValue> withUsecases( final String... names ) + public static Predicate<UnitOfWorkDomainEventsValue> withUsecases( final String... names ) { - return new Specification<UnitOfWorkDomainEventsValue>() + return new Predicate<UnitOfWorkDomainEventsValue>() { @Override - public boolean satisfiedBy( UnitOfWorkDomainEventsValue eventValue ) + public boolean test( UnitOfWorkDomainEventsValue eventValue ) { for (String name : names) { @@ -91,12 +91,12 @@ public class Events }; } - public static Specification<UnitOfWorkDomainEventsValue> byUser( final String... by ) + public static Predicate<UnitOfWorkDomainEventsValue> byUser( final String... by ) { - return new Specification<UnitOfWorkDomainEventsValue>() + return new Predicate<UnitOfWorkDomainEventsValue>() { @Override - public boolean satisfiedBy( UnitOfWorkDomainEventsValue eventValue ) + public boolean test( UnitOfWorkDomainEventsValue eventValue ) { for (String user : by) { @@ -108,12 +108,12 @@ public class Events }; } - public static Specification<DomainEventValue> withNames( final Iterable<String> names ) + public static Predicate<DomainEventValue> withNames( final Iterable<String> names ) { - return new Specification<DomainEventValue>() + return new Predicate<DomainEventValue>() { @Override - public boolean satisfiedBy( DomainEventValue eventValue ) + public boolean test( DomainEventValue eventValue ) { for (String name : names) { @@ -125,12 +125,12 @@ public class Events }; } - public static Specification<DomainEventValue> withNames( final String... names ) + public static Predicate<DomainEventValue> withNames( final String... names ) { - return new Specification<DomainEventValue>() + return new Predicate<DomainEventValue>() { @Override - public boolean satisfiedBy( DomainEventValue eventValue ) + public boolean test( DomainEventValue eventValue ) { for (String name : names) { @@ -142,7 +142,7 @@ public class Events }; } - public static Specification<DomainEventValue> withNames( final Class eventClass ) + public static Predicate<DomainEventValue> withNames( final Class eventClass ) { return Events.withNames( map( new Function<Method, String>() { @@ -154,12 +154,12 @@ public class Events }, Iterables.toList( Methods.METHODS_OF.apply( eventClass ) ) )); } - public static Specification<DomainEventValue> onEntities( final String... entities ) + public static Predicate<DomainEventValue> onEntities( final String... entities ) { - return new Specification<DomainEventValue>() + return new Predicate<DomainEventValue>() { @Override - public boolean satisfiedBy( DomainEventValue eventValue ) + public boolean test( DomainEventValue eventValue ) { for (String entity : entities) { @@ -171,12 +171,12 @@ public class Events }; } - public static Specification<DomainEventValue> onEntityTypes( final String... entityTypes ) + public static Predicate<DomainEventValue> onEntityTypes( final String... entityTypes ) { - return new Specification<DomainEventValue>() + return new Predicate<DomainEventValue>() { @Override - public boolean satisfiedBy( DomainEventValue eventValue ) + public boolean test( DomainEventValue eventValue ) { for (String entityType : entityTypes) { @@ -188,12 +188,12 @@ public class Events }; } - public static Specification<DomainEventValue> paramIs( final String name, final String value ) + public static Predicate<DomainEventValue> paramIs( final String name, final String value ) { - return new Specification<DomainEventValue>() + return new Predicate<DomainEventValue>() { @Override - public boolean satisfiedBy( DomainEventValue eventValue ) + public boolean test( DomainEventValue eventValue ) { return EventParameters.getParameter( eventValue, name ).equals( value ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java ---------------------------------------------------------------------- diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java index 89159bd..b032018 100644 --- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java +++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java @@ -19,7 +19,7 @@ package org.apache.zest.library.eventsourcing.domain.source.helper; import java.util.LinkedHashMap; import java.util.Map; -import org.apache.zest.functional.Specification; +import java.util.function.Predicate; import org.apache.zest.io.Output; import org.apache.zest.io.Receiver; import org.apache.zest.io.Sender; @@ -33,7 +33,7 @@ import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsVa public class UnitOfWorkRouter<T extends Throwable> implements Output<UnitOfWorkDomainEventsValue, T> { - private Map<Specification<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> routes = new LinkedHashMap<Specification<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>>( ); + private Map<Predicate<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> routes = new LinkedHashMap<Predicate<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>>( ); private Receiver<UnitOfWorkDomainEventsValue, T> defaultReceiver = new Receiver<UnitOfWorkDomainEventsValue, T>() { @@ -44,7 +44,7 @@ public class UnitOfWorkRouter<T extends Throwable> } }; - public UnitOfWorkRouter route( Specification<UnitOfWorkDomainEventsValue> specification, Receiver<UnitOfWorkDomainEventsValue, T> receiver) + public UnitOfWorkRouter route( Predicate<UnitOfWorkDomainEventsValue> specification, Receiver<UnitOfWorkDomainEventsValue, T> receiver) { routes.put(specification, receiver); @@ -65,9 +65,9 @@ public class UnitOfWorkRouter<T extends Throwable> @Override public void receive( UnitOfWorkDomainEventsValue item ) throws T { - for( Map.Entry<Specification<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> specificationReceiverEntry : routes.entrySet() ) + for( Map.Entry<Predicate<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> specificationReceiverEntry : routes.entrySet() ) { - if (specificationReceiverEntry.getKey().satisfiedBy( item )) + if (specificationReceiverEntry.getKey().test( item )) { specificationReceiverEntry.getValue().receive( item ); return; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ZestMBeans.java ---------------------------------------------------------------------- diff --git a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ZestMBeans.java b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ZestMBeans.java index b6adc9f..ff75625 100644 --- a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ZestMBeans.java +++ b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ZestMBeans.java @@ -13,11 +13,11 @@ */ package org.apache.zest.library.jmx; +import java.util.function.Predicate; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; /** * Helper for working with Zest MBeans. @@ -28,10 +28,10 @@ public class ZestMBeans public static ObjectName findServiceName( MBeanServer server, String applicationName, String serviceId ) throws MalformedObjectNameException { - return Iterables.first( Iterables.filter( new Specification<ObjectName>() + return Iterables.first( Iterables.filter( new Predicate<ObjectName>() { @Override - public boolean satisfiedBy( ObjectName item ) + public boolean test( ObjectName item ) { return item.getKeyPropertyList().size() == 5; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/api/ContextResourceClient.java ---------------------------------------------------------------------- diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/api/ContextResourceClient.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/api/ContextResourceClient.java index 1b56eaa..25c41ec 100644 --- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/api/ContextResourceClient.java +++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/api/ContextResourceClient.java @@ -272,7 +272,7 @@ public class ContextResourceClient // Check if we should do POST or PUT Method method; - if( LinksUtil.withClass( "idempotent" ).satisfiedBy( link ) ) + if( LinksUtil.withClass( "idempotent" ).test( link ) ) { method = Method.PUT; }
