Search in sources :

Example 11 with Property

use of org.qi4j.api.property.Property in project qi4j-sdk by Qi4j.

the class EntityStateInstance method propertyFor.

@Override
@SuppressWarnings("unchecked")
public <T> Property<T> propertyFor(AccessibleObject accessor) throws IllegalArgumentException {
    Map<AccessibleObject, Object> state = state();
    Property<T> property = (Property<T>) state.get(accessor);
    if (property == null) {
        PropertyModel entityPropertyModel = stateModel.propertyModelFor(accessor);
        property = new EntityPropertyInstance<>(entityState instanceof BuilderEntityState ? entityPropertyModel.getBuilderInfo() : entityPropertyModel, entityState);
        state.put(accessor, property);
    }
    return property;
}
Also used : PropertyModel(org.qi4j.runtime.property.PropertyModel) AccessibleObject(java.lang.reflect.AccessibleObject) AccessibleObject(java.lang.reflect.AccessibleObject) BuilderEntityState(org.qi4j.runtime.unitofwork.BuilderEntityState) Property(org.qi4j.api.property.Property)

Aggregations

Property (org.qi4j.api.property.Property)11 AccessibleObject (java.lang.reflect.AccessibleObject)5 Method (java.lang.reflect.Method)4 HashMap (java.util.HashMap)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Association (org.qi4j.api.association.Association)3 ManyAssociation (org.qi4j.api.association.ManyAssociation)3 NamedAssociation (org.qi4j.api.association.NamedAssociation)3 PropertyModel (org.qi4j.runtime.property.PropertyModel)3 Collection (java.util.Collection)2 Map (java.util.Map)2 TransientStateInstance (org.qi4j.runtime.composite.TransientStateInstance)2 PropertyInstance (org.qi4j.runtime.property.PropertyInstance)2 BuilderEntityState (org.qi4j.runtime.unitofwork.BuilderEntityState)2 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ResultSet (java.sql.ResultSet)1 Properties (java.util.Properties)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1