Class TypeCache
- java.lang.Object
-
- net.ssehub.easy.reasoning.sseReasoner.model.TypeCache
-
public final class TypeCache extends java.lang.ObjectImplements a type cache to avoid repeatedly identifying, iterating over and collecting constraints for complex types.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classTypeCache.ConstraintTemplateRepresents a constraint template with related constraint set to add the constraint to.classTypeCache.EntryImplements a type cache entry.static interfaceTypeCache.IConstraintTargetSpecifies the interface that an object receiving constraints from this class must provide.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<IDatatype,TypeCache.Entry>cachestatic booleanENABLEDGlobally enables or disables type-caching.(package private) static booleanON_DEMAND_ACCESSORSVariable-accessor and name-accessor mappings may be transferred back to the current context in one copy stepfalseor step-wise and on-demand onlytrue.private SubstitutionVisitorsubstVisitor
-
Constructor Summary
Constructors Constructor Description TypeCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(IDatatype type)Returns whether this type cache contains an entry fortype.TypeCache.EntrycreateEntryFor(IDatatype type, AbstractVariable var)Creates a type cache entry.TypeCache.Entryget(IDatatype type)Returns a type cache entry for the giventype.booleantransferConstraints(IDatatype type, TypeCache.IConstraintTarget target, IDecisionVariable register, AbstractVariable var)Transfers collected constraints fortype.voidtransferContext(IDatatype type, java.util.Map<AbstractVariable,ConstraintSyntaxTree> varMap, java.util.Map<java.lang.String,ConstraintSyntaxTree> nameMap)Transfers the mappings of the givencontextinto the cache entry oftype.voidtransferToContext(IDatatype type, ContextStack contexts, AbstractVariable var)Transfers all accessors stored inTypeCache.Entry.varMapinto the actual context incontextsby instantiating them.
-
-
-
Field Detail
-
ENABLED
public static final boolean ENABLED
Globally enables or disables type-caching.- See Also:
- Constant Field Values
-
ON_DEMAND_ACCESSORS
static final boolean ON_DEMAND_ACCESSORS
Variable-accessor and name-accessor mappings may be transferred back to the current context in one copy stepfalseor step-wise and on-demand onlytrue. Only active if#ENABLED.- See Also:
- Constant Field Values
-
cache
private java.util.Map<IDatatype,TypeCache.Entry> cache
-
substVisitor
private transient SubstitutionVisitor substVisitor
-
-
Method Detail
-
get
public TypeCache.Entry get(IDatatype type)
Returns a type cache entry for the giventype.- Parameters:
type- the type to return the cache entry for- Returns:
- the cache entry, may be null for none
-
contains
public boolean contains(IDatatype type)
Returns whether this type cache contains an entry fortype.- Parameters:
type- the type to look for- Returns:
trueiftypeis in the cache,falseelse
-
createEntryFor
public TypeCache.Entry createEntryFor(IDatatype type, AbstractVariable var)
Creates a type cache entry.- Parameters:
type- the type to create the entry forvar- the template varible- Returns:
- the created entry
-
transferConstraints
public boolean transferConstraints(IDatatype type, TypeCache.IConstraintTarget target, IDecisionVariable register, AbstractVariable var)
Transfers collected constraints fortype.- Parameters:
type- the type to transfer the constraints totarget- the constraint target receiving instantiated constraintsregister- the variable to register new constraints withvar- the variable to replace the template variable- Returns:
truefor transferred,falseelse
-
transferContext
public void transferContext(IDatatype type, java.util.Map<AbstractVariable,ConstraintSyntaxTree> varMap, java.util.Map<java.lang.String,ConstraintSyntaxTree> nameMap)
Transfers the mappings of the givencontextinto the cache entry oftype.- Parameters:
type- the typevarMap- the variable-accessor mapping (optional, may be null)nameMap- the name-accessor mapping (optional, may be null)
-
transferToContext
public void transferToContext(IDatatype type, ContextStack contexts, AbstractVariable var)
Transfers all accessors stored inTypeCache.Entry.varMapinto the actual context incontextsby instantiating them.- Parameters:
type- the type to transfercontexts- the target contexts (using the actual one)var- the variable to instantiate for
-
-