use of org.qi4j.api.common.MetaInfo in project qi4j-sdk by Qi4j.
the class EntityAssemblyImpl method newManyAssociationModel.
public ManyAssociationModel newManyAssociationModel(AccessibleObject accessor, Iterable<Class<? extends Constraint<?, ?>>> constraintClasses) {
Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
boolean optional = first(filter(isType(Optional.class), annotations)) != null;
// Constraints for entities in ManyAssociation
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 ManyAssociation itself
valueConstraintsModel = constraintsFor(annotations, ManyAssociation.class, ((Member) accessor).getName(), optional, constraintClasses, accessor);
ValueConstraintsInstance manyValueConstraintsInstance = null;
if (valueConstraintsModel.isConstrained()) {
manyValueConstraintsInstance = valueConstraintsModel.newInstance();
}
MetaInfo metaInfo = manyAssociationDeclarations.metaInfoFor(accessor);
ManyAssociationModel associationModel = new ManyAssociationModel(accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo);
return associationModel;
}
use of org.qi4j.api.common.MetaInfo in project qi4j-sdk by Qi4j.
the class ImportedServiceAssemblyImpl method addImportedServiceModel.
@SuppressWarnings({ "raw", "unchecked" })
void addImportedServiceModel(List<ImportedServiceModel> serviceModels) {
try {
String id = identity;
if (id == null) {
id = generateId(serviceModels, serviceType);
}
ImportedServiceModel serviceModel = new ImportedServiceModel(serviceType, visibility, serviceProvider, id, importOnStartup, new MetaInfo(metaInfo).withAnnotations(serviceType), new ActivatorsModel(activators), moduleAssembly.name());
serviceModels.add(serviceModel);
} catch (Exception e) {
throw new InvalidApplicationException("Could not register " + serviceType.getName(), e);
}
}
use of org.qi4j.api.common.MetaInfo in project qi4j-sdk by Qi4j.
the class ValueAssemblyImpl method newManyAssociationModel.
public ManyAssociationModel newManyAssociationModel(AccessibleObject accessor, Iterable<Class<? extends Constraint<?, ?>>> constraintClasses) {
Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
boolean optional = first(filter(isType(Optional.class), annotations)) != null;
// Constraints for entities in ManyAssociation
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 ManyAssociation itself
valueConstraintsModel = constraintsFor(annotations, ManyAssociation.class, ((Member) accessor).getName(), optional, constraintClasses, accessor);
ValueConstraintsInstance manyValueConstraintsInstance = null;
if (valueConstraintsModel.isConstrained()) {
manyValueConstraintsInstance = valueConstraintsModel.newInstance();
}
MetaInfo metaInfo = stateDeclarations.metaInfoFor(accessor);
ManyAssociationModel associationModel = new ManyAssociationModel(accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo);
return associationModel;
}
use of org.qi4j.api.common.MetaInfo in project qi4j-sdk by Qi4j.
the class CompositeAssemblyImpl method buildComposite.
protected void buildComposite(AssemblyHelper helper, StateDeclarations stateDeclarations) {
this.stateDeclarations = stateDeclarations;
this.helper = helper;
for (Class<?> compositeType : types) {
metaInfo = new MetaInfo(metaInfo).withAnnotations(compositeType);
addAnnotationsMetaInfo(compositeType, metaInfo);
}
immutable = metaInfo.get(Immutable.class) != null;
propertiesModel = new PropertiesModel();
stateModel = createStateModel();
mixinsModel = createMixinsModel();
compositeMethodsModel = new CompositeMethodsModel(mixinsModel);
// Implement composite methods
ArrayList<Type> allTypes = getTypes(this.types);
Iterable<Class<? extends Constraint<?, ?>>> constraintClasses = constraintDeclarations(getTypes(this.types));
Iterable<Class<?>> concernClasses = flatten(concerns, concernDeclarations(allTypes));
Iterable<Class<?>> sideEffectClasses = flatten(sideEffects, sideEffectDeclarations(allTypes));
Iterable<Class<?>> mixinClasses = flatten(mixins, mixinDeclarations(this.types));
implementMixinType(types, constraintClasses, concernClasses, sideEffectClasses, mixinClasses);
// Add state from methods and fields
addState(constraintClasses);
}
use of org.qi4j.api.common.MetaInfo in project qi4j-sdk by Qi4j.
the class CompositeAssemblyImpl method newPropertyModel.
protected PropertyModel newPropertyModel(AccessibleObject accessor, Iterable<Class<? extends Constraint<?, ?>>> constraintClasses) {
Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
boolean optional = first(filter(isType(Optional.class), annotations)) != null;
ValueConstraintsModel valueConstraintsModel = constraintsFor(annotations, GenericPropertyInfo.propertyTypeOf(accessor), ((Member) accessor).getName(), optional, constraintClasses, accessor);
ValueConstraintsInstance valueConstraintsInstance = null;
if (valueConstraintsModel.isConstrained()) {
valueConstraintsInstance = valueConstraintsModel.newInstance();
}
MetaInfo metaInfo = stateDeclarations.metaInfoFor(accessor);
Object initialValue = stateDeclarations.initialValueOf(accessor);
boolean useDefaults = metaInfo.get(UseDefaults.class) != null || stateDeclarations.useDefaults(accessor);
boolean immutable = this.immutable || metaInfo.get(Immutable.class) != null;
PropertyModel propertyModel = new PropertyModel(accessor, immutable, useDefaults, valueConstraintsInstance, metaInfo, initialValue);
return propertyModel;
}
Aggregations