polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kent Sølvsten <kent.soelvs...@gmail.com>
Subject Re: zest-java git commit: Annotations#findAccessorAndTypeAnnotations now returns list to avoid reuse-of-stream trap
Date Thu, 27 Aug 2015 04:30:09 GMT
oops - sorry.

Had to upgrade to a newer Intellij due to too many java8 problems - and
the new version was using "IDE-default" codestyle from the beginning.

Den 27-08-2015 kl. 02:51 skrev Niclas Hedhman:
> Kent, please change your IDE settings so that;
>
> Full import list is always used, and not
> import java.util.*;
>
> And that the imports are fully alphabetical, i.e. no special treatment of
> java.*. The reason for this was that it was impossible to get any other
> consistent behavior across 3 IDEs.
>
> Thanks
> Niclas
>
> On Thu, Aug 27, 2015 at 6:11 AM, <soelvsten@apache.org> wrote:
>
>> Repository: zest-java
>> Updated Branches:
>>   refs/heads/develop bd6fbad9f -> 987eb0e60
>>
>>
>> Annotations#findAccessorAndTypeAnnotations now returns list to avoid
>> reuse-of-stream trap
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/987eb0e6
>> Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/987eb0e6
>> Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/987eb0e6
>>
>> Branch: refs/heads/develop
>> Commit: 987eb0e6013585f6a13d7d92f234568b5c72dcf3
>> Parents: bd6fbad
>> Author: Kent Sølvsten <soelvsten@apache.org>
>> Authored: Thu Aug 27 00:11:24 2015 +0200
>> Committer: Kent Sølvsten <soelvsten@apache.org>
>> Committed: Thu Aug 27 00:11:24 2015 +0200
>>
>> ----------------------------------------------------------------------
>>  .../org/apache/zest/api/util/Annotations.java   | 16 ++--
>>  .../bootstrap/CompositeAssemblyImpl.java        | 81 +++++---------------
>>  .../runtime/bootstrap/EntityAssemblyImpl.java   | 63 ++++++---------
>>  .../runtime/bootstrap/ValueAssemblyImpl.java    | 54 ++++++-------
>>  4 files changed, 75 insertions(+), 139 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/zest-java/blob/987eb0e6/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
>> b/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
>> old mode 100644
>> new mode 100755
>> index 529b358..f94fa56
>> --- a/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
>> +++ b/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
>> @@ -19,8 +19,11 @@ import java.lang.reflect.AccessibleObject;
>>  import java.lang.reflect.AnnotatedElement;
>>  import java.lang.reflect.Type;
>>  import java.util.Arrays;
>> +import java.util.List;
>>  import java.util.function.Function;
>>  import java.util.function.Predicate;
>> +import java.util.stream.Collector;
>> +import java.util.stream.Collectors;
>>  import java.util.stream.Stream;
>>
>>  import static org.apache.zest.api.util.Classes.interfacesOf;
>> @@ -55,13 +58,12 @@ public final class Annotations
>>          return annotationType.cast( Classes.RAW_CLASS.apply( type
>> ).getAnnotation( annotationType ) );
>>      }
>>
>> -    public static Stream<Annotation> findAccessorAndTypeAnnotationsIn(
>> AccessibleObject accessor )
>> -    {
>> -        return Stream.concat(
>> -            Arrays.stream( accessor.getAnnotations() ),
>> -            interfacesOf( typeOf( accessor ) ).flatMap( ANNOTATIONS_OF )
>> +    public static List<Annotation>
>> findAccessorAndTypeAnnotationsIn(AccessibleObject accessor) {
>> +        Stream<Annotation> stream = Stream.concat(
>> +                Arrays.stream(accessor.getAnnotations()),
>> +                interfacesOf(typeOf(accessor)).flatMap(ANNOTATIONS_OF)
>>          );
>> -//        return flatten( iterable( accessor.getAnnotations() ),
>> -//                        flattenIterables( map(
>> Annotations.ANNOTATIONS_OF, interfacesOf( typeOf( accessor ) ) ) ) );
>> +        Collector<Annotation, ?, List<Annotation>> collector =
>> Collectors.toList();
>> +        return stream.collect(collector);
>>      }
>>  }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/zest-java/blob/987eb0e6/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
>> old mode 100644
>> new mode 100755
>> index 01c0d75..05c6f66
>> ---
>> 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
>> @@ -18,30 +18,8 @@
>>   */
>>  package org.apache.zest.runtime.bootstrap;
>>
>> -import java.lang.annotation.Annotation;
>> -import java.lang.reflect.AccessibleObject;
>> -import java.lang.reflect.Field;
>> -import java.lang.reflect.InvocationHandler;
>> -import java.lang.reflect.Member;
>> -import java.lang.reflect.Method;
>> -import java.lang.reflect.Modifier;
>> -import java.lang.reflect.Proxy;
>> -import java.lang.reflect.Type;
>> -import java.util.ArrayList;
>> -import java.util.Arrays;
>> -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.Predicate;
>> -import java.util.stream.Collectors;
>> -import java.util.stream.Stream;
>> -import org.apache.zest.api.common.MetaInfo;
>> +import org.apache.zest.api.common.*;
>>  import org.apache.zest.api.common.Optional;
>> -import org.apache.zest.api.common.QualifiedName;
>> -import org.apache.zest.api.common.UseDefaults;
>> -import org.apache.zest.api.common.Visibility;
>>  import org.apache.zest.api.composite.InvalidCompositeException;
>>  import org.apache.zest.api.concern.Concerns;
>>  import org.apache.zest.api.constraint.Constraint;
>> @@ -63,40 +41,24 @@ 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.HierarchicalVisitorAdapter;
>> -import org.apache.zest.runtime.composite.AbstractConstraintModel;
>> -import org.apache.zest.runtime.composite.CompositeConstraintModel;
>> -import org.apache.zest.runtime.composite.CompositeMethodModel;
>> -import org.apache.zest.runtime.composite.CompositeMethodsModel;
>> -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.Genericpredicate;
>> -import org.apache.zest.runtime.composite.MixinModel;
>> -import org.apache.zest.runtime.composite.MixinsModel;
>> -import org.apache.zest.runtime.composite.SideEffectModel;
>> -import org.apache.zest.runtime.composite.SideEffectsModel;
>> -import org.apache.zest.runtime.composite.StateModel;
>> -import org.apache.zest.runtime.composite.ValueConstraintsInstance;
>> -import org.apache.zest.runtime.composite.ValueConstraintsModel;
>> +import org.apache.zest.runtime.composite.*;
>>  import org.apache.zest.runtime.injection.Dependencies;
>>  import org.apache.zest.runtime.injection.DependencyModel;
>>  import org.apache.zest.runtime.property.PropertiesModel;
>>  import org.apache.zest.runtime.property.PropertyModel;
>>
>> +import java.lang.annotation.Annotation;
>> +import java.lang.reflect.*;
>> +import java.util.*;
>> +import java.util.function.Consumer;
>> +import java.util.function.Predicate;
>> +import java.util.stream.Collectors;
>> +import java.util.stream.Stream;
>> +
>>  import static java.util.stream.Stream.concat;
>> -import static org.apache.zest.api.util.Annotations.hasAnnotation;
>> -import static org.apache.zest.api.util.Annotations.isType;
>> -import static org.apache.zest.api.util.Annotations.type;
>> -import static org.apache.zest.api.util.Classes.classHierarchy;
>> -import static org.apache.zest.api.util.Classes.interfacesOf;
>> -import static org.apache.zest.api.util.Classes.isAssignableFrom;
>> -import static org.apache.zest.api.util.Classes.typeOf;
>> -import static org.apache.zest.api.util.Classes.typesOf;
>> -import static org.apache.zest.api.util.Classes.wrapperClass;
>> -import static org.apache.zest.functional.Iterables.filter;
>> -import static org.apache.zest.functional.Iterables.first;
>> -import static org.apache.zest.functional.Iterables.iterable;
>> +import static org.apache.zest.api.util.Annotations.*;
>> +import static org.apache.zest.api.util.Classes.*;
>> +import static org.apache.zest.functional.Iterables.*;
>>  import static org.apache.zest.runtime.legacy.Specifications.translate;
>>
>>  /**
>> @@ -427,16 +389,15 @@ public abstract class CompositeAssemblyImpl
>>                                                List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> -        annotations = Annotations.findAccessorAndTypeAnnotationsIn(
>> accessor );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional =
>> annotations.stream().anyMatch(isType(Optional.class));
>>          ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> -            annotations,
>> -            GenericPropertyInfo.propertyTypeOf( accessor ),
>> -            ( (Member) accessor ).getName(),
>> -            optional,
>> -            constraintClasses,
>> -            accessor );
>> +                annotations.stream(),
>> +                GenericPropertyInfo.propertyTypeOf(accessor),
>> +                ((Member) accessor).getName(),
>> +                optional,
>> +                constraintClasses,
>> +                accessor);
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>>
>>
>> http://git-wip-us.apache.org/repos/asf/zest-java/blob/987eb0e6/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
>> b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
>> old mode 100644
>> new mode 100755
>> index 473ab07..a9e92fa
>> ---
>> a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
>> +++
>> b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
>> @@ -18,37 +18,19 @@
>>   */
>>  package org.apache.zest.runtime.bootstrap;
>>
>> -import java.lang.annotation.Annotation;
>> -import java.lang.reflect.AccessibleObject;
>> -import java.lang.reflect.Member;
>> -import java.util.List;
>> -import java.util.stream.Stream;
>>  import org.apache.zest.api.association.Association;
>>  import org.apache.zest.api.association.GenericAssociationInfo;
>>  import org.apache.zest.api.association.ManyAssociation;
>>  import org.apache.zest.api.association.NamedAssociation;
>> -import org.apache.zest.api.common.InvalidApplicationException;
>> -import org.apache.zest.api.common.MetaInfo;
>> -import org.apache.zest.api.common.Optional;
>> -import org.apache.zest.api.common.QualifiedName;
>> -import org.apache.zest.api.common.UseDefaults;
>> +import org.apache.zest.api.common.*;
>>  import org.apache.zest.api.entity.EntityComposite;
>>  import org.apache.zest.api.property.GenericPropertyInfo;
>>  import org.apache.zest.api.property.Immutable;
>>  import org.apache.zest.api.property.Property;
>>  import org.apache.zest.api.util.Annotations;
>>  import org.apache.zest.api.util.Classes;
>> -import org.apache.zest.bootstrap.AssociationDeclarations;
>> -import org.apache.zest.bootstrap.EntityAssembly;
>> -import org.apache.zest.bootstrap.ManyAssociationDeclarations;
>> -import org.apache.zest.bootstrap.NamedAssociationDeclarations;
>> -import org.apache.zest.bootstrap.StateDeclarations;
>> -import org.apache.zest.runtime.association.AssociationModel;
>> -import org.apache.zest.runtime.association.AssociationsModel;
>> -import org.apache.zest.runtime.association.ManyAssociationModel;
>> -import org.apache.zest.runtime.association.ManyAssociationsModel;
>> -import org.apache.zest.runtime.association.NamedAssociationModel;
>> -import org.apache.zest.runtime.association.NamedAssociationsModel;
>> +import org.apache.zest.bootstrap.*;
>> +import org.apache.zest.runtime.association.*;
>>  import org.apache.zest.runtime.composite.MixinsModel;
>>  import org.apache.zest.runtime.composite.StateModel;
>>  import org.apache.zest.runtime.composite.ValueConstraintsInstance;
>> @@ -58,6 +40,11 @@ import org.apache.zest.runtime.entity.EntityModel;
>>  import org.apache.zest.runtime.entity.EntityStateModel;
>>  import org.apache.zest.runtime.property.PropertyModel;
>>
>> +import java.lang.annotation.Annotation;
>> +import java.lang.reflect.AccessibleObject;
>> +import java.lang.reflect.Member;
>> +import java.util.List;
>> +
>>  import static org.apache.zest.api.util.Annotations.isType;
>>  import static org.apache.zest.api.util.Classes.typeOf;
>>
>> @@ -163,10 +150,9 @@ public final class EntityAssemblyImpl
>>                                                List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> -        annotations = Annotations.findAccessorAndTypeAnnotationsIn(
>> accessor );
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member)
>> accessor )
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional = annotations.stream().anyMatch( isType(
>> Optional.class ) );
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericPropertyInfo.propertyTypeOf( accessor ), (
>> (Member) accessor )
>>              .getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -184,12 +170,11 @@ public final class EntityAssemblyImpl
>>                                                   Iterable<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> -        annotations = Annotations.findAccessorAndTypeAnnotationsIn(
>> accessor );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional =
>> annotations.stream().anyMatch(isType(Optional.class));
>>
>>          // Constraints for Association references
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericAssociationInfo
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericAssociationInfo
>>              .associationTypeOf( accessor ), ( (Member) accessor
>> ).getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -198,7 +183,7 @@ public final class EntityAssemblyImpl
>>          }
>>
>>          // Constraints for the Association itself
>> -        valueConstraintsModel = constraintsFor( annotations,
>> Association.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>> +        valueConstraintsModel = constraintsFor( annotations.stream(),
>> Association.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>>          ValueConstraintsInstance associationValueConstraintsInstance =
>> null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>> @@ -213,12 +198,11 @@ public final class EntityAssemblyImpl
>>                                                           List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> -        annotations = Annotations.findAccessorAndTypeAnnotationsIn(
>> accessor );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional =
>> annotations.stream().anyMatch(isType(Optional.class));
>>
>>          // Constraints for entities in ManyAssociation
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericAssociationInfo
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericAssociationInfo
>>              .associationTypeOf( accessor ), ( (Member) accessor
>> ).getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -227,7 +211,7 @@ public final class EntityAssemblyImpl
>>          }
>>
>>          // Constraints for the ManyAssociation itself
>> -        valueConstraintsModel = constraintsFor( annotations,
>> ManyAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>> +        valueConstraintsModel = constraintsFor( annotations.stream(),
>> ManyAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>>          ValueConstraintsInstance manyValueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>> @@ -241,12 +225,11 @@ public final class EntityAssemblyImpl
>>                                                             List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> -        annotations = Annotations.findAccessorAndTypeAnnotationsIn(
>> accessor );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional = annotations.stream().anyMatch( isType(
>> Optional.class ) );
>>
>>          // Constraints for entities in NamedAssociation
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericAssociationInfo
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericAssociationInfo
>>              .associationTypeOf( accessor ), ( (Member) accessor
>> ).getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -255,7 +238,7 @@ public final class EntityAssemblyImpl
>>          }
>>
>>          // Constraints for the NamedAssociation itself
>> -        valueConstraintsModel = constraintsFor( annotations,
>> NamedAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>> +        valueConstraintsModel = constraintsFor( annotations.stream(),
>> NamedAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>>          ValueConstraintsInstance namedValueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>>
>>
>> http://git-wip-us.apache.org/repos/asf/zest-java/blob/987eb0e6/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
>> b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
>> old mode 100644
>> new mode 100755
>> index 38e3b2c..80d692f
>> ---
>> a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
>> +++
>> b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
>> @@ -18,20 +18,11 @@
>>   */
>>  package org.apache.zest.runtime.bootstrap;
>>
>> -import java.lang.annotation.Annotation;
>> -import java.lang.reflect.AccessibleObject;
>> -import java.lang.reflect.Member;
>> -import java.util.List;
>> -import java.util.stream.Stream;
>>  import org.apache.zest.api.association.Association;
>>  import org.apache.zest.api.association.GenericAssociationInfo;
>>  import org.apache.zest.api.association.ManyAssociation;
>>  import org.apache.zest.api.association.NamedAssociation;
>> -import org.apache.zest.api.common.InvalidApplicationException;
>> -import org.apache.zest.api.common.MetaInfo;
>> -import org.apache.zest.api.common.Optional;
>> -import org.apache.zest.api.common.QualifiedName;
>> -import org.apache.zest.api.common.UseDefaults;
>> +import org.apache.zest.api.common.*;
>>  import org.apache.zest.api.property.GenericPropertyInfo;
>>  import org.apache.zest.api.property.Property;
>>  import org.apache.zest.api.util.Annotations;
>> @@ -39,12 +30,7 @@ import org.apache.zest.api.util.Classes;
>>  import org.apache.zest.api.value.ValueComposite;
>>  import org.apache.zest.bootstrap.StateDeclarations;
>>  import org.apache.zest.bootstrap.ValueAssembly;
>> -import org.apache.zest.runtime.association.AssociationModel;
>> -import org.apache.zest.runtime.association.AssociationsModel;
>> -import org.apache.zest.runtime.association.ManyAssociationModel;
>> -import org.apache.zest.runtime.association.ManyAssociationsModel;
>> -import org.apache.zest.runtime.association.NamedAssociationModel;
>> -import org.apache.zest.runtime.association.NamedAssociationsModel;
>> +import org.apache.zest.runtime.association.*;
>>  import org.apache.zest.runtime.composite.StateModel;
>>  import org.apache.zest.runtime.composite.ValueConstraintsInstance;
>>  import org.apache.zest.runtime.composite.ValueConstraintsModel;
>> @@ -52,6 +38,11 @@ import org.apache.zest.runtime.property.PropertyModel;
>>  import org.apache.zest.runtime.value.ValueModel;
>>  import org.apache.zest.runtime.value.ValueStateModel;
>>
>> +import java.lang.annotation.Annotation;
>> +import java.lang.reflect.AccessibleObject;
>> +import java.lang.reflect.Member;
>> +import java.util.List;
>> +
>>  import static org.apache.zest.api.util.Annotations.isType;
>>  import static org.apache.zest.api.util.Classes.typeOf;
>>
>> @@ -143,10 +134,9 @@ public final class ValueAssemblyImpl
>>                                                List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> -        annotations = Annotations.findAccessorAndTypeAnnotationsIn(
>> accessor );
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member)
>> accessor )
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional = annotations.stream().anyMatch( isType(
>> Optional.class ) );
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericPropertyInfo.propertyTypeOf( accessor ), (
>> (Member) accessor )
>>              .getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -163,11 +153,11 @@ public final class ValueAssemblyImpl
>>                                                   List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional = annotations.stream().anyMatch( isType(
>> Optional.class ) );
>>
>>          // Constraints for Association references
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericAssociationInfo
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericAssociationInfo
>>              .associationTypeOf( accessor ), ( (Member) accessor
>> ).getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -176,7 +166,7 @@ public final class ValueAssemblyImpl
>>          }
>>
>>          // Constraints for the Association itself
>> -        valueConstraintsModel = constraintsFor( annotations,
>> Association.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>> +        valueConstraintsModel = constraintsFor( annotations.stream(),
>> Association.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>>          ValueConstraintsInstance associationValueConstraintsInstance =
>> null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>> @@ -191,11 +181,11 @@ public final class ValueAssemblyImpl
>>                                                           List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional = annotations.stream().anyMatch( isType(
>> Optional.class ) );
>>
>>          // Constraints for entities in ManyAssociation
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericAssociationInfo
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericAssociationInfo
>>              .associationTypeOf( accessor ), ( (Member) accessor
>> ).getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -204,7 +194,7 @@ public final class ValueAssemblyImpl
>>          }
>>
>>          // Constraints for the ManyAssociation itself
>> -        valueConstraintsModel = constraintsFor( annotations,
>> ManyAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>> +        valueConstraintsModel = constraintsFor( annotations.stream(),
>> ManyAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>>          ValueConstraintsInstance manyValueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>> @@ -218,11 +208,11 @@ public final class ValueAssemblyImpl
>>                                                             List<Class<?>>
>> constraintClasses
>>      )
>>      {
>> -        Stream<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn( accessor );
>> -        boolean optional = annotations.anyMatch( isType( Optional.class )
>> );
>> +        List<Annotation> annotations =
>> Annotations.findAccessorAndTypeAnnotationsIn(accessor);
>> +        boolean optional = annotations.stream().anyMatch( isType(
>> Optional.class ) );
>>
>>          // Constraints for entities in NamedAssociation
>> -        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations, GenericAssociationInfo
>> +        ValueConstraintsModel valueConstraintsModel = constraintsFor(
>> annotations.stream(), GenericAssociationInfo
>>              .associationTypeOf( accessor ), ( (Member) accessor
>> ).getName(), optional, constraintClasses, accessor );
>>          ValueConstraintsInstance valueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>> @@ -231,7 +221,7 @@ public final class ValueAssemblyImpl
>>          }
>>
>>          // Constraints for the NamedAssociation itself
>> -        valueConstraintsModel = constraintsFor( annotations,
>> NamedAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>> +        valueConstraintsModel = constraintsFor( annotations.stream(),
>> NamedAssociation.class, ( (Member) accessor ).getName(), optional,
>> constraintClasses, accessor );
>>          ValueConstraintsInstance namedValueConstraintsInstance = null;
>>          if( valueConstraintsModel.isConstrained() )
>>          {
>>
>>
>


Mime
View raw message