Class VariableLookUpTable
java.lang.Object
net.ssehub.easy.varModel.model.rewrite.VariableLookUpTable
Part of the
RewriteContext to speed up IDecisionVariable retrieval.- Author:
- El-Sharkawy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<AbstractVariable, Set<ContainableModelElement>> List model elements, reusing a constraint variable (declaration).private Set<AbstractVariable> List model elements, calling a constraint variable (declaration).private booleanprivate Map<AbstractVariable, Set<IDecisionVariable>> List of instances for a given declaration.private Map<IDatatype, Set<IDecisionVariable>> List of instances for a givenIDatatype. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate 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) Set<IDecisionVariable> getInstancesForDeclaration(AbstractVariable declaration) Returns the set of instances of the givenAbstractVariabledeclaration.(package private) 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 Details
-
initialized
private boolean initialized -
instancesPerType
List of instances for a givenIDatatype. Is used to speed upConfigurationbasedIModelElementFilter. Contains toplevel and nested variables as well as annotations. -
instancesPerDeclaration
List of instances for a given declaration. Is used to speed upConfigurationbasedIModelElementFilter. Contains toplevel and nested variables as well as annotations. -
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
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:
-
-
Constructor Details
-
VariableLookUpTable
VariableLookUpTable()Single constructor for this class.
-
-
Method Details
-
init
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
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
Adds anIDecisionVariableto theinstancesPerType.- Parameters:
variable- The variable to addtype- The type of the variable.
-
getInstancesForType
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
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
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:
trueif the declaration is used for aIDecisionVariableof the configuration or if this table was not initialized with aConfiguration,falseotherwise.
-
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.
-