use of org.drools.core.base.AccessorKey in project drools by kiegroup.
the class ClassFieldAccessorStore method getAccessor.
public ClassFieldAccessor getAccessor(final String className, final String fieldName) {
AccessorKey key = new AccessorKey(className, fieldName, AccessorKey.AccessorType.FieldAccessor);
FieldLookupEntry entry = (FieldLookupEntry) this.lookup.computeIfAbsent(key, k -> new FieldLookupEntry(new ClassFieldReader(className, fieldName), new ClassFieldWriter(className, fieldName)));
ClassFieldAccessor accessor = new ClassFieldAccessor((ClassFieldReader) entry.getClassFieldReader(), entry.getClassFieldWriter());
if (this.eagerWire) {
wire(entry.getClassFieldReader());
wire(entry.getClassFieldWriter());
}
return accessor;
}
use of org.drools.core.base.AccessorKey in project drools by kiegroup.
the class ClassFieldAccessorStore method getReader.
public synchronized ClassFieldReader getReader(final String className, String fieldName, final AcceptsReadAccessor target, final AccessorKey.AccessorType accessorType) {
AccessorKey key = new AccessorKey(className, fieldName, accessorType);
FieldLookupEntry entry = (FieldLookupEntry) this.lookup.get(key);
boolean exists = entry != null;
if (!exists) {
entry = new FieldLookupEntry(new ClassFieldReader(className, fieldName));
}
if (this.eagerWire) {
wire(entry.getClassFieldReader());
ClassFieldReader reader = (ClassFieldReader) entry.getClassFieldReader();
if (!reader.hasReadAccessor()) {
return null;
}
}
if (target != null) {
target.setReadAccessor(entry.getClassFieldReader());
}
if (!exists) {
// we delay the key writing as we only want to do it if the wiring was successful
this.lookup.put(key, entry);
}
return (ClassFieldReader) entry.getClassFieldReader();
}
use of org.drools.core.base.AccessorKey in project drools by kiegroup.
the class ClassFieldAccessorStore method getMVELReader.
public InternalReadAccessor getMVELReader(final String pkgName, final String className, final String expr, final boolean typesafe, Class<?> returnType) {
AccessorKey key = new AccessorKey(pkgName + className, expr, AccessorKey.AccessorType.FieldAccessor);
FieldLookupEntry entry = (FieldLookupEntry) this.lookup.computeIfAbsent(key, k -> new FieldLookupEntry(getReadAcessor(className, expr, typesafe, returnType)));
return entry.getClassFieldReader();
}
use of org.drools.core.base.AccessorKey in project drools by kiegroup.
the class ClassFieldAccessorStore method wireObjectType.
public ObjectType wireObjectType(ObjectType objectType, AcceptsClassObjectType target) {
if (!(objectType instanceof ClassObjectType)) {
return objectType;
}
AccessorKey key = new AccessorKey(objectType.getClassName(), objectType.isEvent() ? "$$DROOLS__isEvent__" : null, AccessorKey.AccessorType.ClassObjectType);
ClassObjectTypeLookupEntry entry = (ClassObjectTypeLookupEntry) this.lookup.computeIfAbsent(key, k -> new ClassObjectTypeLookupEntry(cache.getClassObjectType((ClassObjectType) objectType, false)));
if (target != null) {
target.setClassObjectType(entry.getClassObjectType());
}
return entry.getClassObjectType();
}
Aggregations