Class VariablePool

java.lang.Object
net.ssehub.easy.varModel.cst.VariablePool

public class VariablePool extends Object
Utility class for caching / pooling variables in order to save memory. Please use this class local to a model / operation in order avoid that memory remains allocated although not used.
Author:
Sascha El-Sharkawy, Holger Eichelberger
  • Field Details

  • Constructor Details

    • VariablePool

      public VariablePool()
  • Method Details

    • obtainVariable

      public final Variable obtainVariable(AbstractVariable decl)
      Returns a Variable for the given AbstractVariable. This method will cache already created Variables to reduce memory consumption.
      Parameters:
      decl - A AbstractVariable for which a Variable shall be created.
      Returns:
      A cached Variable for the given AbstractVariable or a new one if no cached variable exists, a new one is created and will be cached for future calls.
    • keyObject

      public static final Integer keyObject(AbstractVariable decl)
      Returns the key object for hashes, also for tests. This is needed, as the equals/hashcode implementation of AbstractVariable is just based on the name and does not cope with local variables. This method shall remind dependent implementations about the aforementionied problem.
      Parameters:
      decl - the declaration
      Returns:
      the key/hash object
    • knowsVariable

      public final boolean knowsVariable(AbstractVariable decl)
      Returns whether this pool knows a certain variable.
      Parameters:
      decl - the variable declaration
      Returns:
      true if the pool knows the variable, false else
    • clear

      public final void clear()
      Clears this pool for reuse or to force unallocation of memory.
    • toString

      public String toString()
      Overrides:
      toString in class Object