Class Variables

java.lang.Object
jromp.parallel.var.Variables

public class Variables extends Object
Represents a collection of variables.
  • Method Details

    • create

      public static Variables create()
      Creates a new instance of the Variables class.
      Returns:
      the newly created Variables object.
    • create

      public static Variables create(Map<String,Variable<?>> varMap)
      Creates a new instance of the Variables class with the provided variable map.
      Parameters:
      varMap - the map of variables to be added to the new instance.
      Returns:
      the newly created Variables object.
    • add

      public <T extends Serializable> Variables add(String name, Variable<T> variable)
      Adds a variable with the specified name to the map of variables.
      Type Parameters:
      T - the type of the variable.
      Parameters:
      name - the name of the variable.
      variable - the variable to be added.
      Returns:
      the updated Variables object.
    • get

      public <T extends Serializable> Variable<T> get(String name)
      Retrieves the variable with the specified name from the Variables object.
      Type Parameters:
      T - the type of the variable.
      Parameters:
      name - the name of the variable to retrieve.
      Returns:
      the variable with the specified name, or null if it does not exist.
    • isEmpty

      public boolean isEmpty()
      Checks if the variable map is empty.
      Returns:
      true if the variable map is empty, false otherwise.
    • size

      public int size()
      Returns the size of the map of variables.
      Returns:
      the size of the map of variables.
    • contains

      public boolean contains(String name)
      Checks if the variable map contains a variable with the specified name.
      Parameters:
      name - the name of the variable to check.
      Returns:
      true if the variable map contains a variable with the specified name, false otherwise.
    • toString

      public String toString()
      Returns a string representation of the Variables object. The string contains all the variables in the variable map, formatted as "name -> variableString\n". If the variable map is empty, the string "No variables" is returned.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the Variables object.
    • copy

      public Variables copy()
      Creates a copy of the Variables object.
      Returns:
      a copy of the Variables object.
    • getVariablesOfType

      public <T extends Variable<?>> List<T> getVariablesOfType(Class<T> type)
      Retrieves a list of variables of a specified type.
      Type Parameters:
      T - the type of the variables.
      Parameters:
      type - the Class object representing the type of variables to retrieve.
      Returns:
      a list of variables of the specified type.
    • end

      public void end()
      Ends all variables in the variable map.