// traits and proxies can benefit from a cached lookup
identityMap = new IdentityHashMap<Object, FactHandle>( );
}
TraitFactory builder = TraitFactory.getTraitBuilderForKnowledgeBase( this.getKnowledgeRuntime().getKieBase() );
TraitableBean inner = makeTraitable( core, builder, logical );
boolean needsProxy = trait.isAssignableFrom( inner.getClass() );
boolean hasTrait = inner.hasTrait( trait.getName() );
boolean needsUpdate = needsProxy || core != inner;
checkStaticTypeCode( inner );
BitSet boundary = inner.getCurrentTypeCode() != null ? (BitSet) inner.getCurrentTypeCode().clone() : null;
Collection<Thing> mostSpecificTraits = getTraitBoundary( inner, needsProxy, hasTrait, trait );
T thing = asTrait( core, inner, trait, needsProxy, hasTrait, needsUpdate, builder, logical );
configureTrait( thing, value );
thing = doInsertTrait( thing, core, logical, boundary, modes );
refresh( thing, core, inner, trait, mostSpecificTraits, logical );
if ( trait != Thing.class && inner._getFieldTMS() != null ) {
inner._getFieldTMS().resetModificationMask();
}
return thing;
}