use of org.drools.core.reteoo.FactTemplateTypeConf in project drools by kiegroup.
the class ObjectTypeConfigurationRegistry method getObjectTypeConf.
/**
* Returns the ObjectTypeConfiguration object for the given object or
* creates a new one if none is found in the cache
*/
public ObjectTypeConf getObjectTypeConf(EntryPointId entrypoint, Object object) {
// first see if it's a ClassObjectTypeConf
Object key;
if (object instanceof Activation) {
key = ClassObjectType.Match_ObjectType.getClassType();
} else if (object instanceof Fact) {
key = ((Fact) object).getFactTemplate().getName();
} else {
key = object.getClass();
}
ObjectTypeConf objectTypeConf = this.typeConfMap.get(key);
// it doesn't exist, so create it.
if (objectTypeConf == null) {
if (object instanceof Fact) {
objectTypeConf = new FactTemplateTypeConf(entrypoint, ((Fact) object).getFactTemplate(), this.kBase);
} else {
objectTypeConf = new ClassObjectTypeConf(entrypoint, (Class<?>) key, this.kBase);
}
ObjectTypeConf existing = this.typeConfMap.putIfAbsent(key, objectTypeConf);
if (existing != null) {
// Raced, take the (now) existing.
objectTypeConf = existing;
}
}
return objectTypeConf;
}
Aggregations