http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java index 9b320c3..335752a 100644 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java +++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java @@ -19,9 +19,9 @@ package org.apache.zest.bootstrap; +import java.util.function.Predicate; import org.apache.zest.api.activation.Activator; import org.apache.zest.api.structure.Layer; -import org.apache.zest.functional.Specification; /** * Fluid API for declaring a layer in an application. This is obtained by calling {@link ApplicationAssembly#layer(String)}. @@ -69,7 +69,7 @@ public interface LayerAssembly * * @return An EntityDeclaration for the specified EntityComposite types. */ - EntityDeclaration entities( Specification<? super EntityAssembly> specification ); + EntityDeclaration entities( Predicate<? super EntityAssembly> specification ); /** * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can @@ -79,7 +79,7 @@ public interface LayerAssembly * * @return An ServiceDeclaration for the specified ServiceComposite types. */ - ServiceDeclaration services( Specification<? super ServiceAssembly> specification ); + ServiceDeclaration services( Predicate<? super ServiceAssembly> specification ); /** * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can @@ -89,7 +89,7 @@ public interface LayerAssembly * * @return An TransientDeclaration for the specified TransientComposite types. */ - TransientDeclaration transients( Specification<? super TransientAssembly> specification ); + TransientDeclaration transients( Predicate<? super TransientAssembly> specification ); /** * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can @@ -99,7 +99,7 @@ public interface LayerAssembly * * @return An ValueDeclaration for the specified ValueComposite types. */ - ValueDeclaration values( Specification<? super ValueAssembly> specification ); + ValueDeclaration values( Predicate<? super ValueAssembly> specification ); /** * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can @@ -109,7 +109,7 @@ public interface LayerAssembly * * @return An ObjectDeclaration for the specified Object types. */ - ObjectDeclaration objects( Specification<? super ObjectAssembly> specification ); + ObjectDeclaration objects( Predicate<? super ObjectAssembly> specification ); /** * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can @@ -119,5 +119,5 @@ public interface LayerAssembly * * @return An ImportedServiceDeclaration for the specified Imported Service types. */ - ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification ); + ImportedServiceDeclaration importedServices( Predicate<? super ImportedServiceAssembly> specification ); }
http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java index 6bf4437..f99c506 100644 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java +++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java @@ -19,10 +19,10 @@ package org.apache.zest.bootstrap; +import java.util.function.Predicate; import org.apache.zest.api.activation.Activator; import org.apache.zest.api.structure.Module; import org.apache.zest.api.type.HasTypes; -import org.apache.zest.functional.Specification; /** * The ModuleAssembly is used to register any information about * what the module should contain, such as composites, @@ -98,7 +98,7 @@ public interface ModuleAssembly * * @return An TransientDeclaration for the specified TransientComposite types. */ - TransientDeclaration transients( Specification<? super TransientAssembly> specification ); + TransientDeclaration transients( Predicate<? super TransientAssembly> specification ); /** * Declare a list of ValueComposites for this Module. Use the ValueDeclaration that is returned to @@ -118,7 +118,7 @@ public interface ModuleAssembly * * @return An ValueDeclaration for the specified ValueComposite types. */ - ValueDeclaration values( Specification<? super ValueAssembly> specification ); + ValueDeclaration values( Predicate<? super ValueAssembly> specification ); /** * Declare a list of EntityComposites for this Module. Use the EntityDeclaration that is returned to @@ -138,7 +138,7 @@ public interface ModuleAssembly * * @return An EntityDeclaration for the specified EntityComposite types. */ - EntityDeclaration entities( Specification<? super EntityAssembly> specification ); + EntityDeclaration entities( Predicate<? super EntityAssembly> specification ); /** * Declare a list of Configuration Composites for this Module. Use the ConfigurationDeclaration that is returned to @@ -158,7 +158,7 @@ public interface ModuleAssembly * * @return An ConfigurationDeclaration for the specified EntityComposite types. */ - ConfigurationDeclaration configurations( Specification<HasTypes> specification ); + ConfigurationDeclaration configurations( Predicate<HasTypes> specification ); /** @@ -180,7 +180,7 @@ public interface ModuleAssembly * * @return An ObjectDeclaration for the specified Object types. */ - ObjectDeclaration objects( Specification<? super ObjectAssembly> specification ); + ObjectDeclaration objects( Predicate<? super ObjectAssembly> specification ); /** * Create a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to @@ -211,7 +211,7 @@ public interface ModuleAssembly * * @return An ServiceDeclaration for the specified ServiceComposite types. */ - ServiceDeclaration services( Specification<? super ServiceAssembly> specification ); + ServiceDeclaration services( Predicate<? super ServiceAssembly> specification ); /** * Declare a list of imported services for this Module. Use the ImportedServiceDeclaration that is returned to @@ -231,7 +231,7 @@ public interface ModuleAssembly * * @return An ImportedServiceDeclaration for the specified Imported Service types. */ - ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification ); + ImportedServiceDeclaration importedServices( Predicate<? super ImportedServiceAssembly> specification ); <T> MixinDeclaration<T> forMixin( Class<T> mixinType ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java index 6522f57..bd081d0 100644 --- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java +++ b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java @@ -18,6 +18,7 @@ */ package org.apache.zest.bootstrap; +import java.util.function.Predicate; import org.apache.zest.api.activation.ActivationException; import org.apache.zest.api.common.Visibility; import org.apache.zest.api.property.Property; @@ -27,15 +28,14 @@ import org.apache.zest.api.structure.Application; import org.apache.zest.api.structure.ApplicationDescriptor; import org.apache.zest.api.structure.Module; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; public class DocumentationSupport { - public static Specification<ObjectAssembly> hasMyTypeSpecification = new Specification<ObjectAssembly>() + public static Predicate<ObjectAssembly> hasMyTypeSpecification = new Predicate<ObjectAssembly>() { - public boolean satisfiedBy( ObjectAssembly item ) + public boolean test( ObjectAssembly item ) { return Iterables.toList( item.types() ).contains( String.class ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/main/java/org/apache/zest/functional/ForEach.java ---------------------------------------------------------------------- diff --git a/core/functional/src/main/java/org/apache/zest/functional/ForEach.java b/core/functional/src/main/java/org/apache/zest/functional/ForEach.java index e7e815a..23d1619 100644 --- a/core/functional/src/main/java/org/apache/zest/functional/ForEach.java +++ b/core/functional/src/main/java/org/apache/zest/functional/ForEach.java @@ -15,6 +15,7 @@ package org.apache.zest.functional; import java.util.Iterator; import java.util.function.Function; +import java.util.function.Predicate; /** * When using Iterables with map() and filter() the code often reads "in reverse", with the first item last in the code. @@ -47,7 +48,7 @@ public final class ForEach<T> return iterable.iterator(); } - public ForEach<T> filter( Specification<? super T> specification ) + public ForEach<T> filter( Predicate<? super T> specification ) { return new ForEach<>( Iterables.filter( specification, iterable ) ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/main/java/org/apache/zest/functional/Functions.java ---------------------------------------------------------------------- diff --git a/core/functional/src/main/java/org/apache/zest/functional/Functions.java b/core/functional/src/main/java/org/apache/zest/functional/Functions.java index 318c8c0..f5688db 100644 --- a/core/functional/src/main/java/org/apache/zest/functional/Functions.java +++ b/core/functional/src/main/java/org/apache/zest/functional/Functions.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.Map; import java.util.function.BiFunction; import java.util.function.Function; +import java.util.function.Predicate; /** * Utility functions. Combine these with methods in Iterables, for example. See FunctionsTest for usages. @@ -26,14 +27,7 @@ public final class Functions { public static <A, B, C> BiFunction<Function<? super B, C>, Function<A, B>, Function<A, C>> compose() { - return new BiFunction<Function<? super B, C>, Function<A, B>, Function<A, C>>() - { - @Override - public Function<A, C> apply( Function<? super B, C> bcFunction, Function<A, B> abFunction ) - { - return compose( bcFunction, abFunction ); - } - }; + return Functions::compose; } /** @@ -48,64 +42,29 @@ public final class Functions final Function<FROM, MIDDLE> inner ) { - return new Function<FROM, TO>() - { - @Override - public TO apply( FROM from ) - { - return outer.apply( inner.apply( from ) ); - } - }; + return from -> outer.apply( inner.apply( from ) ); } public static <TO, FROM extends TO> Function<FROM, TO> identity() { - return new Function<FROM, TO>() - { - @Override - public TO apply( FROM from ) - { - return from; - } - }; + return from -> from; } public static <FROM, TO> Function<FROM, TO> fromMap( final Map<FROM, TO> map ) { - return new Function<FROM, TO>() - { - @Override - public TO apply( FROM from ) - { - return map.get( from ); - } - }; + return map::get; } public static <T> Function<T, T> withDefault( final T defaultValue ) { - return new Function<T, T>() - { - @Override - public T apply( T from ) - { - if( from == null ) - { - return defaultValue; - } - else - { - return from; - } - } - }; + return from -> from == null ? defaultValue : from; } public static Function<Number, Long> longSum() { return new Function<Number, Long>() { - long sum; + private long sum = 0; @Override public Long apply( Number number ) @@ -120,7 +79,7 @@ public final class Functions { return new Function<Number, Integer>() { - int sum; + private int sum = 0; @Override public Integer apply( Number number ) @@ -142,7 +101,7 @@ public final class Functions * * @return A Function that can count items adhering to a Specification. */ - public static <T> Function<T, Integer> count( final Specification<T> specification ) + public static <T> Function<T, Integer> count( final Predicate<T> specification ) { return new Function<T, Integer>() { @@ -151,7 +110,7 @@ public final class Functions @Override public Integer apply( T item ) { - if( specification.satisfiedBy( item ) ) + if( specification.test( item ) ) { count++; } @@ -171,7 +130,7 @@ public final class Functions * @return A Function that will provide the 'index' where the Specifcation is fulfilled. The Function will * return -1 if the current item doesn't fulfill the Specification. */ - public static <T> Function<T, Integer> indexOf( final Specification<T> specification ) + public static <T> Function<T, Integer> indexOf( final Predicate<T> specification ) { return new Function<T, Integer>() { @@ -181,7 +140,7 @@ public final class Functions @Override public Integer apply( T item ) { - if( index == -1 && specification.satisfiedBy( item ) ) + if( index == -1 && specification.test( item ) ) { index = current; } @@ -218,14 +177,14 @@ public final class Functions * * @return A Function that performs the filter operation when applied to Iterables. */ - public static <T> Function<T, T> filteredMap( final Specification<T> specification, final Function<T, T> function ) + public static <T> Function<T, T> filteredMap( final Predicate<T> specification, final Function<T, T> function ) { return new Function<T, T>() { @Override public T apply( T from ) { - return specification.satisfiedBy( from ) ? function.apply( from ) : from; + return specification.test( from ) ? function.apply( from ) : from; } }; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/main/java/org/apache/zest/functional/Iterables.java ---------------------------------------------------------------------- diff --git a/core/functional/src/main/java/org/apache/zest/functional/Iterables.java b/core/functional/src/main/java/org/apache/zest/functional/Iterables.java index 1b80bcc..bc6f076 100644 --- a/core/functional/src/main/java/org/apache/zest/functional/Iterables.java +++ b/core/functional/src/main/java/org/apache/zest/functional/Iterables.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Set; import java.util.function.Function; +import java.util.function.Predicate; /** * Utility methods for working with Iterables. See test for examples of how to use. @@ -204,9 +205,9 @@ public final class Iterables } @SuppressWarnings( "unchecked" ) - public static <X> Iterable<X> filter( Specification<? /* super X*/> specification, Iterable<X> i ) + public static <X> Iterable<X> filter( Predicate<? /* super X*/> specification, Iterable<X> i ) { - return new FilterIterable<>( i, (Specification<? super X>) specification ); + return new FilterIterable<>( i, (Predicate<? super X>) specification ); } public static <X> X first( Iterable<X> i ) @@ -287,13 +288,13 @@ public final class Iterables return list; } - public static <T> boolean matchesAny( Specification<? super T> specification, Iterable<T> iterable ) + public static <T> boolean matchesAny( Predicate<? super T> specification, Iterable<T> iterable ) { boolean result = false; for( T item : iterable ) { - if( ( (Specification<? super T>) specification ).satisfiedBy( item ) ) + if( ( (Predicate<? super T>) specification ).test( item ) ) { result = true; break; @@ -303,12 +304,12 @@ public final class Iterables return result; } - public static <T> boolean matchesAll( Specification<? super T> specification, Iterable<T> iterable ) + public static <T> boolean matchesAll( Predicate<? super T> specification, Iterable<T> iterable ) { boolean result = true; for( T item : iterable ) { - if( !specification.satisfiedBy( item ) ) + if( !specification.test( item ) ) { result = false; } @@ -717,9 +718,9 @@ public final class Iterables { private final Iterable<T> iterable; - private final Specification<? super T> specification; + private final Predicate<? super T> specification; - private FilterIterable( Iterable<T> iterable, Specification<? super T> specification ) + private FilterIterable( Iterable<T> iterable, Predicate<? super T> specification ) { this.iterable = iterable; this.specification = specification; @@ -736,13 +737,13 @@ public final class Iterables { private final Iterator<T> iterator; - private final Specification<? super T> specification; + private final Predicate<? super T> specification; private T currentValue; boolean finished = false; boolean nextConsumed = true; - private FilterIterator( Iterator<T> iterator, Specification<? super T> specification ) + private FilterIterator( Iterator<T> iterator, Predicate<? super T> specification ) { this.specification = specification; this.iterator = iterator; @@ -754,7 +755,7 @@ public final class Iterables while( !found && iterator.hasNext() ) { T currentValue = iterator.next(); - boolean satisfies = specification.satisfiedBy( currentValue ); + boolean satisfies = specification.test( currentValue ); if( satisfies ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/main/java/org/apache/zest/functional/Specification.java ---------------------------------------------------------------------- diff --git a/core/functional/src/main/java/org/apache/zest/functional/Specification.java b/core/functional/src/main/java/org/apache/zest/functional/Specification.java deleted file mode 100644 index 3ff725d..0000000 --- a/core/functional/src/main/java/org/apache/zest/functional/Specification.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2010, Rickard Ãberg. All Rights Reserved. - * - * 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 implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.zest.functional; - -/** - * Generic specification interface. - * - * @param <T> - */ -// START SNIPPET: specification -public interface Specification<T> -{ -// END SNIPPET: specification - - /** - * Test whether an item matches the given specification - * - * @param item the item to be tested - * - * @return true if the item matches, false otherwise - */ -// START SNIPPET: specification - boolean satisfiedBy( T item ); -} -// END SNIPPET: specification http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/main/java/org/apache/zest/functional/Specifications.java ---------------------------------------------------------------------- diff --git a/core/functional/src/main/java/org/apache/zest/functional/Specifications.java b/core/functional/src/main/java/org/apache/zest/functional/Specifications.java index e81cd48..467f468 100644 --- a/core/functional/src/main/java/org/apache/zest/functional/Specifications.java +++ b/core/functional/src/main/java/org/apache/zest/functional/Specifications.java @@ -14,70 +14,71 @@ package org.apache.zest.functional; import java.util.function.Function; +import java.util.function.Predicate; /** * Common generic specification expressions */ public class Specifications { - public static <T> Specification<T> TRUE() + public static <T> Predicate<T> TRUE() { - return new Specification<T>() + return new Predicate<T>() { @Override - public boolean satisfiedBy( T instance ) + public boolean test( T instance ) { return true; } }; } - public static <T> Specification<T> not( final Specification<T> specification ) + public static <T> Predicate<T> not( final Predicate<T> specification ) { - return new Specification<T>() + return new Predicate<T>() { @Override - public boolean satisfiedBy( T instance ) + public boolean test( T instance ) { - return !specification.satisfiedBy( instance ); + return !specification.test( instance ); } }; } @SafeVarargs - public static <T> AndSpecification<T> and( final Specification<T>... specifications ) + public static <T> AndSpecification<T> and( final Predicate<T>... specifications ) { return and( Iterables.iterable( specifications ) ); } - public static <T> AndSpecification<T> and( final Iterable<Specification<T>> specifications ) + public static <T> AndSpecification<T> and( final Iterable<Predicate<T>> specifications ) { return new AndSpecification<>( specifications ); } @SafeVarargs - public static <T> OrSpecification<T> or( final Specification<T>... specifications ) + public static <T> OrSpecification<T> or( final Predicate<T>... specifications ) { return or( Iterables.iterable( specifications ) ); } - public static <T> OrSpecification<T> or( final Iterable<Specification<T>> specifications ) + public static <T> OrSpecification<T> or( final Iterable<Predicate<T>> specifications ) { return new OrSpecification<>( specifications ); } @SafeVarargs - public static <T> Specification<T> in( final T... allowed ) + public static <T> Predicate<T> in( final T... allowed ) { return in( Iterables.iterable( allowed ) ); } - public static <T> Specification<T> in( final Iterable<T> allowed ) + public static <T> Predicate<T> in( final Iterable<T> allowed ) { - return new Specification<T>() + return new Predicate<T>() { @Override - public boolean satisfiedBy( T item ) + public boolean test( T item ) { for( T allow : allowed ) { @@ -91,28 +92,28 @@ public class Specifications }; } - public static <T> Specification<T> notNull() + public static <T> Predicate<T> notNull() { - return new Specification<T>() + return new Predicate<T>() { @Override - public boolean satisfiedBy( T item ) + public boolean test( T item ) { return item != null; } }; } - public static <FROM, TO> Specification<FROM> translate( final Function<FROM, TO> function, - final Specification<? super TO> specification + public static <FROM, TO> Predicate<FROM> translate( final Function<FROM, TO> function, + final Predicate<? super TO> specification ) { - return new Specification<FROM>() + return new Predicate<FROM>() { @Override - public boolean satisfiedBy( FROM item ) + public boolean test( FROM item ) { - return specification.satisfiedBy( function.apply( item ) ); + return specification.test( function.apply( item ) ); } }; } @@ -121,21 +122,21 @@ public class Specifications * AND Specification. */ public static class AndSpecification<T> - implements Specification<T> + implements Predicate<T> { - private final Iterable<Specification<T>> specifications; + private final Iterable<Predicate<T>> specifications; - private AndSpecification( Iterable<Specification<T>> specifications ) + private AndSpecification( Iterable<Predicate<T>> specifications ) { this.specifications = specifications; } @Override - public boolean satisfiedBy( T instance ) + public boolean test( T instance ) { - for( Specification<T> specification : specifications ) + for( Predicate<T> specification : specifications ) { - if( !specification.satisfiedBy( instance ) ) + if( !specification.test( instance ) ) { return false; } @@ -145,15 +146,15 @@ public class Specifications } @SafeVarargs - public final AndSpecification<T> and( Specification<T>... specifications ) + public final AndSpecification<T> and( Predicate<T>... specifications ) { - Iterable<Specification<T>> iterable = Iterables.iterable( specifications ); - Iterable<Specification<T>> flatten = Iterables.flatten( this.specifications, iterable ); + Iterable<Predicate<T>> iterable = Iterables.iterable( specifications ); + Iterable<Predicate<T>> flatten = Iterables.flatten( this.specifications, iterable ); return Specifications.and( flatten ); } @SafeVarargs - public final OrSpecification<T> or( Specification<T>... specifications ) + public final OrSpecification<T> or( Predicate<T>... specifications ) { return Specifications.or( Iterables.prepend( this, Iterables.iterable( specifications ) ) ); } @@ -163,21 +164,21 @@ public class Specifications * OR Specification. */ public static class OrSpecification<T> - implements Specification<T> + implements Predicate<T> { - private final Iterable<Specification<T>> specifications; + private final Iterable<Predicate<T>> specifications; - private OrSpecification( Iterable<Specification<T>> specifications ) + private OrSpecification( Iterable<Predicate<T>> specifications ) { this.specifications = specifications; } @Override - public boolean satisfiedBy( T instance ) + public boolean test( T instance ) { - for( Specification<T> specification : specifications ) + for( Predicate<T> specification : specifications ) { - if( specification.satisfiedBy( instance ) ) + if( specification.test( instance ) ) { return true; } @@ -187,16 +188,16 @@ public class Specifications } @SafeVarargs - public final AndSpecification<T> and( Specification<T>... specifications ) + public final AndSpecification<T> and( Predicate<T>... specifications ) { return Specifications.and( Iterables.prepend( this, Iterables.iterable( specifications ) ) ); } @SafeVarargs - public final OrSpecification<T> or( Specification<T>... specifications ) + public final OrSpecification<T> or( Predicate<T>... specifications ) { - Iterable<Specification<T>> iterable = Iterables.iterable( specifications ); - Iterable<Specification<T>> flatten = Iterables.flatten( this.specifications, iterable ); + Iterable<Predicate<T>> iterable = Iterables.iterable( specifications ); + Iterable<Predicate<T>> flatten = Iterables.flatten( this.specifications, iterable ); return Specifications.or( flatten ); } } @@ -204,5 +205,4 @@ public class Specifications private Specifications() { } - } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java ---------------------------------------------------------------------- diff --git a/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java b/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java index fa082fe..7deb6ae 100644 --- a/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java +++ b/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java @@ -16,6 +16,7 @@ package org.apache.zest.functional; +import java.util.function.Predicate; import org.junit.Test; import static org.junit.Assert.assertFalse; @@ -27,17 +28,17 @@ public class IntegerRangeSpecificationTest @Test public void test1() { - Specification<Integer> spec = new IntegerRangeSpecification( 10, 12 ); - assertTrue( spec.satisfiedBy( 10 ) ); - assertTrue( spec.satisfiedBy( 11 ) ); - assertTrue( spec.satisfiedBy( 12 ) ); - assertFalse( spec.satisfiedBy( 9 ) ); - assertFalse( spec.satisfiedBy( 13 ) ); + Predicate<Integer> spec = new IntegerRangeSpecification( 10, 12 ); + assertTrue( spec.test( 10 ) ); + assertTrue( spec.test( 11 ) ); + assertTrue( spec.test( 12 ) ); + assertFalse( spec.test( 9 ) ); + assertFalse( spec.test( 13 ) ); } // START SNIPPET: specification public static class IntegerRangeSpecification - implements Specification<Integer> + implements Predicate<Integer> { private int lower; @@ -50,7 +51,7 @@ public class IntegerRangeSpecificationTest } @Override - public boolean satisfiedBy( Integer item ) + public boolean test( Integer item ) { return item >= lower && item <= higher; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java ---------------------------------------------------------------------- diff --git a/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java b/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java index 3171fbc..7ff5bab 100644 --- a/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java +++ b/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java @@ -19,6 +19,7 @@ import java.util.Comparator; import java.util.Enumeration; import java.util.List; import java.util.function.Function; +import java.util.function.Predicate; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -249,11 +250,11 @@ public class IterablesTest { final int[] count = new int[ 1 ]; - Iterable<String> b = Iterables.cache( Iterables.filter( Specifications.and( new Specification<String>() + Iterable<String> b = Iterables.cache( Iterables.filter( Specifications.and( new Predicate<String>() { @Override - public boolean satisfiedBy( String item ) + public boolean test( String item ) { count[ 0] = count[ 0] + 1; return true; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java ---------------------------------------------------------------------- diff --git a/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java b/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java index 7767ffe..f5ce2c0 100644 --- a/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java +++ b/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java @@ -15,6 +15,7 @@ package org.apache.zest.functional; import java.util.function.Function; +import java.util.function.Predicate; import org.junit.Assert; import org.junit.Test; @@ -28,45 +29,44 @@ public class SpecificationsTest @Test public void testTRUE() { - Assert.assertThat( Specifications.<Object>TRUE().satisfiedBy( new Object() ), equalTo( true ) ); + Assert.assertThat( Specifications.<Object>TRUE().test( new Object() ), equalTo( true ) ); } @Test public void testNot() { - Assert.assertThat( Specifications.not( Specifications.<Object>TRUE() ) - .satisfiedBy( new Object() ), equalTo( false ) ); + Assert.assertThat( Specifications.not( Specifications.<Object>TRUE() ).test( new Object() ), equalTo( false ) ); } @Test public void testAnd() { - Specification<Object> trueSpec = Specifications.<Object>TRUE(); - Specification<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() ); + Predicate<Object> trueSpec = Specifications.<Object>TRUE(); + Predicate<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() ); - Assert.assertThat( Specifications.and( falseSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) ); - Assert.assertThat( Specifications.and( trueSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) ); - Assert.assertThat( Specifications.and( falseSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( false ) ); - Assert.assertThat( Specifications.and( trueSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) ); + Assert.assertThat( Specifications.and( falseSpec, falseSpec ).test( new Object() ), equalTo( false ) ); + Assert.assertThat( Specifications.and( trueSpec, falseSpec ).test( new Object() ), equalTo( false ) ); + Assert.assertThat( Specifications.and( falseSpec, trueSpec ).test( new Object() ), equalTo( false ) ); + Assert.assertThat( Specifications.and( trueSpec, trueSpec ).test( new Object() ), equalTo( true ) ); } @Test public void testOr() { - Specification<Object> trueSpec = Specifications.<Object>TRUE(); - Specification<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() ); + Predicate<Object> trueSpec = Specifications.<Object>TRUE(); + Predicate<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() ); - Assert.assertThat( Specifications.or( falseSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) ); - Assert.assertThat( Specifications.or( trueSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( true ) ); - Assert.assertThat( Specifications.or( falseSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) ); - Assert.assertThat( Specifications.or( trueSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) ); + Assert.assertThat( Specifications.or( falseSpec, falseSpec ).test( new Object() ), equalTo( false ) ); + Assert.assertThat( Specifications.or( trueSpec, falseSpec ).test( new Object() ), equalTo( true ) ); + Assert.assertThat( Specifications.or( falseSpec, trueSpec ).test( new Object() ), equalTo( true ) ); + Assert.assertThat( Specifications.or( trueSpec, trueSpec ).test( new Object() ), equalTo( true ) ); } @Test public void testIn() { - Assert.assertThat( Specifications.in( "1", "2", "3" ).satisfiedBy( "2" ), equalTo( true ) ); - Assert.assertThat( Specifications.in( "1", "2", "3" ).satisfiedBy( "4" ), equalTo( false ) ); + Assert.assertThat( Specifications.in( "1", "2", "3" ).test( "2" ), equalTo( true ) ); + Assert.assertThat( Specifications.in( "1", "2", "3" ).test( "4" ), equalTo( false ) ); } @Test @@ -81,6 +81,6 @@ public class SpecificationsTest } }; - Assert.assertTrue( Specifications.translate( stringifier, Specifications.in( "3" ) ).satisfiedBy( 3L ) ); + Assert.assertTrue( Specifications.translate( stringifier, Specifications.in( "3" ) ).test( 3L ) ); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/io/src/main/java/org/apache/zest/io/Transforms.java ---------------------------------------------------------------------- diff --git a/core/io/src/main/java/org/apache/zest/io/Transforms.java b/core/io/src/main/java/org/apache/zest/io/Transforms.java index db5890f..ac169bd 100644 --- a/core/io/src/main/java/org/apache/zest/io/Transforms.java +++ b/core/io/src/main/java/org/apache/zest/io/Transforms.java @@ -20,8 +20,8 @@ import java.text.MessageFormat; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.function.Function; +import java.util.function.Predicate; import java.util.logging.Logger; -import org.apache.zest.functional.Specification; /** * Utility class for I/O transforms @@ -38,7 +38,7 @@ public class Transforms * * @return And Output encapsulation the filter operation. */ - public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filter( final Specification<? super T> specification, + public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filter( final Predicate<? super T> specification, final Output<T, Receiver2ThrowableType> output ) { @@ -60,7 +60,7 @@ public class Transforms public void receive( T item ) throws ReceiverThrowableType { - if( specification.satisfiedBy( item ) ) + if( specification.test( item ) ) { receiver.receive( item ); } @@ -126,7 +126,7 @@ public class Transforms * * @return An Output instance that encapsulates the operation. */ - public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filteredMap( final Specification<? super T> specification, + public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filteredMap( final Predicate<? super T> specification, final Function<? super T, ? extends T> function, final Output<T, Receiver2ThrowableType> output ) @@ -149,7 +149,7 @@ public class Transforms public void receive( T item ) throws ReceiverThrowableType { - if( specification.satisfiedBy( item ) ) + if( specification.test( item ) ) { receiver.receive( function.apply( item ) ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java index 5ab762f..7f4b83f 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java @@ -20,6 +20,7 @@ package org.apache.zest.runtime.bootstrap; import java.lang.annotation.Annotation; import java.lang.reflect.AccessibleObject; +import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Member; @@ -32,7 +33,10 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.StreamSupport; import org.apache.zest.api.common.MetaInfo; import org.apache.zest.api.common.Optional; import org.apache.zest.api.common.QualifiedName; @@ -58,11 +62,8 @@ import org.apache.zest.api.util.Annotations; import org.apache.zest.api.util.Classes; import org.apache.zest.api.util.Fields; import org.apache.zest.bootstrap.StateDeclarations; -import org.apache.zest.functional.ForEach; import org.apache.zest.functional.HierarchicalVisitorAdapter; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; -import org.apache.zest.functional.Visitor; import org.apache.zest.runtime.composite.AbstractConstraintModel; import org.apache.zest.runtime.composite.CompositeConstraintModel; import org.apache.zest.runtime.composite.CompositeMethodModel; @@ -71,7 +72,7 @@ import org.apache.zest.runtime.composite.ConcernModel; import org.apache.zest.runtime.composite.ConcernsModel; import org.apache.zest.runtime.composite.ConstraintModel; import org.apache.zest.runtime.composite.ConstraintsModel; -import org.apache.zest.runtime.composite.GenericSpecification; +import org.apache.zest.runtime.composite.Genericpredicate; import org.apache.zest.runtime.composite.MixinModel; import org.apache.zest.runtime.composite.MixinsModel; import org.apache.zest.runtime.composite.SideEffectModel; @@ -314,16 +315,16 @@ public abstract class CompositeAssemblyImpl // Check if mixinClass implements the method. If so, check if the mixinClass is generic or if the filter passes. // If a mixinClass is both generic AND non-generic at the same time, then the filter applies to the non-generic // side only. - Specification<Class<?>> appliesToSpec = new Specification<Class<?>>() + Predicate<Class<?>> appliesToSpec = new Predicate<Class<?>>() { @Override - public boolean satisfiedBy( Class<?> item ) + public boolean test( Class<?> item ) { return helper.appliesTo( item, method, types, item ); } }; return first( filter( and( isAssignableFrom( method.getDeclaringClass() ), - or( GenericSpecification.INSTANCE, appliesToSpec ) ), + or( Genericpredicate.INSTANCE, appliesToSpec ) ), mixins ) ); } @@ -331,10 +332,10 @@ public abstract class CompositeAssemblyImpl private Class<?> findGenericImplementation( final Method method, Iterable<Class<?>> mixins ) { // Check if mixinClass is generic and the applies-to filter passes - return first( filter( and( GenericSpecification.INSTANCE, new Specification<Class<?>>() + return first( filter( and( Genericpredicate.INSTANCE, new Predicate<Class<?>>() { @Override - public boolean satisfiedBy( Class<?> item ) + public boolean test( Class<?> item ) { return helper.appliesTo( item, method, types, item ); } @@ -389,19 +390,18 @@ public abstract class CompositeAssemblyImpl if( visited instanceof MixinModel ) { MixinModel model = (MixinModel) visited; - Visitor<Field, RuntimeException> addState = new Visitor<Field, RuntimeException>() + Consumer<Field> addState = new Consumer<Field>() { @Override - public boolean visit( Field visited ) - throws RuntimeException + public void accept( Field field ) { - addStateFor( visited, constraintClasses ); - return true; + addStateFor( field, constraintClasses ); } }; - ForEach.forEach( Fields.FIELDS_OF.apply( model.mixinClass() ) ). - filter( Annotations.hasAnnotation( State.class ) ). - visit( addState ); + Iterable<Field> fields = Fields.FIELDS_OF.apply( model.mixinClass() ); + StreamSupport.stream( fields.spliterator(), true ) + .filter( Annotations.hasAnnotation( State.class ) ) + .forEach( addState ); return false; } return super.visitEnter( visited ); @@ -517,9 +517,10 @@ public abstract class CompositeAssemblyImpl valueType = wrapperClass( valueType ); List<AbstractConstraintModel> constraintModels = new ArrayList<>(); + Iterable<Annotation> filter = filter( translate( type(), hasAnnotation( ConstraintDeclaration.class ) ), + constraintAnnotations ); nextConstraint: - for( Annotation constraintAnnotation : filter( translate( type(), hasAnnotation( ConstraintDeclaration.class ) ), - constraintAnnotations ) ) + for( Annotation constraintAnnotation : filter ) { // Check composite declarations first Class<? extends Annotation> annotationType = constraintAnnotation.annotationType(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java index c199bee..d029800 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java @@ -23,6 +23,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.function.Predicate; import org.apache.zest.api.activation.Activator; import org.apache.zest.api.common.MetaInfo; import org.apache.zest.api.common.Visibility; @@ -44,7 +45,6 @@ import org.apache.zest.bootstrap.TransientAssembly; import org.apache.zest.bootstrap.TransientDeclaration; import org.apache.zest.bootstrap.ValueAssembly; import org.apache.zest.bootstrap.ValueDeclaration; -import org.apache.zest.functional.Specification; /** * Assembly of a Layer. From here you can create more ModuleAssemblies for @@ -135,7 +135,7 @@ public final class LayerAssemblyImpl } @Override - public EntityDeclaration entities( Specification<? super EntityAssembly> specification ) + public EntityDeclaration entities( Predicate<? super EntityAssembly> specification ) { final List<EntityDeclaration> declarations = new ArrayList<>(); @@ -209,7 +209,7 @@ public final class LayerAssemblyImpl } @Override - public ServiceDeclaration services( Specification<? super ServiceAssembly> specification ) + public ServiceDeclaration services( Predicate<? super ServiceAssembly> specification ) { final List<ServiceDeclaration> declarations = new ArrayList<>(); @@ -325,7 +325,7 @@ public final class LayerAssemblyImpl } @Override - public TransientDeclaration transients( Specification<? super TransientAssembly> specification ) + public TransientDeclaration transients( Predicate<? super TransientAssembly> specification ) { final List<TransientDeclaration> declarations = new ArrayList<>(); @@ -399,7 +399,7 @@ public final class LayerAssemblyImpl } @Override - public ValueDeclaration values( Specification<? super ValueAssembly> specification ) + public ValueDeclaration values( Predicate<? super ValueAssembly> specification ) { final List<ValueDeclaration> declarations = new ArrayList<>(); @@ -472,7 +472,7 @@ public final class LayerAssemblyImpl } @Override - public ObjectDeclaration objects( Specification<? super ObjectAssembly> specification ) + public ObjectDeclaration objects( Predicate<? super ObjectAssembly> specification ) { final List<ObjectDeclaration> declarations = new ArrayList<>(); @@ -506,7 +506,7 @@ public final class LayerAssemblyImpl } @Override - public ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification ) + public ImportedServiceDeclaration importedServices( Predicate<? super ImportedServiceAssembly> specification ) { final List<ImportedServiceDeclaration> declarations = new ArrayList<>(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java index 673dfe7..6f072de 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java @@ -22,6 +22,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import org.apache.zest.api.activation.Activator; import org.apache.zest.api.common.MetaInfo; import org.apache.zest.api.common.Visibility; @@ -55,7 +56,6 @@ import org.apache.zest.bootstrap.TransientDeclaration; import org.apache.zest.bootstrap.ValueAssembly; import org.apache.zest.bootstrap.ValueDeclaration; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.Specifications; import org.apache.zest.runtime.activation.ActivatorsModel; import org.apache.zest.runtime.composite.TransientModel; @@ -168,12 +168,12 @@ public final class ModuleAssemblyImpl } @Override - public ValueDeclaration values( Specification<? super ValueAssembly> specification ) + public ValueDeclaration values( Predicate<? super ValueAssembly> specification ) { List<ValueAssemblyImpl> assemblies = new ArrayList<>(); for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() ) { - if( specification.satisfiedBy( transientAssembly ) ) + if( specification.test( transientAssembly ) ) { assemblies.add( transientAssembly ); } @@ -206,12 +206,12 @@ public final class ModuleAssemblyImpl } @Override - public TransientDeclaration transients( Specification<? super TransientAssembly> specification ) + public TransientDeclaration transients( Predicate<? super TransientAssembly> specification ) { List<TransientAssemblyImpl> assemblies = new ArrayList<>(); for( TransientAssemblyImpl transientAssembly : transientAssemblies.values() ) { - if( specification.satisfiedBy( transientAssembly ) ) + if( specification.test( transientAssembly ) ) { assemblies.add( transientAssembly ); } @@ -244,12 +244,12 @@ public final class ModuleAssemblyImpl } @Override - public EntityDeclaration entities( Specification<? super EntityAssembly> specification ) + public EntityDeclaration entities( Predicate<? super EntityAssembly> specification ) { List<EntityAssemblyImpl> assemblies = new ArrayList<>(); for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() ) { - if( specification.satisfiedBy( entityAssembly ) ) + if( specification.test( entityAssembly ) ) { assemblies.add( entityAssembly ); } @@ -298,14 +298,14 @@ public final class ModuleAssemblyImpl } @Override - public ConfigurationDeclaration configurations( Specification<HasTypes> specification ) + public ConfigurationDeclaration configurations( Predicate<HasTypes> specification ) { - Specification<HasTypes> isConfigurationComposite = new MatchTypeSpecification( Identity.class ); + Predicate<HasTypes> isConfigurationComposite = new MatchTypeSpecification( Identity.class ); specification = Specifications.and( specification, isConfigurationComposite ); List<EntityAssemblyImpl> entityAssmblyList = new ArrayList<>(); for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() ) { - if( specification.satisfiedBy( entityAssembly ) ) + if( specification.test( entityAssembly ) ) { entityAssmblyList.add( entityAssembly ); } @@ -313,7 +313,7 @@ public final class ModuleAssemblyImpl List<ValueAssemblyImpl> valueAssemblyList = new ArrayList<>(); for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() ) { - if( specification.satisfiedBy( transientAssembly ) ) + if( specification.test( transientAssembly ) ) { valueAssemblyList.add( transientAssembly ); } @@ -349,12 +349,12 @@ public final class ModuleAssemblyImpl } @Override - public ObjectDeclaration objects( Specification<? super ObjectAssembly> specification ) + public ObjectDeclaration objects( Predicate<? super ObjectAssembly> specification ) { List<ObjectAssemblyImpl> assemblies = new ArrayList<>(); for( ObjectAssemblyImpl objectAssembly : objectAssemblies.values() ) { - if( specification.satisfiedBy( objectAssembly ) ) + if( specification.test( objectAssembly ) ) { assemblies.add( objectAssembly ); } @@ -401,12 +401,12 @@ public final class ModuleAssemblyImpl } @Override - public ServiceDeclaration services( Specification<? super ServiceAssembly> specification ) + public ServiceDeclaration services( Predicate<? super ServiceAssembly> specification ) { List<ServiceAssemblyImpl> assemblies = new ArrayList<>(); for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies ) { - if( specification.satisfiedBy( serviceAssembly ) ) + if( specification.test( serviceAssembly ) ) { assemblies.add( serviceAssembly ); } @@ -438,12 +438,12 @@ public final class ModuleAssemblyImpl } @Override - public ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification ) + public ImportedServiceDeclaration importedServices( Predicate<? super ImportedServiceAssembly> specification ) { List<ImportedServiceAssemblyImpl> assemblies = new ArrayList<>(); for( ImportedServiceAssemblyImpl objectAssembly : importedServiceAssemblies.values() ) { - if( specification.satisfiedBy( objectAssembly ) ) + if( specification.test( objectAssembly ) ) { assemblies.add( objectAssembly ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java index 9258dbc..dfaccfa 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java @@ -216,7 +216,7 @@ public final class CompositeMethodModel try { MixinModel model = mixins.mixinFor( method ); - if( GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) ) + if( Genericpredicate.INSTANCE.test( model.mixinClass() ) ) { return false; } @@ -237,7 +237,7 @@ public final class CompositeMethodModel try { MixinModel model = mixins.mixinFor( method ); - if( !GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) ) + if( !Genericpredicate.INSTANCE.test( model.mixinClass() ) ) { T annotation = annotationClass.cast( model.mixinClass() .getMethod( method.getName(), method.getParameterTypes() ) @@ -264,7 +264,7 @@ public final class CompositeMethodModel List<Annotation> annotations = new ArrayList<Annotation>(); MixinModel model = mixins.mixinFor( method ); Annotation[] mixinAnnotations = new Annotation[ 0 ]; - if( !GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) ) + if( !Genericpredicate.INSTANCE.test( model.mixinClass() ) ) { mixinAnnotations = model.mixinClass().getAnnotations(); annotations.addAll( Arrays.asList( mixinAnnotations ) ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java deleted file mode 100644 index 47ba877..0000000 --- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java +++ /dev/null @@ -1,37 +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.runtime.composite; - -import java.lang.reflect.InvocationHandler; -import org.apache.zest.functional.Specification; - -/** - * Specification that checks whether a given class implements InvocationHandler or not. - */ -public class GenericSpecification - implements Specification<Class<?>> -{ - public static final GenericSpecification INSTANCE = new GenericSpecification(); - - @Override - public boolean satisfiedBy( Class<?> item ) - { - return InvocationHandler.class.isAssignableFrom( item ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/composite/Genericpredicate.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/Genericpredicate.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/Genericpredicate.java new file mode 100644 index 0000000..e69ec3c --- /dev/null +++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/Genericpredicate.java @@ -0,0 +1,37 @@ +/* + * 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.runtime.composite; + +import java.lang.reflect.InvocationHandler; +import java.util.function.Predicate; + +/** + * Specification that checks whether a given class implements InvocationHandler or not. + */ +public class Genericpredicate + implements Predicate<Class<?>> +{ + public static final Genericpredicate INSTANCE = new Genericpredicate(); + + @Override + public boolean test( Class<?> item ) + { + return InvocationHandler.class.isAssignableFrom( item ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java index 8c78f26..30fc6c0 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java @@ -24,11 +24,11 @@ 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.util.Classes; import org.apache.zest.bootstrap.BindingException; import org.apache.zest.functional.HierarchicalVisitor; import org.apache.zest.functional.HierarchicalVisitorAdapter; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.VisitableHierarchy; import org.apache.zest.runtime.injection.DependencyModel; import org.apache.zest.runtime.injection.InjectedFieldModel; @@ -210,10 +210,10 @@ public class MixinsModel { return entry.getKey(); } - }, filter( new Specification<Map.Entry<Method, MixinModel>>() + }, filter( new Predicate<Map.Entry<Method, MixinModel>>() { @Override - public boolean satisfiedBy( Map.Entry<Method, MixinModel> item ) + public boolean test( Map.Entry<Method, MixinModel> item ) { MixinModel model = item.getValue(); return model.mixinClass().equals( mixinClass ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java index 619c570..73381bb 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java @@ -20,13 +20,13 @@ import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.util.Collections; import java.util.function.Function; +import java.util.function.Predicate; import org.apache.zest.api.common.ConstructionException; import org.apache.zest.api.common.Optional; import org.apache.zest.api.composite.DependencyDescriptor; import org.apache.zest.bootstrap.BindingException; import org.apache.zest.bootstrap.InvalidInjectionException; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.Visitable; import org.apache.zest.functional.Visitor; import org.apache.zest.runtime.injection.provider.InjectionProviderException; @@ -384,7 +384,7 @@ public final class DependencyModel } public static class ScopeSpecification - implements Specification<DependencyModel> + implements Predicate<DependencyModel> { private final Class<? extends Annotation> scope; @@ -394,7 +394,7 @@ public final class DependencyModel } @Override - public boolean satisfiedBy( DependencyModel model ) + public boolean test( DependencyModel model ) { return model.hasScope( scope ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java index 60977a5..f521e11 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java @@ -19,12 +19,12 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.util.Collection; +import java.util.function.Predicate; import org.apache.zest.api.composite.InjectedFieldDescriptor; import org.apache.zest.api.util.Classes; import org.apache.zest.bootstrap.BindingException; import org.apache.zest.bootstrap.InjectionException; import org.apache.zest.functional.HierarchicalVisitor; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.VisitableHierarchy; import org.apache.zest.runtime.composite.TransientInstance; import org.apache.zest.runtime.model.Resolution; @@ -127,9 +127,9 @@ public final class InjectedFieldModel return visitor.visitLeave( this ); } - public Collection<DependencyModel> filter( Specification<DependencyModel> specification ) + public Collection<DependencyModel> filter( Predicate<DependencyModel> specification ) { - if( specification.satisfiedBy( dependencyModel ) ) + if( specification.test( dependencyModel ) ) { return singleton( dependencyModel ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java index 2bb8360..1a4c723 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java @@ -17,9 +17,9 @@ package org.apache.zest.runtime.injection; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.function.Predicate; import org.apache.zest.api.composite.InjectedParametersDescriptor; import org.apache.zest.functional.HierarchicalVisitor; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.VisitableHierarchy; /** @@ -79,12 +79,12 @@ public final class InjectedParametersModel return visitor.visitLeave( this ); } - public Collection<DependencyModel> filter( Specification<DependencyModel> specification ) + public Collection<DependencyModel> filter( Predicate<DependencyModel> specification ) { ArrayList<DependencyModel> result = new ArrayList<DependencyModel>(); for( DependencyModel model : parameterDependencies ) { - if( specification.satisfiedBy( model ) ) + if( specification.test( model ) ) { result.add( model ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java index 952a73c..764d227 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java @@ -18,6 +18,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.function.Function; +import java.util.function.Predicate; import org.apache.zest.api.service.NoSuchServiceException; import org.apache.zest.api.service.ServiceReference; import org.apache.zest.api.service.qualifier.Qualifier; @@ -25,7 +26,6 @@ import org.apache.zest.api.util.Annotations; import org.apache.zest.api.util.Classes; import org.apache.zest.bootstrap.InvalidInjectionException; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.Specifications; import org.apache.zest.runtime.injection.DependencyModel; import org.apache.zest.runtime.injection.InjectionContext; @@ -49,7 +49,7 @@ public final class ServiceInjectionProviderFactory // TODO This could be changed to allow multiple @Qualifier annotations Annotation qualifierAnnotation = first( filter( Specifications.translate( Annotations.type(), hasAnnotation( Qualifier.class ) ), iterable( dependencyModel .annotations() ) ) ); - Specification<ServiceReference<?>> serviceQualifier = null; + Predicate<ServiceReference<?>> serviceQualifier = null; if( qualifierAnnotation != null ) { Qualifier qualifier = qualifierAnnotation.annotationType().getAnnotation( Qualifier.class ); @@ -96,7 +96,7 @@ public final class ServiceInjectionProviderFactory extends ServiceInjectionProvider { private IterableServiceReferenceProvider( Type serviceType, - Specification<ServiceReference<?>> serviceQualifier + Predicate<ServiceReference<?>> serviceQualifier ) { super( serviceType, serviceQualifier ); @@ -115,7 +115,7 @@ public final class ServiceInjectionProviderFactory implements Function<ServiceReference<?>, Object> { private IterableServiceProvider( Type serviceType, - Specification<ServiceReference<?>> serviceQualifier + Predicate<ServiceReference<?>> serviceQualifier ) { super( serviceType, serviceQualifier ); @@ -138,7 +138,7 @@ public final class ServiceInjectionProviderFactory private static class ServiceReferenceProvider extends ServiceInjectionProvider { - ServiceReferenceProvider( Type serviceType, Specification<ServiceReference<?>> qualifier ) + ServiceReferenceProvider( Type serviceType, Predicate<ServiceReference<?>> qualifier ) { super( serviceType, qualifier ); } @@ -154,7 +154,7 @@ public final class ServiceInjectionProviderFactory private static class ServiceProvider extends ServiceInjectionProvider { - ServiceProvider( Type serviceType, Specification<ServiceReference<?>> qualifier ) + ServiceProvider( Type serviceType, Predicate<ServiceReference<?>> qualifier ) { super( serviceType, qualifier ); } @@ -180,10 +180,10 @@ public final class ServiceInjectionProviderFactory implements InjectionProvider { private final Type serviceType; - private final Specification<ServiceReference<?>> serviceQualifier; + private final Predicate<ServiceReference<?>> serviceQualifier; private ServiceInjectionProvider( Type serviceType, - Specification<ServiceReference<?>> serviceQualifier + Predicate<ServiceReference<?>> serviceQualifier ) { this.serviceType = serviceType; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java index a7b53eb..70c8160 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java @@ -52,7 +52,7 @@ public final class ThisInjectionProviderFactory final Class<?> thisType = dependencyModel.rawInjectionType(); Iterable<Class<?>> injectionTypes = null; - if( Classes.assignableTypeSpecification( thisType ).satisfiedBy( bindingContext.model() ) ) + if( Classes.assignableTypeSpecification( thisType ).test( bindingContext.model() ) ) { injectionTypes = bindingContext.model().types(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java index 451f1d1..7166229 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java @@ -19,12 +19,12 @@ import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import org.apache.zest.api.composite.Composite; import org.apache.zest.api.property.Property; import org.apache.zest.api.query.grammar.OrderBy; import org.apache.zest.api.util.Classes; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.functional.Specifications; import org.apache.zest.spi.query.QuerySource; @@ -49,7 +49,7 @@ public class IterableQuerySource @Override public <T> T find( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -66,7 +66,7 @@ public class IterableQuerySource @Override public <T> long count( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -78,7 +78,7 @@ public class IterableQuerySource @Override public <T> Iterator<T> iterator( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -90,7 +90,7 @@ public class IterableQuerySource @SuppressWarnings( {"raw", "unchecked"} ) private <T> List<T> list( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -146,7 +146,7 @@ public class IterableQuerySource } @SuppressWarnings( {"raw", "unchecked"} ) - private <T> List<T> filter( Class<T> resultType, Specification whereClause ) + private <T> List<T> filter( Class<T> resultType, Predicate whereClause ) { if( whereClause == null ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java index 67ab342..7bf6045 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java @@ -18,11 +18,11 @@ */ package org.apache.zest.runtime.query; +import java.util.function.Predicate; import org.apache.zest.api.composite.Composite; import org.apache.zest.api.query.Query; import org.apache.zest.api.query.QueryBuilder; import org.apache.zest.api.query.QueryExpressions; -import org.apache.zest.functional.Specification; import org.apache.zest.spi.query.EntityFinder; import org.apache.zest.spi.query.QueryBuilderSPI; import org.apache.zest.spi.query.QuerySource; @@ -46,7 +46,7 @@ final class QueryBuilderImpl<T> /** * Where clause. */ - private final Specification<Composite> whereClause; + private final Predicate<Composite> whereClause; /** * Constructor. @@ -57,7 +57,7 @@ final class QueryBuilderImpl<T> */ QueryBuilderImpl( final EntityFinder entityFinder, final Class<T> resultType, - final Specification<Composite> whereClause + final Predicate<Composite> whereClause ) { this.entityFinder = entityFinder; @@ -67,7 +67,7 @@ final class QueryBuilderImpl<T> @Override @SuppressWarnings( "unchecked" ) - public QueryBuilder<T> where( Specification<Composite> specification ) + public QueryBuilder<T> where( Predicate<Composite> specification ) { if( specification == null ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java index 59ebb5d..c0d5286 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java @@ -21,6 +21,7 @@ package org.apache.zest.runtime.query; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.function.Predicate; import org.apache.zest.api.composite.Composite; import org.apache.zest.api.property.Property; import org.apache.zest.api.query.Query; @@ -28,7 +29,6 @@ import org.apache.zest.api.query.QueryExecutionException; import org.apache.zest.api.query.QueryExpressions; import org.apache.zest.api.query.grammar.OrderBy; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.spi.query.QuerySource; /** @@ -46,7 +46,7 @@ import org.apache.zest.spi.query.QuerySource; /** * Where clause. */ - private final Specification<Composite> whereClause; + private final Predicate<Composite> whereClause; private QuerySource querySource; /** * Order by clause segments. @@ -72,7 +72,7 @@ import org.apache.zest.spi.query.QuerySource; * @param whereClause where clause */ /* package */ QueryImpl( final Class<T> resultType, - final Specification<Composite> whereClause, + final Predicate<Composite> whereClause, final QuerySource querySource ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java index f957f11..5fa5118 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java @@ -15,6 +15,7 @@ package org.apache.zest.runtime.service; import java.util.List; +import java.util.function.Predicate; import org.apache.zest.api.activation.Activation; import org.apache.zest.api.activation.ActivationEventListener; import org.apache.zest.api.activation.ActivationEventListenerRegistration; @@ -23,7 +24,6 @@ import org.apache.zest.api.activation.PassivationException; import org.apache.zest.api.common.Visibility; import org.apache.zest.api.service.ServiceReference; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.runtime.activation.ActivationDelegate; import org.apache.zest.runtime.activation.ActivatorsInstance; @@ -69,10 +69,10 @@ public class ImportedServicesInstance public Iterable<ServiceReference> visibleServices( final Visibility visibility ) { - return Iterables.filter( new Specification<ServiceReference>() + return Iterables.filter( new Predicate<ServiceReference>() { @Override - public boolean satisfiedBy( ServiceReference item ) + public boolean test( ServiceReference item ) { return ( (ImportedServiceReferenceInstance) item ).serviceDescriptor() .visibility() http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java index 727b6fd..6a401d2 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java @@ -51,7 +51,7 @@ public class ServiceInstance super( compositeModel, moduleInstance, mixins, state ); implementsServiceAvailable = - Classes.assignableTypeSpecification( Availability.class ).satisfiedBy( descriptor() ); + Classes.assignableTypeSpecification( Availability.class ).test( descriptor() ); hasEnabledConfiguration = compositeModel.configurationType() != null && Enabled.class.isAssignableFrom( compositeModel.configurationType() ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/b659ba67/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java index bb03428..7400faf 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java @@ -15,6 +15,7 @@ package org.apache.zest.runtime.service; import java.util.List; +import java.util.function.Predicate; import org.apache.zest.api.activation.Activation; import org.apache.zest.api.activation.ActivationEventListener; import org.apache.zest.api.activation.ActivationEventListenerRegistration; @@ -23,7 +24,6 @@ import org.apache.zest.api.activation.PassivationException; import org.apache.zest.api.common.Visibility; import org.apache.zest.api.service.ServiceReference; import org.apache.zest.functional.Iterables; -import org.apache.zest.functional.Specification; import org.apache.zest.runtime.activation.ActivationDelegate; import org.apache.zest.runtime.activation.ActivatorsInstance; @@ -67,10 +67,10 @@ public class ServicesInstance public Iterable<ServiceReference> visibleServices( final Visibility visibility ) { - return Iterables.filter( new Specification<ServiceReference>() + return Iterables.filter( new Predicate<ServiceReference>() { @Override - public boolean satisfiedBy( ServiceReference item ) + public boolean test( ServiceReference item ) { return ( (ServiceReferenceInstance) item ).serviceDescriptor() .visibility()
