{
Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
// Constraints for entities in NamedAssociation
ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
.associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
ValueConstraintsInstance valueConstraintsInstance = null;
if( valueConstraintsModel.isConstrained() )
{
valueConstraintsInstance = valueConstraintsModel.newInstance();
}
// Constraints for the NamedAssociation itself
valueConstraintsModel = constraintsFor( annotations, NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
ValueConstraintsInstance namedValueConstraintsInstance = null;
if( valueConstraintsModel.isConstrained() )
{
namedValueConstraintsInstance = valueConstraintsModel.newInstance();
}
MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
NamedAssociationModel associationModel = new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
return associationModel;
}