Package org.variantsync.boosting.product
Class Variant
java.lang.Object
org.variantsync.boosting.product.Variant
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionVariant
(String name, CustomHashSet<ASTNode> astNodesMainTree, AbstractAST productAST, CustomHashSet<Feature> features) Constructs a new Variant object with the given parameters.Creates a new Variant object by copying the contents of another Variant object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
Clears the variant's Abstract Syntax Tree (AST) by setting it to null.Returns the set of AST nodes in the main tree.Retrieves the set of features associated with the variant.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.getName()
Returns the name of the object.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.Returns the Abstract Syntax Tree (AST) representing the variant.int
hashCode()
void
setAstNodesMainTree
(CustomHashSet<ASTNode> astNodesMainTree) Sets the AST nodes for the main tree.
-
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 variantastNodesMainTree
- the main tree of AST nodes of the variantproductAST
- the abstract syntax tree of the variantfeatures
- the set of features associated with the variant
-
Variant
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
Retrieves the set of features associated with the variant.- Returns:
- The set of features associated with the variant
-
getAstNodesMainTree
Returns the set of AST nodes in the main tree.- Returns:
- a set of AST nodes in the main tree
-
getMappingFromPosition
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
Returns the name of the object.- Returns:
- the name of the object as a String
-
getNodeFromPosition
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
Returns the Abstract Syntax Tree (AST) representing the variant.- Returns:
- the AST representing the variant
-
setAstNodesMainTree
Sets the AST nodes for the main tree.- Parameters:
astNodesMainTree
- the AST nodes for the main tree
-
equals
-
hashCode
public int hashCode()
-