You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/08/26 17:45:13 UTC
[10/24] zest-java git commit: ZEST-113;
Removed the use of Specification and replaced with Java 8 Predicate.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java
deleted file mode 100644
index 3a28f16..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Less or equals Specification.
- */
-public class LeSpecification<T>
- extends ComparisonSpecification<T>
-{
- public LeSpecification( PropertyFunction<T> property, T value )
- {
- super( property, value );
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- protected boolean compare( T value )
- {
- return ( (Comparable) value ).compareTo( this.value ) <= 0;
- }
-
- @Override
- public String toString()
- {
- return property.toString() + "<=" + value.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/LtPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/LtPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/LtPredicate.java
new file mode 100644
index 0000000..ecee020
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/LtPredicate.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+/**
+ * Lesser than Specification.
+ */
+public class LtPredicate<T>
+ extends ComparisonPredicate<T>
+{
+ public LtPredicate( PropertyFunction<T> property, T value )
+ {
+ super( property, value );
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ protected boolean compare( T value )
+ {
+ return ( (Comparable) value ).compareTo( this.value ) < 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ return property.toString() + "<" + value.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java
deleted file mode 100644
index 8f476c3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Lesser than Specification.
- */
-public class LtSpecification<T>
- extends ComparisonSpecification<T>
-{
- public LtSpecification( PropertyFunction<T> property, T value )
- {
- super( property, value );
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- protected boolean compare( T value )
- {
- return ( (Comparable) value ).compareTo( this.value ) < 0;
- }
-
- @Override
- public String toString()
- {
- return property.toString() + "<" + value.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsPredicate.java
new file mode 100644
index 0000000..af60033
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsPredicate.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-2011 Rickard Öberg.
+ * Copyright 2007-2010 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import org.apache.zest.api.association.ManyAssociation;
+import org.apache.zest.api.composite.Composite;
+
+/**
+ * ManyAssociation Contains Specification.
+ */
+public class ManyAssociationContainsPredicate<T>
+ extends ExpressionPredicate
+{
+ private final ManyAssociationFunction<T> manyAssociationFunction;
+ private final T value;
+
+ public ManyAssociationContainsPredicate( ManyAssociationFunction<T> manyAssociationFunction, T value )
+ {
+ this.manyAssociationFunction = manyAssociationFunction;
+ this.value = value;
+ }
+
+ public ManyAssociationFunction<T> manyAssociation()
+ {
+ return manyAssociationFunction;
+ }
+
+ public T value()
+ {
+ return value;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ ManyAssociation<T> collection = manyAssociationFunction.apply( item );
+ if( collection == null )
+ {
+ return false;
+ }
+ return collection.contains( value );
+ }
+
+ @Override
+ public String toString()
+ {
+ return manyAssociationFunction + " contains:" + value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java
deleted file mode 100644
index 1814b26..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2007-2011 Rickard Öberg.
- * Copyright 2007-2010 Niclas Hedhman.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * ManyAssociation Contains Specification.
- */
-public class ManyAssociationContainsSpecification<T>
- extends ExpressionSpecification
-{
- private final ManyAssociationFunction<T> manyAssociationFunction;
- private final T value;
-
- public ManyAssociationContainsSpecification( ManyAssociationFunction<T> manyAssociationFunction, T value )
- {
- this.manyAssociationFunction = manyAssociationFunction;
- this.value = value;
- }
-
- public ManyAssociationFunction<T> manyAssociation()
- {
- return manyAssociationFunction;
- }
-
- public T value()
- {
- return value;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- ManyAssociation<T> collection = manyAssociationFunction.apply( item );
- if( collection == null )
- {
- return false;
- }
- return collection.contains( value );
- }
-
- @Override
- public String toString()
- {
- return manyAssociationFunction + " contains:" + value;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java
new file mode 100644
index 0000000..b217680
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import org.apache.zest.api.composite.Composite;
+import org.apache.zest.api.property.Property;
+
+/**
+ * Regular expression match Specification.
+ */
+public class MatchesPredicate
+ extends ExpressionPredicate
+{
+ private PropertyFunction<String> property;
+ private Object value;
+
+ public MatchesPredicate( PropertyFunction<String> property, String regexp )
+ {
+ this.property = property;
+ this.value = regexp;
+ }
+
+ public MatchesPredicate( PropertyFunction<String> property, Variable variable )
+ {
+ this.property = property;
+ this.value = variable;
+ }
+
+ public PropertyFunction<String> property()
+ {
+ return property;
+ }
+
+ public Object value()
+ {
+ return value;
+ }
+
+ public String regexp()
+ {
+ return ( String ) value;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ Property<String> prop = property.apply( item );
+
+ if( prop == null )
+ {
+ return false;
+ }
+
+ String val = prop.get();
+
+ if( val == null )
+ {
+ return false;
+ }
+
+ return val.matches( ( String ) value );
+ }
+
+ @Override
+ public String toString()
+ {
+ return new StringBuilder()
+ .append( "( " )
+ .append( property )
+ .append( " matches " )
+ .append( "\"" )
+ .append( value )
+ .append( "\"" )
+ .append( " )" )
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java
deleted file mode 100644
index c18c3c0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Regular expression match Specification.
- */
-public class MatchesSpecification
- extends ExpressionSpecification
-{
- private PropertyFunction<String> property;
- private Object value;
-
- public MatchesSpecification( PropertyFunction<String> property, String regexp )
- {
- this.property = property;
- this.value = regexp;
- }
-
- public MatchesSpecification( PropertyFunction<String> property, Variable variable )
- {
- this.property = property;
- this.value = variable;
- }
-
- public PropertyFunction<String> property()
- {
- return property;
- }
-
- public Object value()
- {
- return value;
- }
-
- public String regexp()
- {
- return ( String ) value;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- Property<String> prop = property.apply( item );
-
- if( prop == null )
- {
- return false;
- }
-
- String val = prop.get();
-
- if( val == null )
- {
- return false;
- }
-
- return val.matches( ( String ) value );
- }
-
- @Override
- public String toString()
- {
- return new StringBuilder()
- .append( "( " )
- .append( property )
- .append( " matches " )
- .append( "\"" )
- .append( value )
- .append( "\"" )
- .append( " )" )
- .toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNamePredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNamePredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNamePredicate.java
new file mode 100644
index 0000000..128735a
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNamePredicate.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2012 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import org.apache.zest.api.association.NamedAssociation;
+import org.apache.zest.api.composite.Composite;
+
+/**
+ * NamedAssociation Contains Specification.
+ */
+public class NamedAssociationContainsNamePredicate<T>
+ extends ExpressionPredicate
+{
+ private final NamedAssociationFunction<T> namedAssociationFunction;
+ private final String name;
+
+ public NamedAssociationContainsNamePredicate( NamedAssociationFunction<T> namedAssociationFunction, String name )
+ {
+ this.namedAssociationFunction = namedAssociationFunction;
+ this.name = name;
+ }
+
+ public NamedAssociationFunction<T> namedAssociation()
+ {
+ return namedAssociationFunction;
+ }
+
+ public String name()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ NamedAssociation<T> collection = namedAssociationFunction.apply( item );
+ if( collection == null )
+ {
+ return false;
+ }
+ return collection.containsName( name );
+ }
+
+ @Override
+ public String toString()
+ {
+ return namedAssociationFunction + " contains name:" + name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java
deleted file mode 100644
index fdcde0b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2011-2012 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * NamedAssociation Contains Specification.
- */
-public class NamedAssociationContainsNameSpecification<T>
- extends ExpressionSpecification
-{
- private final NamedAssociationFunction<T> namedAssociationFunction;
- private final String name;
-
- public NamedAssociationContainsNameSpecification( NamedAssociationFunction<T> namedAssociationFunction, String name )
- {
- this.namedAssociationFunction = namedAssociationFunction;
- this.name = name;
- }
-
- public NamedAssociationFunction<T> namedAssociation()
- {
- return namedAssociationFunction;
- }
-
- public String name()
- {
- return name;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- NamedAssociation<T> collection = namedAssociationFunction.apply( item );
- if( collection == null )
- {
- return false;
- }
- return collection.containsName( name );
- }
-
- @Override
- public String toString()
- {
- return namedAssociationFunction + " contains name:" + name;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsPredicate.java
new file mode 100644
index 0000000..c6b18b5
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsPredicate.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2012 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import org.apache.zest.api.association.NamedAssociation;
+import org.apache.zest.api.composite.Composite;
+
+/**
+ * NamedAssociation Contains Specification.
+ */
+public class NamedAssociationContainsPredicate<T>
+ extends ExpressionPredicate
+{
+ private final NamedAssociationFunction<T> namedAssociationFunction;
+ private final T value;
+
+ public NamedAssociationContainsPredicate( NamedAssociationFunction<T> namedAssociationFunction, T value )
+ {
+ this.namedAssociationFunction = namedAssociationFunction;
+ this.value = value;
+ }
+
+ public NamedAssociationFunction<T> namedAssociation()
+ {
+ return namedAssociationFunction;
+ }
+
+ public T value()
+ {
+ return value;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ NamedAssociation<T> collection = namedAssociationFunction.apply( item );
+ if( collection == null )
+ {
+ return false;
+ }
+ return collection.nameOf( value ) != null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return namedAssociationFunction + " contains:" + value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java
deleted file mode 100644
index 9838951..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2011-2012 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * NamedAssociation Contains Specification.
- */
-public class NamedAssociationContainsSpecification<T>
- extends ExpressionSpecification
-{
- private final NamedAssociationFunction<T> namedAssociationFunction;
- private final T value;
-
- public NamedAssociationContainsSpecification( NamedAssociationFunction<T> namedAssociationFunction, T value )
- {
- this.namedAssociationFunction = namedAssociationFunction;
- this.value = value;
- }
-
- public NamedAssociationFunction<T> namedAssociation()
- {
- return namedAssociationFunction;
- }
-
- public T value()
- {
- return value;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- NamedAssociation<T> collection = namedAssociationFunction.apply( item );
- if( collection == null )
- {
- return false;
- }
- return collection.nameOf( value ) != null;
- }
-
- @Override
- public String toString()
- {
- return namedAssociationFunction + " contains:" + value;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NePredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NePredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NePredicate.java
new file mode 100644
index 0000000..8c67e0d
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/NePredicate.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+/**
+ * Not equals Specification.
+ */
+public class NePredicate<T>
+ extends ComparisonPredicate<T>
+{
+ public NePredicate( PropertyFunction<T> property, T value )
+ {
+ super( property, value );
+ }
+
+ @Override
+ protected boolean compare( T value )
+ {
+ return !value.equals( this.value );
+ }
+
+ @Override
+ public String toString()
+ {
+ return property.toString() + "!=" + value.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java
deleted file mode 100644
index 42b26c7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Not equals Specification.
- */
-public class NeSpecification<T>
- extends ComparisonSpecification<T>
-{
- public NeSpecification( PropertyFunction<T> property, T value )
- {
- super( property, value );
- }
-
- @Override
- protected boolean compare( T value )
- {
- return !value.equals( this.value );
- }
-
- @Override
- public String toString()
- {
- return property.toString() + "!=" + value.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java
deleted file mode 100644
index 046db37..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-/**
- * NOT Specification.
- */
-public class NotSpecification implements Specification<Composite>
-{
- private Specification<Composite> operand;
-
- public NotSpecification( Specification<Composite> operand )
- {
- this.operand = operand;
- }
-
- public Specification<Composite> operand()
- {
- return operand;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- return Specifications.not( operand ).satisfiedBy( item );
- }
-
- @Override
- public String toString()
- {
- return "!" + operand.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/Notpredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/Notpredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/Notpredicate.java
new file mode 100644
index 0000000..252488f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/Notpredicate.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import java.util.function.Predicate;
+import org.apache.zest.api.composite.Composite;
+import org.apache.zest.functional.Specifications;
+
+/**
+ * NOT Specification.
+ */
+public class Notpredicate implements Predicate<Composite>
+{
+ private Predicate<Composite> operand;
+
+ public Notpredicate( Predicate<Composite> operand )
+ {
+ this.operand = operand;
+ }
+
+ public Predicate<Composite> operand()
+ {
+ return operand;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ return Specifications.not( operand ).test( item );
+ }
+
+ @Override
+ public String toString()
+ {
+ return "!" + operand.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/OrPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/OrPredicate.java
new file mode 100644
index 0000000..27c91e9
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/OrPredicate.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import java.util.function.Predicate;
+import org.apache.zest.api.composite.Composite;
+import org.apache.zest.functional.Specifications;
+
+/**
+ * OR Specification.
+ */
+public class OrPredicate
+ extends BinaryPredicate
+{
+
+ public OrPredicate( Iterable<Predicate<Composite>> operands )
+ {
+ super( operands );
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ return Specifications.or( operands ).test( item );
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder( "(" );
+ String or = "";
+ for( Predicate<Composite> operand : operands )
+ {
+ sb.append( or ).append( operand );
+ or = " or ";
+ }
+ return sb.append( ")" ).toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java
deleted file mode 100644
index 1daa1ad..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-/**
- * OR Specification.
- */
-public class OrSpecification
- extends BinarySpecification
-{
-
- public OrSpecification( Iterable<Specification<Composite>> operands )
- {
- super( operands );
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- return Specifications.or( operands ).satisfiedBy( item );
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder( "(" );
- String or = "";
- for( Specification<Composite> operand : operands )
- {
- sb.append( or ).append( operand );
- or = " or ";
- }
- return sb.append( ")" ).toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullPredicate.java
new file mode 100644
index 0000000..9c9f437
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullPredicate.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import org.apache.zest.api.composite.Composite;
+import org.apache.zest.api.property.Property;
+
+/**
+ * Property not null Specification.
+ */
+public class PropertyNotNullPredicate<T>
+ extends ExpressionPredicate
+{
+ private PropertyFunction<T> property;
+
+ public PropertyNotNullPredicate( PropertyFunction<T> property )
+ {
+ this.property = property;
+ }
+
+ public PropertyFunction<T> property()
+ {
+ return property;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ Property<T> prop = property.apply( item );
+
+ if( prop == null )
+ {
+ return false;
+ }
+
+ return prop.get() != null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return property.toString() + "is not null";
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java
deleted file mode 100644
index 3519d87..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Property not null Specification.
- */
-public class PropertyNotNullSpecification<T>
- extends ExpressionSpecification
-{
- private PropertyFunction<T> property;
-
- public PropertyNotNullSpecification( PropertyFunction<T> property )
- {
- this.property = property;
- }
-
- public PropertyFunction<T> property()
- {
- return property;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- Property<T> prop = property.apply( item );
-
- if( prop == null )
- {
- return false;
- }
-
- return prop.get() != null;
- }
-
- @Override
- public String toString()
- {
- return property.toString() + "is not null";
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullPredicate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullPredicate.java
new file mode 100644
index 0000000..123bb81
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullPredicate.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.zest.api.query.grammar;
+
+import org.apache.zest.api.composite.Composite;
+import org.apache.zest.api.property.Property;
+
+/**
+ * Property null Specification.
+ */
+public class PropertyNullPredicate<T>
+ extends ExpressionPredicate
+{
+ private PropertyFunction<T> property;
+
+ public PropertyNullPredicate( PropertyFunction<T> property )
+ {
+ this.property = property;
+ }
+
+ public PropertyFunction<T> property()
+ {
+ return property;
+ }
+
+ @Override
+ public boolean test( Composite item )
+ {
+ Property<T> prop = property.apply( item );
+
+ if( prop == null )
+ {
+ return true;
+ }
+
+ return prop.get() == null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return property.toString() + "is null";
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java
deleted file mode 100644
index 7b62f13..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Property null Specification.
- */
-public class PropertyNullSpecification<T>
- extends ExpressionSpecification
-{
- private PropertyFunction<T> property;
-
- public PropertyNullSpecification( PropertyFunction<T> property )
- {
- this.property = property;
- }
-
- public PropertyFunction<T> property()
- {
- return property;
- }
-
- @Override
- public boolean satisfiedBy( Composite item )
- {
- Property<T> prop = property.apply( item );
-
- if( prop == null )
- {
- return true;
- }
-
- return prop.get() == null;
- }
-
- @Override
- public String toString()
- {
- return property.toString() + "is null";
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
index a0ce311..02c0a84 100644
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
+++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
@@ -18,17 +18,17 @@
*/
package org.apache.zest.api.query.grammar;
+import java.util.function.Predicate;
import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
/**
* This should be used when doing native queries, such as SQL, SPARQL or similar. EntityFinders can choose
* what type of query languages they can understand by checking the language property of a QuerySpecification
*/
public class QuerySpecification
- implements Specification<Composite>
+ implements Predicate<Composite>
{
- public static boolean isQueryLanguage( String language, Specification<Composite> specification )
+ public static boolean isQueryLanguage( String language, Predicate<Composite> specification )
{
if( !( specification instanceof QuerySpecification ) )
{
@@ -58,7 +58,7 @@ public class QuerySpecification
}
@Override
- public boolean satisfiedBy( Composite item )
+ public boolean test( Composite item )
{
return false;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java b/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
index c1ced8c..515e8e4 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
@@ -16,6 +16,7 @@ package org.apache.zest.api.service.importer;
import java.util.ArrayList;
import java.util.List;
+import java.util.function.Predicate;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.service.Availability;
import org.apache.zest.api.service.ImportedServiceDescriptor;
@@ -25,7 +26,6 @@ import org.apache.zest.api.service.ServiceImporterException;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.service.qualifier.ServiceQualifier;
import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
/**
* If several services are available with a given type, and you want to constrain
@@ -47,13 +47,13 @@ public final class ServiceSelectorImporter<T>
public T importService( ImportedServiceDescriptor serviceDescriptor )
throws ServiceImporterException
{
- Specification<ServiceReference<?>> selector = serviceDescriptor.metaInfo( Specification.class );
+ Predicate<ServiceReference<?>> selector = serviceDescriptor.metaInfo( Predicate.class );
Class serviceType = Iterables.first( serviceDescriptor.types() );
Iterable<ServiceReference<T>> services = locator.findServices( serviceType );
List<ServiceReference<T>> filteredServices = new ArrayList<>();
for( ServiceReference<T> service : services )
{
- Specification selector1 = service.metaInfo( Specification.class );
+ Predicate selector1 = service.metaInfo( Predicate.class );
if( selector1 != null && selector1 == selector )
{
continue;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
index c961eb9..a179496 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
@@ -16,8 +16,8 @@ package org.apache.zest.api.service.qualifier;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* Filter services based on whether they are active or not.
@@ -43,7 +43,7 @@ public @interface Active
implements AnnotationQualifier<Active>
{
@Override
- public <T> Specification<ServiceReference<?>> qualifier( Active active )
+ public <T> Predicate<ServiceReference<?>> qualifier( Active active )
{
return ServiceQualifier.whereActive();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
index 38e45c5..49cb6af 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
@@ -15,13 +15,13 @@
package org.apache.zest.api.service.qualifier;
import java.lang.annotation.Annotation;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* Constructs a Specification for a given qualifier annotation
*/
public interface AnnotationQualifier<QUALIFIER extends Annotation>
{
- public <T> Specification<ServiceReference<?>> qualifier( QUALIFIER qualifier );
+ public <T> Predicate<ServiceReference<?>> qualifier( QUALIFIER qualifier );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
index 6638061..f0fac8e 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
@@ -16,8 +16,8 @@ package org.apache.zest.api.service.qualifier;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* Filter services based on whether they are available or not.
@@ -41,7 +41,7 @@ public @interface Available
implements AnnotationQualifier<Available>
{
@Override
- public <T> Specification<ServiceReference<?>> qualifier( Available active )
+ public <T> Predicate<ServiceReference<?>> qualifier( Available active )
{
return ServiceQualifier.whereAvailable();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
index 887e5a7..c5861bd 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
@@ -16,8 +16,8 @@ package org.apache.zest.api.service.qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* Filter services based on Meta Info being declared on the Service.
@@ -68,13 +68,13 @@ public @interface HasMetaInfo
implements AnnotationQualifier<HasMetaInfo>
{
@Override
- public <T> Specification<ServiceReference<?>> qualifier( final HasMetaInfo hasMetaInfo )
+ public <T> Predicate<ServiceReference<?>> qualifier( final HasMetaInfo hasMetaInfo )
{
- return new Specification<ServiceReference<?>>()
+ return new Predicate<ServiceReference<?>>()
{
@Override
@SuppressWarnings( {"raw", "unchecked"} )
- public boolean satisfiedBy( ServiceReference<?> service )
+ public boolean test( ServiceReference<?> service )
{
for( Class metaInfoType : hasMetaInfo.value() )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
index 6f18f56..f816f8d 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
@@ -16,8 +16,8 @@ package org.apache.zest.api.service.qualifier;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* Filter services based on identity. Identity can be set during assembly, like so:
@@ -45,7 +45,7 @@ public @interface IdentifiedBy
implements AnnotationQualifier<IdentifiedBy>
{
@Override
- public <T> Specification<ServiceReference<?>> qualifier( IdentifiedBy identifiedBy )
+ public <T> Predicate<ServiceReference<?>> qualifier( IdentifiedBy identifiedBy )
{
return ServiceQualifier.withId( identifiedBy.value() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
index 3c79477..6213589 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
@@ -14,8 +14,8 @@
package org.apache.zest.api.service.qualifier;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* This class helps you select a particular service
@@ -42,13 +42,13 @@ import org.apache.zest.functional.Specification;
*/
public abstract class ServiceQualifier
{
- public static <T> T firstService( Specification<ServiceReference<?>> qualifier,
+ public static <T> T firstService( Predicate<ServiceReference<?>> qualifier,
Iterable<ServiceReference<T>> services
)
{
for( ServiceReference<T> service : services )
{
- if( qualifier.satisfiedBy( service ) )
+ if( qualifier.test( service ) )
{
return service.get();
}
@@ -56,24 +56,24 @@ public abstract class ServiceQualifier
return null;
}
- public static Specification<ServiceReference<?>> withId( final String anId )
+ public static Predicate<ServiceReference<?>> withId( final String anId )
{
- return new Specification<ServiceReference<?>>()
+ return new Predicate<ServiceReference<?>>()
{
@Override
- public boolean satisfiedBy( ServiceReference<?> service )
+ public boolean test( ServiceReference<?> service )
{
return service.identity().equals( anId );
}
};
}
- public static Specification<ServiceReference<?>> whereMetaInfoIs( final Object metaInfo )
+ public static Predicate<ServiceReference<?>> whereMetaInfoIs( final Object metaInfo )
{
- return new Specification<ServiceReference<?>>()
+ return new Predicate<ServiceReference<?>>()
{
@Override
- public boolean satisfiedBy( ServiceReference<?> service )
+ public boolean test( ServiceReference<?> service )
{
Object metaObject = service.metaInfo( metaInfo.getClass() );
return metaObject != null && metaInfo.equals( metaObject );
@@ -81,36 +81,36 @@ public abstract class ServiceQualifier
};
}
- public static Specification<ServiceReference<?>> whereActive()
+ public static Predicate<ServiceReference<?>> whereActive()
{
- return new Specification<ServiceReference<?>>()
+ return new Predicate<ServiceReference<?>>()
{
@Override
- public boolean satisfiedBy( ServiceReference<?> service )
+ public boolean test( ServiceReference<?> service )
{
return service.isActive();
}
};
}
- public static Specification<ServiceReference<?>> whereAvailable()
+ public static Predicate<ServiceReference<?>> whereAvailable()
{
- return new Specification<ServiceReference<?>>()
+ return new Predicate<ServiceReference<?>>()
{
@Override
- public boolean satisfiedBy( ServiceReference<?> service )
+ public boolean test( ServiceReference<?> service )
{
return service.isAvailable();
}
};
}
- public static Specification<ServiceReference<?>> withTags( final String... tags )
+ public static Predicate<ServiceReference<?>> withTags( final String... tags )
{
- return new Specification<ServiceReference<?>>()
+ return new Predicate<ServiceReference<?>>()
{
@Override
- public boolean satisfiedBy( ServiceReference<?> service )
+ public boolean test( ServiceReference<?> service )
{
ServiceTags serviceTags = service.metaInfo( ServiceTags.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
index e2f9b2d..5440a77 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
@@ -16,8 +16,8 @@ package org.apache.zest.api.service.qualifier;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.function.Predicate;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
/**
* Filter services based on tags. Tags can be set using the ServiceTags meta-info, like so:
@@ -46,7 +46,7 @@ public @interface Tagged
implements AnnotationQualifier<Tagged>
{
@Override
- public Specification<ServiceReference<?>> qualifier( Tagged tagged )
+ public Predicate<ServiceReference<?>> qualifier( Tagged tagged )
{
return ServiceQualifier.withTags( tagged.value() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java b/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
index 328dcf4..03035a6 100644
--- a/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
+++ b/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
@@ -16,13 +16,13 @@
package org.apache.zest.api.type;
-import org.apache.zest.functional.Specification;
+import java.util.function.Predicate;
/**
* Match Type Specification for HasTypes.
*/
public class MatchTypeSpecification
- implements Specification<HasTypes>
+ implements Predicate<HasTypes>
{
private final Class<?> matchType;
@@ -32,7 +32,7 @@ public class MatchTypeSpecification
}
@Override
- public boolean satisfiedBy( HasTypes item )
+ public boolean test( HasTypes item )
{
for( Class<?> type : item.types() )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Annotations.java b/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
index da2e929..a144b61 100644
--- a/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
+++ b/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
@@ -19,8 +19,8 @@ import java.lang.reflect.AccessibleObject;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
import java.util.function.Function;
+import java.util.function.Predicate;
import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
import static org.apache.zest.api.util.Classes.interfacesOf;
import static org.apache.zest.api.util.Classes.typeOf;
@@ -43,12 +43,12 @@ public final class Annotations
}
} );
- public static Specification<AnnotatedElement> hasAnnotation( final Class<? extends Annotation> annotationType )
+ public static Predicate<AnnotatedElement> hasAnnotation( final Class<? extends Annotation> annotationType )
{
- return new Specification<AnnotatedElement>()
+ return new Predicate<AnnotatedElement>()
{
@Override
- public boolean satisfiedBy( AnnotatedElement element )
+ public boolean test( AnnotatedElement element )
{
return element.getAnnotation( annotationType ) != null;
}
@@ -67,12 +67,12 @@ public final class Annotations
};
}
- public static Specification<Annotation> isType( final Class<? extends Annotation> annotationType )
+ public static Predicate<Annotation> isType( final Class<? extends Annotation> annotationType )
{
- return new Specification<Annotation>()
+ return new Predicate<Annotation>()
{
@Override
- public boolean satisfiedBy( Annotation annotation )
+ public boolean test( Annotation annotation )
{
return annotation.annotationType().equals( annotationType );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/util/Classes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Classes.java b/core/api/src/main/java/org/apache/zest/api/util/Classes.java
index 92a5e86..b965121 100644
--- a/core/api/src/main/java/org/apache/zest/api/util/Classes.java
+++ b/core/api/src/main/java/org/apache/zest/api/util/Classes.java
@@ -31,9 +31,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
+import java.util.function.Predicate;
import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
import static org.apache.zest.functional.Iterables.cast;
import static org.apache.zest.functional.Iterables.empty;
@@ -272,13 +272,13 @@ public final class Classes
return WRAPPER_CLASS.apply( type );
}
- public static Specification<Class<?>> isAssignableFrom( final Class clazz )
+ public static Predicate<Class<?>> isAssignableFrom( final Class clazz )
{
- return new Specification<Class<?>>()
+ return new Predicate<Class<?>>()
{
@Override
@SuppressWarnings( "unchecked" )
- public boolean satisfiedBy( Class<?> item )
+ public boolean test( Class<?> item )
{
return clazz.isAssignableFrom( item );
}
@@ -286,24 +286,24 @@ public final class Classes
}
@SuppressWarnings( "raw" )
- public static Specification<Object> instanceOf( final Class clazz )
+ public static Predicate<Object> instanceOf( final Class clazz )
{
- return new Specification<Object>()
+ return new Predicate<Object>()
{
@Override
- public boolean satisfiedBy( Object item )
+ public boolean test( Object item )
{
return clazz.isInstance( item );
}
};
}
- public static Specification<Class<?>> hasModifier( final int classModifier )
+ public static Predicate<Class<?>> hasModifier( final int classModifier )
{
- return new Specification<Class<?>>()
+ return new Predicate<Class<?>>()
{
@Override
- public boolean satisfiedBy( Class<?> item )
+ public boolean test( Class<?> item )
{
return ( item.getModifiers() & classModifier ) != 0;
}
@@ -429,12 +429,12 @@ public final class Classes
return result;
}
- public static Specification<Member> memberNamed( final String name )
+ public static Predicate<Member> memberNamed( final String name )
{
- return new Specification<Member>()
+ return new Predicate<Member>()
{
@Override
- public boolean satisfiedBy( Member item )
+ public boolean test( Member item )
{
return item.getName().equals( name );
}
@@ -595,17 +595,17 @@ public final class Classes
return uriPart.replace( '-', '$' );
}
- public static Specification<ModelDescriptor> modelTypeSpecification( final String className )
+ public static Predicate<ModelDescriptor> modelTypeSpecification( final String className )
{
- return new Specification<ModelDescriptor>()
+ return new Predicate<ModelDescriptor>()
{
@Override
- public boolean satisfiedBy( ModelDescriptor item )
+ public boolean test( ModelDescriptor item )
{
- return matchesAny( new Specification<String>()
+ return matchesAny( new Predicate<String>()
{
@Override
- public boolean satisfiedBy( String item )
+ public boolean test( String item )
{
return item.equals( className );
}
@@ -622,17 +622,17 @@ public final class Classes
}
@SuppressWarnings( "raw" )
- public static Specification<ModelDescriptor> exactTypeSpecification( final Class type )
+ public static Predicate<ModelDescriptor> exactTypeSpecification( final Class type )
{
- return new Specification<ModelDescriptor>()
+ return new Predicate<ModelDescriptor>()
{
@Override
- public boolean satisfiedBy( ModelDescriptor item )
+ public boolean test( ModelDescriptor item )
{
- return matchesAny( new Specification<Class<?>>()
+ return matchesAny( new Predicate<Class<?>>()
{
@Override
- public boolean satisfiedBy( Class<?> item )
+ public boolean test( Class<?> item )
{
return item.equals( type );
}
@@ -642,18 +642,18 @@ public final class Classes
}
@SuppressWarnings( "raw" )
- public static Specification<ModelDescriptor> assignableTypeSpecification( final Class type )
+ public static Predicate<ModelDescriptor> assignableTypeSpecification( final Class type )
{
- return new Specification<ModelDescriptor>()
+ return new Predicate<ModelDescriptor>()
{
@Override
- public boolean satisfiedBy( ModelDescriptor item )
+ public boolean test( ModelDescriptor item )
{
- return matchesAny( new Specification<Class<?>>()
+ return matchesAny( new Predicate<Class<?>>()
{
@Override
@SuppressWarnings( "unchecked" )
- public boolean satisfiedBy( Class<?> itemType )
+ public boolean test( Class<?> itemType )
{
return !type.equals( itemType ) && type.isAssignableFrom( itemType );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/main/java/org/apache/zest/api/util/Methods.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Methods.java b/core/api/src/main/java/org/apache/zest/api/util/Methods.java
index c091597..98095b7 100644
--- a/core/api/src/main/java/org/apache/zest/api/util/Methods.java
+++ b/core/api/src/main/java/org/apache/zest/api/util/Methods.java
@@ -21,7 +21,7 @@ package org.apache.zest.api.util;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.function.Function;
-import org.apache.zest.functional.Specification;
+import java.util.function.Predicate;
import static org.apache.zest.functional.Iterables.iterable;
@@ -30,10 +30,10 @@ import static org.apache.zest.functional.Iterables.iterable;
*/
public class Methods
{
- public static final Specification<Type> HAS_METHODS = new Specification<Type>()
+ public static final Predicate<Type> HAS_METHODS = new Predicate<Type>()
{
@Override
- public boolean satisfiedBy( Type item )
+ public boolean test( Type item )
{
return Classes.RAW_CLASS.apply( item ).getDeclaredMethods().length > 0;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java b/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
index 2f4301a..0f917d6 100644
--- a/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.api;
+import java.util.function.Predicate;
import org.junit.Assert;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -34,7 +35,6 @@ import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.bootstrap.SingletonAssembler;
import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
import org.apache.zest.test.EntityTestAssembler;
/**
@@ -77,17 +77,17 @@ public class OperatorsTest
QueryBuilder<TestEntity> builder = assembler.module().newQueryBuilder( TestEntity.class );
{
- Specification<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
+ Predicate<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
.foo(), "Bar" );
- Assert.assertTrue( where.satisfiedBy( testEntity ) );
+ Assert.assertTrue( where.test( testEntity ) );
System.out.println( where );
}
{
- Specification<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
+ Predicate<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
.value()
.get()
.bar(), "Xyz" );
- Assert.assertTrue( where.satisfiedBy( testEntity ) );
+ Assert.assertTrue( where.test( testEntity ) );
System.out.println( where );
Assert.assertTrue( builder.where( where ).newQuery( entities ).find().equals( testEntity ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java b/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
index 4b9e79e..4a9321d 100644
--- a/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
@@ -20,9 +20,9 @@ import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.HashSet;
import java.util.Set;
+import java.util.function.Predicate;
import org.junit.Test;
import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
import org.apache.zest.functional.Specifications;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -61,7 +61,7 @@ public class ClassesTest
{
Iterable<Type> types = Iterables.filter( Methods.HAS_METHODS, interfacesOf( C.class ) );
assertThat( "one interface returned", count( types ), equalTo( 1L ) );
- assertThat( "correct interface returned", Iterables.matchesAny( (Specification) Specifications.in( B.class ), Iterables
+ assertThat( "correct interface returned", Iterables.matchesAny( (Predicate) Specifications.in( B.class ), Iterables
.<Class<?>>cast( types ) ), is( true ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
index 69b82e3..a17238b 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
@@ -18,8 +18,8 @@
*/
package org.apache.zest.bootstrap;
+import java.util.function.Predicate;
import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.functional.Specification;
import org.apache.zest.functional.Specifications;
/**
@@ -27,17 +27,17 @@ import org.apache.zest.functional.Specifications;
*/
public class AssemblySpecifications
{
- public static Specification<HasTypes> types( final Class... types )
+ public static Predicate<HasTypes> types( final Class... types )
{
- return new Specification<HasTypes>()
+ return new Predicate<HasTypes>()
{
@Override
- public boolean satisfiedBy( HasTypes item )
+ public boolean test( HasTypes item )
{
for( Class<?> type : item.types() )
{
- if( Specifications.in( types ).satisfiedBy( type ) )
+ if( Specifications.in( types ).test( type ) )
{
return true;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
index 54cacae..44982c7 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
@@ -24,11 +24,11 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.security.CodeSource;
import java.util.function.Function;
+import java.util.function.Predicate;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
import static org.apache.zest.functional.Iterables.filter;
import static org.apache.zest.functional.Iterables.flatten;
@@ -105,10 +105,10 @@ public class ClassScanner
}
}
}
- , filter( new Specification<JarEntry>()
+ , filter( new Predicate<JarEntry>()
{
@Override
- public boolean satisfiedBy( JarEntry jarEntry )
+ public boolean test( JarEntry jarEntry )
{
return jarEntry.getName()
.startsWith( packageName ) && jarEntry.getName()
@@ -129,10 +129,10 @@ public class ClassScanner
else
{
final File path = new File( file, seedClass.getPackage().getName().replace( '.', File.separatorChar ) );
- Iterable<File> files = findFiles( path, new Specification<File>()
+ Iterable<File> files = findFiles( path, new Predicate<File>()
{
@Override
- public boolean satisfiedBy( File file )
+ public boolean test( File file )
{
return file.getName().endsWith( ".class" );
}
@@ -170,21 +170,21 @@ public class ClassScanner
*
* @return regex class name specification
*/
- public static Specification<Class<?>> matches( String regex )
+ public static Predicate<Class<?>> matches( String regex )
{
final Pattern pattern = Pattern.compile( regex );
- return new Specification<Class<?>>()
+ return new Predicate<Class<?>>()
{
@Override
- public boolean satisfiedBy( Class<?> aClass )
+ public boolean test( Class<?> aClass )
{
return pattern.matcher( aClass.getName() ).matches();
}
};
}
- private static Iterable<File> findFiles( File directory, final Specification<File> filter )
+ private static Iterable<File> findFiles( File directory, final Predicate<File> filter )
{
return flatten( filter( filter, iterable( directory.listFiles() ) ),
flattenIterables( map( new Function<File, Iterable<File>>()
@@ -194,10 +194,10 @@ public class ClassScanner
{
return findFiles( file, filter );
}
- }, filter( new Specification<File>()
+ }, filter( new Predicate<File>()
{
@Override
- public boolean satisfiedBy( File file )
+ public boolean test( File file )
{
return file.isDirectory();
}
@@ -205,10 +205,10 @@ public class ClassScanner
}
private static class ValidClass
- implements Specification<Class<?>>
+ implements Predicate<Class<?>>
{
@Override
- public boolean satisfiedBy( Class<?> item )
+ public boolean test( Class<?> item )
{
return ( item.isInterface() || !Modifier.isAbstract( item.getModifiers() ) ) && ( !item.isEnum() && !item.isAnonymousClass() );
}