Class Variant

java.lang.Object
org.variantsync.boosting.product.Variant
All Implemented Interfaces:
Serializable

public class Variant extends Object implements Serializable
The class Variant represents a software variant with features and an abstract syntax tree (AST). It also stores the AST nodes of the main tree that correspond to the AST nodes of the variant AST.
See Also:
  • Constructor Details

    • Variant

      public Variant(String name, CustomHashSet<ASTNode> astNodesMainTree, AbstractAST productAST, CustomHashSet<Feature> features)
      Constructs a new Variant object with the given parameters.
      Parameters:
      name - the name of the variant
      astNodesMainTree - the main tree of AST nodes of the variant
      productAST - the abstract syntax tree of the variant
      features - the set of features associated with the variant
    • Variant

      public Variant(Variant other)
      Creates a new Variant object by copying the contents of another Variant object.
      Parameters:
      other - The Variant object to copy from
      Throws:
      UnsupportedOperationException - if the productAST type is not JavaAST or LineAST
  • Method Details

    • forgetAST

      public void forgetAST()
      Clears the variant's Abstract Syntax Tree (AST) by setting it to null.
    • getFeatures

      public CustomHashSet<Feature> getFeatures()
      Retrieves the set of features associated with the variant.
      Returns:
      The set of features associated with the variant
    • getAstNodesMainTree

      public CustomHashSet<ASTNode> getAstNodesMainTree()
      Returns the set of AST nodes in the main tree.
      Returns:
      a set of AST nodes in the main tree
    • getMappingFromPosition

      public org.logicng.formulas.Formula getMappingFromPosition(Position position)
      Returns the mapping of the node at the given position in the variant's AST or, if it has already been merged into the main tree, the mapping of the corresponding node in the main tree.
      Parameters:
      position - The position of the node to find the mapping for
      Returns:
      The mapping of the node at the given position, or null if no node is found
    • getName

      public String getName()
      Returns the name of the object.
      Returns:
      the name of the object as a String
    • getNodeFromPosition

      public ASTNode getNodeFromPosition(Position position)
      Returns the ASTNode at the given position in the variant AST or, if it has already been merged into the main tree, returns the corresponding node in the main tree.
      Parameters:
      position - The position to search for in the variant's AST.
      Returns:
      The ASTNode at the given position in the variant's AST, or the corresponding node in the main tree if merged.
    • getProductAst

      public AbstractAST getProductAst()
      Returns the Abstract Syntax Tree (AST) representing the variant.
      Returns:
      the AST representing the variant
    • setAstNodesMainTree

      public void setAstNodesMainTree(CustomHashSet<ASTNode> astNodesMainTree)
      Sets the AST nodes for the main tree.
      Parameters:
      astNodesMainTree - the AST nodes for the main tree
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object