Class VariableLookUpTable
- java.lang.Object
-
- net.ssehub.easy.varModel.model.rewrite.VariableLookUpTable
-
class VariableLookUpTable extends java.lang.ObjectPart of theRewriteContextto speed upIDecisionVariableretrieval.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<AbstractVariable,java.util.Set<ContainableModelElement>>constraintReusersList model elements, reusing a constraint variable (declaration).private java.util.Set<AbstractVariable>definedDeclarationsList model elements, calling a constraint variable (declaration).private booleaninitializedprivate java.util.Map<AbstractVariable,java.util.Set<IDecisionVariable>>instancesPerDeclarationList of instances for a given declaration.private java.util.Map<IDatatype,java.util.Set<IDecisionVariable>>instancesPerTypeList of instances for a givenIDatatype.
-
Constructor Summary
Constructors Constructor Description VariableLookUpTable()Single constructor for this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddVariable(IDecisionVariable variable, IDatatype type)Adds anIDecisionVariableto theinstancesPerType.(package private) booleandeclarationKnown(AbstractVariable declaration)Checks whether the declaration is known or whether the declaration is a local declaration used as an iterator of a constraint.(package private) java.util.Set<IDecisionVariable>getInstancesForDeclaration(AbstractVariable declaration)Returns the set of instances of the givenAbstractVariabledeclaration.(package private) java.util.Set<IDecisionVariable>getInstancesForType(IDatatype type)Returns the set of instances of the givenIDatatype.(package private) voidinit(Configuration config)Creates the internal look up tables and should be called if it is the first time used.private voidinit(IDecisionVariable variable)Recursive part ofinit(Configuration).(package private) voidputConstraintOccurrence(AbstractVariable constraintDecl, ContainableModelElement referringElement)Stores that the given constraint declaration was used inside the referring element.
-
-
-
Field Detail
-
initialized
private boolean initialized
-
instancesPerType
private java.util.Map<IDatatype,java.util.Set<IDecisionVariable>> instancesPerType
List of instances for a givenIDatatype. Is used to speed upConfigurationbasedIModelElementFilter. Contains toplevel and nested variables as well as annotations.
-
instancesPerDeclaration
private java.util.Map<AbstractVariable,java.util.Set<IDecisionVariable>> instancesPerDeclaration
List of instances for a given declaration. Is used to speed upConfigurationbasedIModelElementFilter. Contains toplevel and nested variables as well as annotations.
-
constraintReusers
private java.util.Map<AbstractVariable,java.util.Set<ContainableModelElement>> constraintReusers
List model elements, reusing a constraint variable (declaration). A tuple in form of (Constraint Variable declaration, Set of reusing elements). For instance:Constraint cVar = ...; def Boolean func(Integer intVar) = cVar && ...;
-
definedDeclarations
private java.util.Set<AbstractVariable> definedDeclarations
List model elements, calling a constraint variable (declaration). A tuple in form of (Calling element Set of called constraint variables). Inverse toconstraintReusersFor instance:Constraint cVar = func(aVariable); def Boolean func(Integer intVar) = intVar > 10;- See Also:
constraintReusers
-
-
Method Detail
-
init
void init(Configuration config)
Creates the internal look up tables and should be called if it is the first time used. Multiple calls will ignored.- Parameters:
config- The used configuration.
-
init
private void init(IDecisionVariable variable)
Recursive part ofinit(Configuration). Will add the variable as well as all nested variables and annotations. Adapt this method if further tables are needed.- Parameters:
variable- AIDecisionVariableof the configuration.
-
addVariable
private void addVariable(IDecisionVariable variable, IDatatype type)
Adds anIDecisionVariableto theinstancesPerType.- Parameters:
variable- The variable to addtype- The type of the variable.
-
getInstancesForType
java.util.Set<IDecisionVariable> getInstancesForType(IDatatype type)
Returns the set of instances of the givenIDatatype.- Parameters:
type- The exactIDatatypefor which the instances shall be returned, will not considerIDatatype.isAssignableFrom(IDatatype).- Returns:
- The instances for the given type or null if no instances exist.
-
getInstancesForDeclaration
java.util.Set<IDecisionVariable> getInstancesForDeclaration(AbstractVariable declaration)
Returns the set of instances of the givenAbstractVariabledeclaration.- Parameters:
declaration- The declaration for which the instances shall be returned. If the declaration is nested inside a compound which was multiple times instantiated, this single declaration could return multipleIDecisionVariables.- Returns:
- The instances for the given declaration or null if no instances exist.
-
declarationKnown
boolean declarationKnown(AbstractVariable declaration)
Checks whether the declaration is known or whether the declaration is a local declaration used as an iterator of a constraint. Needs that thisVariableLookUpTablewas already initialized with aConfiguration.- Parameters:
declaration- The declaration to check.- Returns:
- true if the declaration is used for a
IDecisionVariableof the configuration or if this table was not initialized with aConfiguration, false otherwise.
-
putConstraintOccurrence
void putConstraintOccurrence(AbstractVariable constraintDecl, ContainableModelElement referringElement)
Stores that the given constraint declaration was used inside the referring element.- Parameters:
constraintDecl- A constraint declaration used inside the second parameter.referringElement- An element which may use a constraint declaration as part of its own definition, e.g., another constraint declaration, aConstraintor aOperationDefinition.
-
-