http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ServiceInjectionProviderFactory.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ServiceInjectionProviderFactory.java b/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ServiceInjectionProviderFactory.java index 30c16f5..8884cf0 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ServiceInjectionProviderFactory.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ServiceInjectionProviderFactory.java @@ -17,15 +17,15 @@ package org.qi4j.runtime.injection.provider; 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.qi4j.api.service.NoSuchServiceException; import org.qi4j.api.service.ServiceReference; import org.qi4j.api.service.qualifier.Qualifier; import org.qi4j.api.util.Annotations; import org.qi4j.api.util.Classes; import org.qi4j.bootstrap.InvalidInjectionException; -import org.qi4j.functional.Function; import org.qi4j.functional.Iterables; -import org.qi4j.functional.Specification; import org.qi4j.functional.Specifications; import org.qi4j.runtime.injection.DependencyModel; import org.qi4j.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 ); @@ -66,7 +66,7 @@ public final class ServiceInjectionProviderFactory if( dependencyModel.rawInjectionType().equals( Iterable.class ) ) { Type iterableType = ( (ParameterizedType) dependencyModel.injectionType() ).getActualTypeArguments()[ 0 ]; - if( Classes.RAW_CLASS.map( iterableType ).equals( ServiceReference.class ) ) + if( Classes.RAW_CLASS.apply( iterableType ).equals( ServiceReference.class ) ) { // @Service Iterable<ServiceReference<MyService<Foo>> serviceRefs Type serviceType = ( (ParameterizedType) iterableType ).getActualTypeArguments()[ 0 ]; @@ -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 ); @@ -129,7 +129,7 @@ public final class ServiceInjectionProviderFactory } @Override - public Object map( ServiceReference<?> objectServiceReference ) + public Object apply( ServiceReference<?> objectServiceReference ) { return objectServiceReference.get(); } @@ -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-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ThisInjectionProviderFactory.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ThisInjectionProviderFactory.java b/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ThisInjectionProviderFactory.java index ac648d8..c927b65 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ThisInjectionProviderFactory.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/injection/provider/ThisInjectionProviderFactory.java @@ -34,7 +34,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-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/query/IterableQuerySource.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/query/IterableQuerySource.java b/core/runtime/src/main/java/org/qi4j/runtime/query/IterableQuerySource.java index 09490a5..c1cecf4 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/query/IterableQuerySource.java +++ b/core/runtime/src/main/java/org/qi4j/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.qi4j.api.composite.Composite; import org.qi4j.api.property.Property; import org.qi4j.api.query.grammar.OrderBy; import org.qi4j.api.util.Classes; import org.qi4j.functional.Iterables; -import org.qi4j.functional.Specification; import org.qi4j.functional.Specifications; import org.qi4j.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 ) { @@ -183,8 +183,8 @@ public class IterableQuerySource { try { - final Property prop1 = orderBySegment.property().map( o1 ); - final Property prop2 = orderBySegment.property().map( o2 ); + final Property prop1 = orderBySegment.property().apply( o1 ); + final Property prop2 = orderBySegment.property().apply( o2 ); if( prop1 == null || prop2 == null ) { if( prop1 == null && prop2 == null ) http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/query/QueryBuilderImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/query/QueryBuilderImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/query/QueryBuilderImpl.java index bef28c5..2374609 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/query/QueryBuilderImpl.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/query/QueryBuilderImpl.java @@ -18,11 +18,11 @@ */ package org.qi4j.runtime.query; +import java.util.function.Predicate; import org.qi4j.api.composite.Composite; import org.qi4j.api.query.Query; import org.qi4j.api.query.QueryBuilder; import org.qi4j.api.query.QueryExpressions; -import org.qi4j.functional.Specification; import org.qi4j.spi.query.EntityFinder; import org.qi4j.spi.query.QueryBuilderSPI; import org.qi4j.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-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/query/QueryImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/query/QueryImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/query/QueryImpl.java index 7048990..e944d73 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/query/QueryImpl.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/query/QueryImpl.java @@ -21,6 +21,7 @@ package org.qi4j.runtime.query; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.function.Predicate; import org.qi4j.api.composite.Composite; import org.qi4j.api.property.Property; import org.qi4j.api.query.Query; @@ -28,7 +29,6 @@ import org.qi4j.api.query.QueryExecutionException; import org.qi4j.api.query.QueryExpressions; import org.qi4j.api.query.grammar.OrderBy; import org.qi4j.functional.Iterables; -import org.qi4j.functional.Specification; import org.qi4j.spi.query.QuerySource; /** @@ -46,7 +46,7 @@ import org.qi4j.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.qi4j.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-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/service/ImportedServicesInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/service/ImportedServicesInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/service/ImportedServicesInstance.java index 211dfad..dd7a412 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/service/ImportedServicesInstance.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/service/ImportedServicesInstance.java @@ -15,6 +15,7 @@ package org.qi4j.runtime.service; import java.util.List; +import java.util.function.Predicate; import org.qi4j.api.activation.Activation; import org.qi4j.api.activation.ActivationEventListener; import org.qi4j.api.activation.ActivationEventListenerRegistration; @@ -23,7 +24,6 @@ import org.qi4j.api.activation.PassivationException; import org.qi4j.api.common.Visibility; import org.qi4j.api.service.ServiceReference; import org.qi4j.functional.Iterables; -import org.qi4j.functional.Specification; import org.qi4j.runtime.activation.ActivationDelegate; import org.qi4j.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-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceInstance.java index 2bbb462..ee0e7af 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceInstance.java +++ b/core/runtime/src/main/java/org/qi4j/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-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceModel.java b/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceModel.java index ec029d1..f13ba07 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceModel.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/service/ServiceModel.java @@ -196,7 +196,7 @@ public final class ServiceModel extends CompositeModel .equals( Configuration.class ) && dependencyModel.injectionType() instanceof ParameterizedType ) { Class<?> type = Classes.RAW_CLASS - .map( ( (ParameterizedType) dependencyModel.injectionType() ).getActualTypeArguments()[ 0 ] ); + .apply( ( (ParameterizedType) dependencyModel.injectionType() ).getActualTypeArguments()[ 0 ] ); if( injectionClass == null ) { injectionClass = type; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/service/ServicesInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/service/ServicesInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/service/ServicesInstance.java index 3920855..4020ff3 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/service/ServicesInstance.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/service/ServicesInstance.java @@ -15,6 +15,7 @@ package org.qi4j.runtime.service; import java.util.List; +import java.util.function.Predicate; import org.qi4j.api.activation.Activation; import org.qi4j.api.activation.ActivationEventListener; import org.qi4j.api.activation.ActivationEventListenerRegistration; @@ -23,7 +24,6 @@ import org.qi4j.api.activation.PassivationException; import org.qi4j.api.common.Visibility; import org.qi4j.api.service.ServiceReference; import org.qi4j.functional.Iterables; -import org.qi4j.functional.Specification; import org.qi4j.runtime.activation.ActivationDelegate; import org.qi4j.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() http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/LayerInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/LayerInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/LayerInstance.java index 9ed77bb..0b408e4 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/LayerInstance.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/LayerInstance.java @@ -16,13 +16,13 @@ package org.qi4j.runtime.structure; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import org.qi4j.api.activation.ActivationEventListener; import org.qi4j.api.activation.ActivationException; import org.qi4j.api.activation.PassivationException; import org.qi4j.api.common.Visibility; import org.qi4j.api.service.ServiceReference; import org.qi4j.api.structure.Layer; -import org.qi4j.functional.Function; import org.qi4j.runtime.activation.ActivationDelegate; import org.qi4j.runtime.composite.TransientModel; import org.qi4j.runtime.entity.EntityModel; @@ -136,7 +136,7 @@ public class LayerInstance { @Override - public Iterable<ModelModule<ObjectModel>> map( ModuleInstance moduleInstance ) + public Iterable<ModelModule<ObjectModel>> apply( ModuleInstance moduleInstance ) { return moduleInstance.visibleObjects( visibility ); } @@ -150,7 +150,7 @@ public class LayerInstance { @Override - public Iterable<ModelModule<TransientModel>> map( ModuleInstance moduleInstance ) + public Iterable<ModelModule<TransientModel>> apply( ModuleInstance moduleInstance ) { return moduleInstance.visibleTransients( visibility ); } @@ -164,7 +164,7 @@ public class LayerInstance { @Override - public Iterable<ModelModule<EntityModel>> map( ModuleInstance moduleInstance ) + public Iterable<ModelModule<EntityModel>> apply( ModuleInstance moduleInstance ) { return moduleInstance.visibleEntities( visibility ); } @@ -178,7 +178,7 @@ public class LayerInstance { @Override - public Iterable<ModelModule<ValueModel>> map( ModuleInstance moduleInstance ) + public Iterable<ModelModule<ValueModel>> apply( ModuleInstance moduleInstance ) { return moduleInstance.visibleValues( visibility ); } @@ -192,7 +192,7 @@ public class LayerInstance { @Override - public Iterable<ServiceReference<?>> map( ModuleInstance moduleInstance ) + public Iterable<ServiceReference<?>> apply( ModuleInstance moduleInstance ) { return moduleInstance.visibleServices( visibility ); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/ModelModule.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/ModelModule.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/ModelModule.java index fe787a0..e68eda2 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/ModelModule.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/ModelModule.java @@ -1,7 +1,7 @@ package org.qi4j.runtime.structure; +import java.util.function.Function; import org.qi4j.api.composite.ModelDescriptor; -import org.qi4j.functional.Function; /** * TODO @@ -13,7 +13,7 @@ public class ModelModule<T extends ModelDescriptor> return new Function<T, ModelModule<T>>() { @Override - public ModelModule<T> map( T model ) + public ModelModule<T> apply( T model ) { return new ModelModule<>( module, model ); } @@ -25,7 +25,7 @@ public class ModelModule<T extends ModelDescriptor> return new Function<ModelModule<T>, T>() { @Override - public T map( ModelModule<T> modelModule ) + public T apply( ModelModule<T> modelModule ) { return modelModule.model(); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleInstance.java index 551999e..cfbbb41 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleInstance.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleInstance.java @@ -24,6 +24,9 @@ import java.util.List; import java.util.Map; import java.util.Stack; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; import org.qi4j.api.activation.Activation; import org.qi4j.api.activation.ActivationEventListener; import org.qi4j.api.activation.ActivationException; @@ -62,9 +65,6 @@ import org.qi4j.api.value.ValueComposite; import org.qi4j.api.value.ValueDescriptor; import org.qi4j.api.value.ValueSerialization; import org.qi4j.api.value.ValueSerializationException; -import org.qi4j.functional.Function; -import org.qi4j.functional.Function2; -import org.qi4j.functional.Specification; import org.qi4j.functional.Specifications; import org.qi4j.runtime.activation.ActivationDelegate; import org.qi4j.runtime.composite.TransientBuilderInstance; @@ -320,7 +320,7 @@ public class ModuleInstance TransientStateInstance state = new TransientStateInstance( properties ); - return new TransientBuilderInstance<>( modelModule, state, UsesInstance.EMPTY_USES ); + return new TransientBuilderInstance<T>( modelModule, state, UsesInstance.EMPTY_USES ); } @Override @@ -437,25 +437,25 @@ public class ModuleInstance @Override public Object getPropertyState( PropertyDescriptor propertyDescriptor ) { - return propertyFunction.map( propertyDescriptor ); + return propertyFunction.apply( propertyDescriptor ); } @Override public EntityReference getAssociationState( AssociationDescriptor associationDescriptor ) { - return associationFunction.map( associationDescriptor ); + return associationFunction.apply( associationDescriptor ); } @Override public List<EntityReference> getManyAssociationState( AssociationDescriptor associationDescriptor ) { - return toList( manyAssociationFunction.map( associationDescriptor ) ); + return toList( manyAssociationFunction.apply( associationDescriptor ) ); } @Override public Map<String, EntityReference> getNamedAssociationState( AssociationDescriptor associationDescriptor ) { - return namedAssociationFunction.map( associationDescriptor ); + return namedAssociationFunction.apply( associationDescriptor ); } } @@ -629,13 +629,13 @@ public class ModuleInstance return typeLookup; } - public Function2<EntityReference, Type, Object> getEntityFunction() + public BiFunction<EntityReference, Type, Object> getEntityFunction() { return entityFunction; } private static class EntityFunction - implements Function2<EntityReference, Type, Object> + implements BiFunction<EntityReference, Type, Object> { private final UnitOfWorkFactory uowf; @@ -646,9 +646,9 @@ public class ModuleInstance } @Override - public Object map( EntityReference entityReference, Type type ) + public Object apply( EntityReference entityReference, Type type ) { - return uowf.currentUnitOfWork().get( RAW_CLASS.map( type ), entityReference.identity() ); + return uowf.currentUnitOfWork().get( RAW_CLASS.apply( type ), entityReference.identity() ); } } @@ -773,8 +773,8 @@ public class ModuleInstance Class<?> clazz = classes.get( name ); if( clazz == null ) { - Specification<ModelDescriptor> modelTypeSpecification = modelTypeSpecification( name ); - Specification<ModelModule<ModelDescriptor>> translate = Specifications.translate( ModelModule.modelFunction(), modelTypeSpecification ); + Predicate<ModelDescriptor> modelTypeSpecification = modelTypeSpecification( name ); + Predicate<ModelModule<ModelDescriptor>> translate = Specifications.translate( ModelModule.modelFunction(), modelTypeSpecification ); // Check module { Iterable<ModelModule<ModelDescriptor>> i = cast( flatten( http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleUnitOfWork.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleUnitOfWork.java index bdadb75..2a333c7 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleUnitOfWork.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/ModuleUnitOfWork.java @@ -18,6 +18,7 @@ package org.qi4j.runtime.structure; import java.util.Collections; import java.util.Iterator; import java.util.Map; +import java.util.function.Predicate; import org.qi4j.api.composite.Composite; import org.qi4j.api.entity.EntityBuilder; import org.qi4j.api.entity.EntityComposite; @@ -38,7 +39,6 @@ import org.qi4j.api.unitofwork.UnitOfWorkCompletionException; import org.qi4j.api.unitofwork.UnitOfWorkFactory; import org.qi4j.api.usecase.Usecase; import org.qi4j.functional.Iterables; -import org.qi4j.functional.Specification; import org.qi4j.runtime.entity.EntityInstance; import org.qi4j.runtime.entity.EntityModel; import org.qi4j.runtime.unitofwork.EntityBuilderInstance; @@ -335,7 +335,7 @@ public class ModuleUnitOfWork @Override public <T> T find( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -370,7 +370,7 @@ public class ModuleUnitOfWork @Override public <T> long count( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -392,7 +392,7 @@ public class ModuleUnitOfWork @Override public <T> Iterator<T> iterator( final Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/TypeLookup.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/TypeLookup.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/TypeLookup.java index 1383ce8..ae796cf 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/TypeLookup.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/TypeLookup.java @@ -27,13 +27,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import java.util.function.Predicate; import org.qi4j.api.common.Visibility; import org.qi4j.api.composite.AmbiguousTypeException; import org.qi4j.api.composite.ModelDescriptor; import org.qi4j.api.service.NoSuchServiceException; import org.qi4j.api.service.ServiceReference; -import org.qi4j.functional.Function; -import org.qi4j.functional.Specification; import org.qi4j.functional.Specifications; import org.qi4j.runtime.composite.TransientModel; import org.qi4j.runtime.entity.EntityModel; @@ -356,7 +356,7 @@ public class TypeLookup if( serviceReference == null ) { - throw new NoSuchServiceException( RAW_CLASS.map( serviceType ).getName(), moduleInstance.name() ); + throw new NoSuchServiceException( RAW_CLASS.apply( serviceType ).getName(), moduleInstance.name() ); } return (ServiceReference<T>) serviceReference; @@ -411,19 +411,19 @@ public class TypeLookup } @SuppressWarnings( { "raw", "unchecked" } ) - private static <T extends ModelDescriptor> Iterable<ModelModule<T>> findModels( Specification<Iterable<Class<?>>> specification, + private static <T extends ModelDescriptor> Iterable<ModelModule<T>> findModels( Predicate<Iterable<Class<?>>> specification, Iterable<ModelModule<T>>... models ) { - Specification<ModelModule<T>> spec = Specifications.translate( new ModelModuleTypesFunction(), specification ); + Predicate<ModelModule<T>> spec = Specifications.translate( new ModelModuleTypesFunction(), specification ); Iterable<ModelModule<T>> flattened = flattenIterables( iterable( models ) ); return filter( spec, flattened ); } @SuppressWarnings( { "raw", "unchecked" } ) - private static Iterable<ServiceReference<?>> findServiceReferences( Specification<Iterable<Class<?>>> specification, + private static Iterable<ServiceReference<?>> findServiceReferences( Predicate<Iterable<Class<?>>> specification, Iterable<ServiceReference<?>>... references ) { - Specification<ServiceReference<?>> spec = Specifications.translate( new ServiceReferenceTypesFunction(), specification ); + Predicate<ServiceReference<?>> spec = Specifications.translate( new ServiceReferenceTypesFunction(), specification ); Iterable<ServiceReference<?>> flattened = flattenIterables( iterable( references ) ); return filter( spec, flattened ); } @@ -482,7 +482,7 @@ public class TypeLookup { @Override - public Iterable<Class<?>> map( ModelModule<T> modelModule ) + public Iterable<Class<?>> apply( ModelModule<T> modelModule ) { return modelModule.model().types(); } @@ -494,7 +494,7 @@ public class TypeLookup { @Override - public Iterable<Class<?>> map( ServiceReference<?> serviceReference ) + public Iterable<Class<?>> apply( ServiceReference<?> serviceReference ) { return serviceReference.types(); } @@ -502,7 +502,7 @@ public class TypeLookup } private static abstract class AbstractTypeLookupSpecification - implements Specification<Iterable<Class<?>>> + implements Predicate<Iterable<Class<?>>> { protected final Type lookedUpType; @@ -513,7 +513,7 @@ public class TypeLookup } @Override - public final boolean satisfiedBy( Iterable<Class<?>> types ) + public final boolean test( Iterable<Class<?>> types ) { if( lookedUpType instanceof Class ) { http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/UsedLayersInstance.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/UsedLayersInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/UsedLayersInstance.java index 1c0f650..7db6f39 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/UsedLayersInstance.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/UsedLayersInstance.java @@ -15,9 +15,9 @@ package org.qi4j.runtime.structure; import java.util.List; +import java.util.function.Function; import org.qi4j.api.common.Visibility; import org.qi4j.api.service.ServiceReference; -import org.qi4j.functional.Function; import org.qi4j.runtime.composite.TransientModel; import org.qi4j.runtime.entity.EntityModel; import org.qi4j.runtime.object.ObjectModel; @@ -42,7 +42,7 @@ public final class UsedLayersInstance return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<ObjectModel>>>() { @Override - public Iterable<ModelModule<ObjectModel>> map( LayerInstance layerInstance ) + public Iterable<ModelModule<ObjectModel>> apply( LayerInstance layerInstance ) { return layerInstance.visibleObjects( Visibility.application ); } @@ -54,7 +54,7 @@ public final class UsedLayersInstance return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<TransientModel>>>() { @Override - public Iterable<ModelModule<TransientModel>> map( LayerInstance layerInstance ) + public Iterable<ModelModule<TransientModel>> apply( LayerInstance layerInstance ) { return layerInstance.visibleTransients( Visibility.application ); } @@ -66,7 +66,7 @@ public final class UsedLayersInstance return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<EntityModel>>>() { @Override - public Iterable<ModelModule<EntityModel>> map( LayerInstance layerInstance ) + public Iterable<ModelModule<EntityModel>> apply( LayerInstance layerInstance ) { return layerInstance.visibleEntities( Visibility.application ); } @@ -78,7 +78,7 @@ public final class UsedLayersInstance return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<ValueModel>>>() { @Override - public Iterable<ModelModule<ValueModel>> map( LayerInstance layerInstance ) + public Iterable<ModelModule<ValueModel>> apply( LayerInstance layerInstance ) { return layerInstance.visibleValues( Visibility.application ); } @@ -90,7 +90,7 @@ public final class UsedLayersInstance return flattenIterables( map( new Function<LayerInstance, Iterable<ServiceReference<?>>>() { @Override - public Iterable<ServiceReference<?>> map( LayerInstance layerInstance ) + public Iterable<ServiceReference<?>> apply( LayerInstance layerInstance ) { return layerInstance.visibleServices( Visibility.application ); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/structure/VisibilitySpecification.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/structure/VisibilitySpecification.java b/core/runtime/src/main/java/org/qi4j/runtime/structure/VisibilitySpecification.java index 37862b2..ce1f285 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/structure/VisibilitySpecification.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/structure/VisibilitySpecification.java @@ -1,18 +1,18 @@ package org.qi4j.runtime.structure; +import java.util.function.Predicate; import org.qi4j.api.common.Visibility; import org.qi4j.api.composite.ModelDescriptor; -import org.qi4j.functional.Specification; /** * TODO */ public class VisibilitySpecification - implements Specification<ModelDescriptor> + implements Predicate<ModelDescriptor> { - public static final Specification<ModelDescriptor> MODULE = new VisibilitySpecification( Visibility.module ); - public static final Specification<ModelDescriptor> LAYER = new VisibilitySpecification( Visibility.layer ); - public static final Specification<ModelDescriptor> APPLICATION = new VisibilitySpecification( Visibility.application ); + public static final Predicate<ModelDescriptor> MODULE = new VisibilitySpecification( Visibility.module ); + public static final Predicate<ModelDescriptor> LAYER = new VisibilitySpecification( Visibility.layer ); + public static final Predicate<ModelDescriptor> APPLICATION = new VisibilitySpecification( Visibility.application ); private final Visibility visibility; @@ -22,7 +22,7 @@ public class VisibilitySpecification } @Override - public boolean satisfiedBy( ModelDescriptor item ) + public boolean test( ModelDescriptor item ) { return item.visibility().ordinal() >= visibility.ordinal(); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java b/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java index 0910293..cd74487 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java @@ -77,12 +77,12 @@ public class ValueTypeFactory collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType ); } ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module ); - valueType = new CollectionType( Classes.RAW_CLASS.map( type ), collectedType ); + valueType = new CollectionType( Classes.RAW_CLASS.apply( type ), collectedType ); } else { - valueType = new CollectionType( Classes.RAW_CLASS - .map( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ) ); + valueType = new CollectionType( + Classes.RAW_CLASS.apply( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ) ); } } else if( MapType.isMap( type ) ) @@ -106,18 +106,18 @@ public class ValueTypeFactory } ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module ); - valueType = new MapType( Classes.RAW_CLASS.map( type ), keyedType, valuedType ); + valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyedType, valuedType ); } else { - valueType = new MapType( Classes.RAW_CLASS - .map( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ), newValueType( Object.class, declaringClass, compositeType, layer, module ) ); + valueType = new MapType( + Classes.RAW_CLASS.apply( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ), newValueType( Object.class, declaringClass, compositeType, layer, module ) ); } } else if( ValueCompositeType.isValueComposite( type ) ) { // Find ValueModel in module/layer/used layers - ValueModel model = new ValueFinder( layer, module, Classes.RAW_CLASS.map( type ) ).getFoundModel(); + ValueModel model = new ValueFinder( layer, module, Classes.RAW_CLASS.apply( type ) ).getFoundModel(); if( model == null ) { @@ -143,11 +143,11 @@ public class ValueTypeFactory } else if( EnumType.isEnum( type ) ) { - valueType = new EnumType( Classes.RAW_CLASS.map( type ) ); + valueType = new EnumType( Classes.RAW_CLASS.apply( type ) ); } else { - valueType = new ValueType( Classes.RAW_CLASS.map( type ) ); + valueType = new ValueType( Classes.RAW_CLASS.apply( type ) ); } return valueType; @@ -209,7 +209,7 @@ public class ValueTypeFactory else if( visited instanceof ValueModel ) { ValueModel valueModel = (ValueModel) visited; - boolean typeEquality = Specifications.in( valueModel.types() ).satisfiedBy( type ); + boolean typeEquality = Specifications.in( valueModel.types() ).test( type ); if( typeEquality && valueModel.visibility().ordinal() >= visibility.ordinal() ) { foundModel = valueModel; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/main/java/org/qi4j/runtime/unitofwork/BuilderEntityState.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/qi4j/runtime/unitofwork/BuilderEntityState.java b/core/runtime/src/main/java/org/qi4j/runtime/unitofwork/BuilderEntityState.java index 7c1388c..fc2302d 100644 --- a/core/runtime/src/main/java/org/qi4j/runtime/unitofwork/BuilderEntityState.java +++ b/core/runtime/src/main/java/org/qi4j/runtime/unitofwork/BuilderEntityState.java @@ -81,7 +81,7 @@ public final class BuilderEntityState @Override public boolean isAssignableTo( Class<?> type ) { - return Classes.exactTypeSpecification( type ).satisfiedBy( entityType ); + return Classes.exactTypeSpecification( type ).test( entityType ); } @Override http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/composite/CompositeFactoryImplTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/composite/CompositeFactoryImplTest.java b/core/runtime/src/test/java/org/qi4j/runtime/composite/CompositeFactoryImplTest.java index 40666e0..564f28a 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/composite/CompositeFactoryImplTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/composite/CompositeFactoryImplTest.java @@ -57,7 +57,7 @@ public class CompositeFactoryImplTest TransientBuilder<SecondComposite> builder = module.newTransientBuilder( SecondComposite.class ); SecondComposite composition9 = builder.newInstance(); - composition9.setValue( "satisfiedBy value" ); + composition9.setValue( "test value" ); } catch( Exception e ) { http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/composite/FunctionalListTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/composite/FunctionalListTest.java b/core/runtime/src/test/java/org/qi4j/runtime/composite/FunctionalListTest.java index da0c71f..3e61416 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/composite/FunctionalListTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/composite/FunctionalListTest.java @@ -2,6 +2,7 @@ package org.qi4j.runtime.composite; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import org.junit.Test; import org.qi4j.api.injection.scope.Structure; import org.qi4j.api.injection.scope.This; @@ -9,7 +10,6 @@ import org.qi4j.api.mixin.Mixins; import org.qi4j.api.structure.Module; import org.qi4j.bootstrap.AssemblyException; import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.functional.Function; import org.qi4j.test.AbstractQi4jTest; import static org.hamcrest.CoreMatchers.hasItems; @@ -38,7 +38,7 @@ public class FunctionalListTest extends AbstractQi4jTest List<String> strings = list.translate( new Function<Integer, String>() { @Override - public String map( Integer x ) + public String apply( Integer x ) { return x.toString(); } @@ -72,7 +72,7 @@ public class FunctionalListTest extends AbstractQi4jTest List<TO> result = module.newTransient( List.class ); for( FROM data : list ) { - result.add( function.map( data ) ); + result.add( function.apply( data ) ); } return result; } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/injection/ServiceInjectionTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/injection/ServiceInjectionTest.java b/core/runtime/src/test/java/org/qi4j/runtime/injection/ServiceInjectionTest.java index 1038b79..fcd1943 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/injection/ServiceInjectionTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/injection/ServiceInjectionTest.java @@ -17,6 +17,7 @@ package org.qi4j.runtime.injection; import java.io.Serializable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.function.Predicate; import org.junit.Test; import org.qi4j.api.activation.ActivationException; import org.qi4j.api.common.ConstructionException; @@ -36,7 +37,6 @@ import org.qi4j.bootstrap.LayerAssembly; import org.qi4j.bootstrap.ModuleAssembly; import org.qi4j.bootstrap.ServiceDeclaration; import org.qi4j.bootstrap.SingletonAssembler; -import org.qi4j.functional.Specification; import static org.junit.Assert.assertEquals; import static org.qi4j.api.common.Visibility.application; @@ -294,11 +294,11 @@ public class ServiceInjectionTest public static final class NamedSelector implements AnnotationQualifier<Named> { - public <T> Specification<ServiceReference<?>> qualifier( final Named named ) + public <T> Predicate<ServiceReference<?>> qualifier( final Named named ) { - return new Specification<ServiceReference<?>>() + return new Predicate<ServiceReference<?>>() { - public boolean satisfiedBy( ServiceReference<?> service ) + public boolean test( ServiceReference<?> service ) { ServiceName serviceName = service.metaInfo( ServiceName.class ); return ( serviceName != null && serviceName.getName().equals( named.value() ) ); http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/mixin/JDKMixinTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/mixin/JDKMixinTest.java b/core/runtime/src/test/java/org/qi4j/runtime/mixin/JDKMixinTest.java index f52a6c6..31679d5 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/mixin/JDKMixinTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/mixin/JDKMixinTest.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import org.json.JSONObject; import org.junit.Before; import org.junit.Test; @@ -30,7 +31,6 @@ import org.qi4j.api.injection.scope.This; import org.qi4j.api.service.ServiceReference; import org.qi4j.bootstrap.AssemblyException; import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.functional.Specification; import org.qi4j.test.AbstractQi4jTest; import static org.hamcrest.core.IsEqual.*; @@ -103,8 +103,8 @@ public class JDKMixinTest private static final String EXTENDS_IDENTITY = ExtendsJDKMixin.class.getName(); private static final String COMPOSE_IDENTITY = ComposeWithJDKMixin.class.getName(); - private static final Specification<ServiceReference<?>> EXTENDS_IDENTITY_SPEC = new ServiceIdentitySpec( EXTENDS_IDENTITY ); - private static final Specification<ServiceReference<?>> COMPOSE_IDENTITY_SPEC = new ServiceIdentitySpec( COMPOSE_IDENTITY ); + private static final Predicate<ServiceReference<?>> EXTENDS_IDENTITY_SPEC = new ServiceIdentitySpec( EXTENDS_IDENTITY ); + private static final Predicate<ServiceReference<?>> COMPOSE_IDENTITY_SPEC = new ServiceIdentitySpec( COMPOSE_IDENTITY ); private static final List<String> CONCERN_RECORDS = new ArrayList<String>(); @Before @@ -170,7 +170,7 @@ public class JDKMixinTest } private static class ServiceIdentitySpec - implements Specification<ServiceReference<?>> + implements Predicate<ServiceReference<?>> { private final String identity; @@ -181,7 +181,7 @@ public class JDKMixinTest } @Override - public boolean satisfiedBy( ServiceReference<?> item ) + public boolean test( ServiceReference<?> item ) { return item.identity().equals( identity ); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/mixin/MixinPrecedenceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/mixin/MixinPrecedenceTest.java b/core/runtime/src/test/java/org/qi4j/runtime/mixin/MixinPrecedenceTest.java index 3fdb1f5..eca8245 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/mixin/MixinPrecedenceTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/mixin/MixinPrecedenceTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; /** - * Test mixin declaration precedence satisfiedBy + * Test mixin declaration precedence test */ public class MixinPrecedenceTest extends AbstractQi4jTest http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/property/PropertyTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/property/PropertyTest.java b/core/runtime/src/test/java/org/qi4j/runtime/property/PropertyTest.java index ea2a319..3f2eba4 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/property/PropertyTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/property/PropertyTest.java @@ -35,7 +35,7 @@ import static org.junit.Assert.assertEquals; * Tests for properties */ //@Ignore( -// "This is an incorrect satisfiedBy case. The Property fragment support is not well defined at the moment, so until" + +// "This is an incorrect test case. The Property fragment support is not well defined at the moment, so until" + // "more work is finalized on exactly what should be supported, this is ignored not to be forgotten." ) public class PropertyTest extends AbstractQi4jTest http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/runtime/structure/ModuleTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/runtime/structure/ModuleTest.java b/core/runtime/src/test/java/org/qi4j/runtime/structure/ModuleTest.java index d9e14f2..ef7e4ed 100644 --- a/core/runtime/src/test/java/org/qi4j/runtime/structure/ModuleTest.java +++ b/core/runtime/src/test/java/org/qi4j/runtime/structure/ModuleTest.java @@ -33,7 +33,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; /** - * Test of the Module interface. This should satisfiedBy both the general interface and all possible visibility + * Test of the Module interface. This should test both the general interface and all possible visibility * rules. */ public class ModuleTest http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/test/ASMTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/test/ASMTest.java b/core/runtime/src/test/java/org/qi4j/test/ASMTest.java index 797fc0a..9bda4cb 100644 --- a/core/runtime/src/test/java/org/qi4j/test/ASMTest.java +++ b/core/runtime/src/test/java/org/qi4j/test/ASMTest.java @@ -165,8 +165,8 @@ public class ASMTest MethodVisitor mv; AnnotationVisitor av0; - cw.visit( V1_6, ACC_PUBLIC + ACC_SUPER, "org/qi4j/satisfiedBy/SomeMixin_Stub", null, - "org/qi4j/satisfiedBy/SomeMixin", null ); + cw.visit( V1_6, ACC_PUBLIC + ACC_SUPER, "org/qi4j/test/SomeMixin_Stub", null, + "org/qi4j/test/SomeMixin", null ); { fv = cw.visitField( ACC_PUBLIC, "_instance", "Lorg/qi4j/spi/composite/CompositeInvoker;", null, null ); @@ -196,7 +196,7 @@ public class ASMTest mv = cw.visitMethod( ACC_PUBLIC, "<init>", "()V", null, null ); mv.visitCode(); mv.visitVarInsn( ALOAD, 0 ); - mv.visitMethodInsn( INVOKESPECIAL, "org/qi4j/satisfiedBy/SomeMixin", "<init>", "()V" ); + mv.visitMethodInsn( INVOKESPECIAL, "org/qi4j/test/SomeMixin", "<init>", "()V" ); mv.visitInsn( RETURN ); mv.visitMaxs( 1, 1 ); mv.visitEnd(); @@ -206,7 +206,7 @@ public class ASMTest mv.visitCode(); mv.visitVarInsn( ALOAD, 0 ); mv.visitVarInsn( ALOAD, 1 ); - mv.visitMethodInsn( INVOKESPECIAL, "org/qi4j/satisfiedBy/SomeMixin", "<init>", "(Ljava/lang/String;)V" ); + mv.visitMethodInsn( INVOKESPECIAL, "org/qi4j/test/SomeMixin", "<init>", "(Ljava/lang/String;)V" ); mv.visitInsn( RETURN ); mv.visitMaxs( 2, 2 ); mv.visitEnd(); @@ -220,9 +220,9 @@ public class ASMTest mv.visitTryCatchBlock( l0, l1, l2, "java/lang/Throwable" ); mv.visitLabel( l0 ); mv.visitVarInsn( ALOAD, 0 ); - mv.visitFieldInsn( GETFIELD, "org/qi4j/satisfiedBy/SomeMixin_Stub", "_instance", + mv.visitFieldInsn( GETFIELD, "org/qi4j/test/SomeMixin_Stub", "_instance", "Lorg/qi4j/spi/composite/CompositeInvoker;" ); - mv.visitFieldInsn( GETSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m1", "Ljava/lang/reflect/Method;" ); + mv.visitFieldInsn( GETSTATIC, "org/qi4j/test/SomeMixin_Stub", "m1", "Ljava/lang/reflect/Method;" ); mv.visitInsn( ACONST_NULL ); mv.visitMethodInsn( INVOKEINTERFACE, "org/qi4j/spi/composite/CompositeInvoker", "invokeComposite", "(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;" ); @@ -253,9 +253,9 @@ public class ASMTest mv.visitTryCatchBlock( l0, l1, l3, "java/lang/Throwable" ); mv.visitLabel( l0 ); mv.visitVarInsn( ALOAD, 0 ); - mv.visitFieldInsn( GETFIELD, "org/qi4j/satisfiedBy/SomeMixin_Stub", "_instance", + mv.visitFieldInsn( GETFIELD, "org/qi4j/test/SomeMixin_Stub", "_instance", "Lorg/qi4j/spi/composite/CompositeInvoker;" ); - mv.visitFieldInsn( GETSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m2", "Ljava/lang/reflect/Method;" ); + mv.visitFieldInsn( GETSTATIC, "org/qi4j/test/SomeMixin_Stub", "m2", "Ljava/lang/reflect/Method;" ); mv.visitInsn( ICONST_2 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Object" ); mv.visitInsn( DUP ); @@ -298,9 +298,9 @@ public class ASMTest mv.visitTryCatchBlock( l0, l1, l2, "java/lang/Throwable" ); mv.visitLabel( l0 ); mv.visitVarInsn( ALOAD, 0 ); - mv.visitFieldInsn( GETFIELD, "org/qi4j/satisfiedBy/SomeMixin_Stub", "_instance", + mv.visitFieldInsn( GETFIELD, "org/qi4j/test/SomeMixin_Stub", "_instance", "Lorg/qi4j/spi/composite/CompositeInvoker;" ); - mv.visitFieldInsn( GETSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m3", "Ljava/lang/reflect/Method;" ); + mv.visitFieldInsn( GETSTATIC, "org/qi4j/test/SomeMixin_Stub", "m3", "Ljava/lang/reflect/Method;" ); mv.visitIntInsn( BIPUSH, 11 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Object" ); mv.visitInsn( DUP ); @@ -378,21 +378,21 @@ public class ASMTest } { mv = cw.visitMethod( ACC_PUBLIC, "multiEx", "(Ljava/lang/String;)V", null, - new String[]{ "org/qi4j/satisfiedBy/Exception1", "org/qi4j/satisfiedBy/Exception2" } ); + new String[]{ "org/qi4j/test/Exception1", "org/qi4j/test/Exception2" } ); mv.visitCode(); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new Label(); - mv.visitTryCatchBlock( l0, l1, l2, "org/qi4j/satisfiedBy/Exception1" ); + mv.visitTryCatchBlock( l0, l1, l2, "org/qi4j/test/Exception1" ); Label l3 = new Label(); - mv.visitTryCatchBlock( l0, l1, l3, "org/qi4j/satisfiedBy/Exception2" ); + mv.visitTryCatchBlock( l0, l1, l3, "org/qi4j/test/Exception2" ); Label l4 = new Label(); mv.visitTryCatchBlock( l0, l1, l4, "java/lang/Throwable" ); mv.visitLabel( l0 ); mv.visitVarInsn( ALOAD, 0 ); - mv.visitFieldInsn( GETFIELD, "org/qi4j/satisfiedBy/SomeMixin_Stub", "_instance", + mv.visitFieldInsn( GETFIELD, "org/qi4j/test/SomeMixin_Stub", "_instance", "Lorg/qi4j/spi/composite/CompositeInvoker;" ); - mv.visitFieldInsn( GETSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m4", "Ljava/lang/reflect/Method;" ); + mv.visitFieldInsn( GETSTATIC, "org/qi4j/test/SomeMixin_Stub", "m4", "Ljava/lang/reflect/Method;" ); mv.visitInsn( ICONST_1 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Object" ); mv.visitInsn( DUP ); @@ -406,12 +406,12 @@ public class ASMTest Label l5 = new Label(); mv.visitJumpInsn( GOTO, l5 ); mv.visitLabel( l2 ); - mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "org/qi4j/satisfiedBy/Exception1" } ); + mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "org/qi4j/test/Exception1" } ); mv.visitVarInsn( ASTORE, 2 ); mv.visitVarInsn( ALOAD, 2 ); mv.visitInsn( ATHROW ); mv.visitLabel( l3 ); - mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "org/qi4j/satisfiedBy/Exception2" } ); + mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "org/qi4j/test/Exception2" } ); mv.visitVarInsn( ASTORE, 2 ); mv.visitVarInsn( ALOAD, 2 ); mv.visitInsn( ATHROW ); @@ -439,9 +439,9 @@ public class ASMTest mv.visitTryCatchBlock( l0, l1, l2, "java/lang/Throwable" ); mv.visitLabel( l0 ); mv.visitVarInsn( ALOAD, 0 ); - mv.visitFieldInsn( GETFIELD, "org/qi4j/satisfiedBy/SomeMixin_Stub", "_instance", + mv.visitFieldInsn( GETFIELD, "org/qi4j/test/SomeMixin_Stub", "_instance", "Lorg/qi4j/spi/composite/CompositeInvoker;" ); - mv.visitFieldInsn( GETSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m5", "Ljava/lang/reflect/Method;" ); + mv.visitFieldInsn( GETSTATIC, "org/qi4j/test/SomeMixin_Stub", "m5", "Ljava/lang/reflect/Method;" ); mv.visitInsn( ACONST_NULL ); mv.visitMethodInsn( INVOKEINTERFACE, "org/qi4j/spi/composite/CompositeInvoker", "invokeComposite", "(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;" ); @@ -469,14 +469,14 @@ public class ASMTest Label l2 = new Label(); mv.visitTryCatchBlock( l0, l1, l2, "java/lang/NoSuchMethodException" ); mv.visitLabel( l0 ); - mv.visitLdcInsn( Type.getType( "Lorg/qi4j/satisfiedBy/Other;" ) ); + mv.visitLdcInsn( Type.getType( "Lorg/qi4j/test/Other;" ) ); mv.visitLdcInsn( "other" ); mv.visitInsn( ICONST_0 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" ); mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;" ); - mv.visitFieldInsn( PUTSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m1", "Ljava/lang/reflect/Method;" ); - mv.visitLdcInsn( Type.getType( "Lorg/qi4j/satisfiedBy/Other;" ) ); + mv.visitFieldInsn( PUTSTATIC, "org/qi4j/test/SomeMixin_Stub", "m1", "Ljava/lang/reflect/Method;" ); + mv.visitLdcInsn( Type.getType( "Lorg/qi4j/test/Other;" ) ); mv.visitLdcInsn( "foo" ); mv.visitInsn( ICONST_2 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" ); @@ -490,8 +490,8 @@ public class ASMTest mv.visitInsn( AASTORE ); mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;" ); - mv.visitFieldInsn( PUTSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m2", "Ljava/lang/reflect/Method;" ); - mv.visitLdcInsn( Type.getType( "Lorg/qi4j/satisfiedBy/Other;" ) ); + mv.visitFieldInsn( PUTSTATIC, "org/qi4j/test/SomeMixin_Stub", "m2", "Ljava/lang/reflect/Method;" ); + mv.visitLdcInsn( Type.getType( "Lorg/qi4j/test/Other;" ) ); mv.visitLdcInsn( "bar" ); mv.visitIntInsn( BIPUSH, 11 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" ); @@ -541,8 +541,8 @@ public class ASMTest mv.visitInsn( AASTORE ); mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;" ); - mv.visitFieldInsn( PUTSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m3", "Ljava/lang/reflect/Method;" ); - mv.visitLdcInsn( Type.getType( "Lorg/qi4j/satisfiedBy/Other;" ) ); + mv.visitFieldInsn( PUTSTATIC, "org/qi4j/test/SomeMixin_Stub", "m3", "Ljava/lang/reflect/Method;" ); + mv.visitLdcInsn( Type.getType( "Lorg/qi4j/test/Other;" ) ); mv.visitLdcInsn( "multiEx" ); mv.visitInsn( ICONST_1 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" ); @@ -552,14 +552,14 @@ public class ASMTest mv.visitInsn( AASTORE ); mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;" ); - mv.visitFieldInsn( PUTSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m4", "Ljava/lang/reflect/Method;" ); - mv.visitLdcInsn( Type.getType( "Lorg/qi4j/satisfiedBy/Other;" ) ); + mv.visitFieldInsn( PUTSTATIC, "org/qi4j/test/SomeMixin_Stub", "m4", "Ljava/lang/reflect/Method;" ); + mv.visitLdcInsn( Type.getType( "Lorg/qi4j/test/Other;" ) ); mv.visitLdcInsn( "unwrapResult" ); mv.visitInsn( ICONST_0 ); mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" ); mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;" ); - mv.visitFieldInsn( PUTSTATIC, "org/qi4j/satisfiedBy/SomeMixin_Stub", "m5", "Ljava/lang/reflect/Method;" ); + mv.visitFieldInsn( PUTSTATIC, "org/qi4j/test/SomeMixin_Stub", "m5", "Ljava/lang/reflect/Method;" ); mv.visitLabel( l1 ); Label l3 = new Label(); mv.visitJumpInsn( GOTO, l3 ); http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/runtime/src/test/java/org/qi4j/test/composite/CleanStackTraceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/qi4j/test/composite/CleanStackTraceTest.java b/core/runtime/src/test/java/org/qi4j/test/composite/CleanStackTraceTest.java index 7d0d322..1c01597 100644 --- a/core/runtime/src/test/java/org/qi4j/test/composite/CleanStackTraceTest.java +++ b/core/runtime/src/test/java/org/qi4j/test/composite/CleanStackTraceTest.java @@ -35,7 +35,7 @@ import static org.junit.Assume.assumeTrue; /** * Test if the stacktrace is cleaned up properly. * <p> - * NOTE: This satisfiedBy MUST NOT be inside package org.qi4j.runtime, or it will fail. + * NOTE: This test MUST NOT be inside package org.qi4j.runtime, or it will fail. * </p> */ public class CleanStackTraceTest @@ -61,7 +61,7 @@ public class CleanStackTraceTest @Test public void cleanStackTraceOnApplicationException() { - // Don't run the satisfiedBy if compacttrace is set to anything else but proxy + // Don't run the test if compacttrace is set to anything else but proxy String compactTracePropertyValue = System.getProperty( "qi4j.compacttrace" ); if( compactTracePropertyValue != null && !"proxy".equals( compactTracePropertyValue ) ) { http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/spi/src/main/java/org/qi4j/spi/entity/QualifiedIdentity.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/qi4j/spi/entity/QualifiedIdentity.java b/core/spi/src/main/java/org/qi4j/spi/entity/QualifiedIdentity.java index 71defc5..0d846a9 100644 --- a/core/spi/src/main/java/org/qi4j/spi/entity/QualifiedIdentity.java +++ b/core/spi/src/main/java/org/qi4j/spi/entity/QualifiedIdentity.java @@ -61,9 +61,8 @@ public final class QualifiedIdentity public QualifiedIdentity( EntityComposite entityComposite ) { - this( entityComposite.identity().get(), first( Qi4j.FUNCTION_DESCRIPTOR_FOR - .map( entityComposite ) - .types() ).getName() ); + this( entityComposite.identity().get(), + first( Qi4j.FUNCTION_DESCRIPTOR_FOR.apply( entityComposite ).types() ).getName() ); } public QualifiedIdentity( String identity, Class<?> clazz ) http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/DefaultEntityState.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/DefaultEntityState.java b/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/DefaultEntityState.java index e7938c3..178ecc6 100644 --- a/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/DefaultEntityState.java +++ b/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/DefaultEntityState.java @@ -213,7 +213,7 @@ public final class DefaultEntityState @Override public boolean isAssignableTo( Class<?> type ) { - return Classes.exactTypeSpecification( type ).satisfiedBy( entityDescriptor ); + return Classes.exactTypeSpecification( type ).test( entityDescriptor ); } @Override http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/spi/src/main/java/org/qi4j/spi/query/EntityFinder.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/qi4j/spi/query/EntityFinder.java b/core/spi/src/main/java/org/qi4j/spi/query/EntityFinder.java index d00a99d..8a53a1b 100644 --- a/core/spi/src/main/java/org/qi4j/spi/query/EntityFinder.java +++ b/core/spi/src/main/java/org/qi4j/spi/query/EntityFinder.java @@ -19,11 +19,11 @@ package org.qi4j.spi.query; import java.util.Map; +import java.util.function.Predicate; import org.qi4j.api.common.Optional; import org.qi4j.api.composite.Composite; import org.qi4j.api.entity.EntityReference; import org.qi4j.api.query.grammar.OrderBy; -import org.qi4j.functional.Specification; /** * Entity Finder. @@ -42,7 +42,7 @@ public interface EntityFinder * @return Single entity matching the query criterion. */ Iterable<EntityReference> findEntities( Class<?> resultType, - @Optional Specification<Composite> whereClause, + @Optional Predicate<Composite> whereClause, @Optional OrderBy[] orderBySegments, @Optional Integer firstResult, @Optional Integer maxResults, @@ -59,7 +59,7 @@ public interface EntityFinder * @return Single entity matching the query criterion. */ EntityReference findEntity( Class<?> resultType, - @Optional Specification<Composite> whereClause, + @Optional Predicate<Composite> whereClause, Map<String, Object> variables ) throws EntityFinderException; @@ -73,7 +73,7 @@ public interface EntityFinder * @return Count entities matching the query criterion. */ long countEntities( Class<?> resultType, - @Optional Specification<Composite> whereClause, + @Optional Predicate<Composite> whereClause, Map<String, Object> variables ) throws EntityFinderException; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/spi/src/main/java/org/qi4j/spi/query/QuerySource.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/qi4j/spi/query/QuerySource.java b/core/spi/src/main/java/org/qi4j/spi/query/QuerySource.java index 35a3661..15894b7 100644 --- a/core/spi/src/main/java/org/qi4j/spi/query/QuerySource.java +++ b/core/spi/src/main/java/org/qi4j/spi/query/QuerySource.java @@ -2,9 +2,9 @@ package org.qi4j.spi.query; import java.util.Iterator; import java.util.Map; +import java.util.function.Predicate; import org.qi4j.api.composite.Composite; import org.qi4j.api.query.grammar.OrderBy; -import org.qi4j.functional.Specification; /** * Query Source, used in QueryBuilder SPI. @@ -12,7 +12,7 @@ import org.qi4j.functional.Specification; public interface QuerySource { <T> T find( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -20,7 +20,7 @@ public interface QuerySource ); <T> long count( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, @@ -28,7 +28,7 @@ public interface QuerySource ); <T> Iterator<T> iterator( Class<T> resultType, - Specification<Composite> whereClause, + Predicate<Composite> whereClause, Iterable<OrderBy> orderBySegments, Integer firstResult, Integer maxResults, http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/9479a63e/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java index 73056fe..ce01787 100644 --- a/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java +++ b/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java @@ -32,6 +32,8 @@ import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; +import java.util.function.BiFunction; +import java.util.function.Function; import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.joda.time.LocalDateTime; @@ -54,8 +56,6 @@ import org.qi4j.api.value.ValueBuilder; import org.qi4j.api.value.ValueDescriptor; import org.qi4j.api.value.ValueDeserializer; import org.qi4j.api.value.ValueSerializationException; -import org.qi4j.functional.Function; -import org.qi4j.functional.Function2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -158,7 +158,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( String.class, new Function<Object, String>() { @Override - public String map( Object input ) + public String apply( Object input ) { return input.toString(); } @@ -166,7 +166,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Character.class, new Function<Object, Character>() { @Override - public Character map( Object input ) + public Character apply( Object input ) { return input.toString().charAt( 0 ); } @@ -174,7 +174,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Boolean.class, new Function<Object, Boolean>() { @Override - public Boolean map( Object input ) + public Boolean apply( Object input ) { return ( input instanceof String ) ? Boolean.parseBoolean( (String) input ) @@ -184,7 +184,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Integer.class, new Function<Object, Integer>() { @Override - public Integer map( Object input ) + public Integer apply( Object input ) { return ( input instanceof String ) ? Integer.parseInt( (String) input ) @@ -194,7 +194,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Long.class, new Function<Object, Long>() { @Override - public Long map( Object input ) + public Long apply( Object input ) { return ( input instanceof String ) ? Long.parseLong( (String) input ) @@ -204,7 +204,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Short.class, new Function<Object, Short>() { @Override - public Short map( Object input ) + public Short apply( Object input ) { return ( input instanceof String ) ? Short.parseShort( (String) input ) @@ -214,7 +214,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Byte.class, new Function<Object, Byte>() { @Override - public Byte map( Object input ) + public Byte apply( Object input ) { return ( input instanceof String ) ? Byte.parseByte( (String) input ) @@ -224,7 +224,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Float.class, new Function<Object, Float>() { @Override - public Float map( Object input ) + public Float apply( Object input ) { return ( input instanceof String ) ? Float.parseFloat( (String) input ) @@ -234,7 +234,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Double.class, new Function<Object, Double>() { @Override - public Double map( Object input ) + public Double apply( Object input ) { return ( input instanceof String ) ? Double.parseDouble( (String) input ) @@ -246,7 +246,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( BigDecimal.class, new Function<Object, BigDecimal>() { @Override - public BigDecimal map( Object input ) + public BigDecimal apply( Object input ) { return new BigDecimal( input.toString() ); } @@ -254,7 +254,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( BigInteger.class, new Function<Object, BigInteger>() { @Override - public BigInteger map( Object input ) + public BigInteger apply( Object input ) { return new BigInteger( input.toString() ); } @@ -264,7 +264,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( Date.class, new Function<Object, Date>() { @Override - public Date map( Object input ) + public Date apply( Object input ) { return Dates.fromString( input.toString() ); } @@ -272,7 +272,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( DateTime.class, new Function<Object, DateTime>() { @Override - public DateTime map( Object input ) + public DateTime apply( Object input ) { return DateTime.parse( input.toString() ); } @@ -280,7 +280,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( LocalDateTime.class, new Function<Object, LocalDateTime>() { @Override - public LocalDateTime map( Object input ) + public LocalDateTime apply( Object input ) { return new LocalDateTime( input ); } @@ -288,7 +288,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( LocalDate.class, new Function<Object, LocalDate>() { @Override - public LocalDate map( Object input ) + public LocalDate apply( Object input ) { return new LocalDate( input ); } @@ -298,7 +298,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> registerDeserializer( EntityReference.class, new Function<Object, EntityReference>() { @Override - public EntityReference map( Object input ) + public EntityReference apply( Object input ) { return EntityReference.parseEntityReference( input.toString() ); } @@ -326,7 +326,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> } else { - valuesModule = valuesModuleFinder.map( application ); + valuesModule = valuesModuleFinder.apply( application ); if( valuesModule == null ) { throw new ValueSerializationException( "Values Module provided by the finder Function was null." ); @@ -356,23 +356,16 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> @Override public final <T> Function<String, T> deserialize( final ValueType valueType ) { - return new Function<String, T>() - { - @Override - public T map( String input ) - { - return deserialize( valueType, input ); - } - }; + return input -> deserialize( valueType, input ); } @Override - public final <T> Function2<ValueType, String, T> deserialize() + public final <T> BiFunction<ValueType, String, T> deserialize() { - return new Function2<ValueType, String, T>() + return new BiFunction<ValueType, String, T>() { @Override - public T map( ValueType valueType, String input ) + public T apply( ValueType valueType, String input ) { return deserialize( valueType, input ); } @@ -463,7 +456,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> return String.class.equals( type ) ? (T) "" : null; } String string = scanner.next(); - return (T) deserializers.get( type ).map( string ); + return (T) deserializers.get( type ).apply( string ); } else // Array ValueType if( type.isArray() ) @@ -499,7 +492,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> { return null; } - return (T) deserializers.get( type ).map( value ); + return (T) deserializers.get( type ).apply( value ); } else if( complexDeserializers.get( type ) != null ) { @@ -544,7 +537,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> return new Function<InputType, T>() { @Override - public T map( InputType input ) + public T apply( InputType input ) { try { @@ -739,7 +732,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> return new Function<InputNodeType, T>() { @Override - public T map( InputNodeType inputNode ) + public T apply( InputNodeType inputNode ) { try { @@ -777,7 +770,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> { return null; } - return (T) deserializers.get( type ).map( value ); + return (T) deserializers.get( type ).apply( value ); } else if( complexDeserializers.get( type ) != null ) { @@ -822,7 +815,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> new Function<PropertyDescriptor, Object>() { @Override - public Object map( PropertyDescriptor property ) + public Object apply( PropertyDescriptor property ) { return stateMap.get( property.qualifiedName().name() ); } @@ -830,7 +823,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> new Function<AssociationDescriptor, EntityReference>() { @Override - public EntityReference map( AssociationDescriptor association ) + public EntityReference apply( AssociationDescriptor association ) { Object entityRef = stateMap.get( association.qualifiedName().name() ); if( entityRef == null ) @@ -844,7 +837,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> { @Override @SuppressWarnings( "unchecked" ) - public Iterable<EntityReference> map( AssociationDescriptor manyAssociation ) + public Iterable<EntityReference> apply( AssociationDescriptor manyAssociation ) { Object entityRefs = stateMap.get( manyAssociation.qualifiedName().name() ); if( entityRefs == null ) @@ -858,7 +851,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType> { @Override @SuppressWarnings( "unchecked" ) - public Map<String, EntityReference> map( AssociationDescriptor namedAssociation ) + public Map<String, EntityReference> apply( AssociationDescriptor namedAssociation ) { Object entityRefs = stateMap.get( namedAssociation.qualifiedName().name() ); if( entityRefs == null )
