Package de.monticore.tf.odrules
Class HierarchyHelper
- java.lang.Object
-
- de.monticore.tf.odrules.HierarchyHelper
-
public final class HierarchyHelper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description HierarchyHelper()HierarchyHelper(ASTODRule astodRule)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCustomImports(java.lang.String customImport)Add custom import for code generationjava.util.List<ASTChange>getChangeObjectsWhithoutCreate(ASTReplacement replacements)java.util.List<java.lang.String>getCustomImports()Get all custom imports for code generationjava.util.List<ASTMatchingObject>getInnerLinkObjectsLHS(java.util.List<ASTMatchingObject> allMatches, ASTMatchingObject obj)Calculates all inner objects of a given objectjava.util.List<ASTMatchingObject>getListChilds(java.util.List<ASTMatchingObject> allobjects)Gives all objects in a List in the given list of objects, besides optionalsjava.util.List<ASTMatchingObject>getListChilds(java.util.List<ASTMatchingObject> allObjects, ASTMatchingObject list)Removes every optional and listChild match-object.java.util.List<ASTMatchingObject>getListChildsWithOptionals(java.util.List<ASTMatchingObject> allobjects)Gives all objects in a List in the given list of objectsjava.util.List<ASTMatchingObject>getListChildsWithOptionals(java.util.List<ASTMatchingObject> allobjects, ASTMatchingObject list)Gives all child objects from a given list of objects, including optionalsjava.util.List<ASTMatchingObject>getListObjects(java.util.List<ASTMatchingObject> allObjects)Removes every mandatory object.java.lang.StringgetListParent(java.lang.String object)Gives the ListStructure Name the given objectName lies injava.util.List<java.lang.String>getListTree(java.lang.String object)Method to get the Treepath the object lies in.java.util.List<ASTChange>getMandatoryChangeObjects(java.util.List<ASTChange> allChanges)Removes every Change object with the Optional type.java.util.List<ASTChange>getMandatoryChangeObjectsNoList(java.util.List<ASTChange> allChanges)Removes every Change object with the Optional type and the list type.java.util.List<ASTChange>getMandatoryChangeObjectsOnlyList(java.util.List<ASTChange> allChanges)Only change objects with the list type.java.util.List<ASTDeleteOperation>getMandatoryDeleteObjects(java.util.List<ASTDeleteOperation> allDeletes)Removes every Delete object with the Optional type.java.util.List<ASTMatchingObject>getMandatoryMatchObjects(java.util.List<ASTMatchingObject> allMatches)Removes every optional Match object.java.util.List<ASTMatchingObject>getMandatoryObjectsWithoutListChilds(java.util.List<ASTMatchingObject> allMatches)Removes every listChild match-object.java.util.List<ASTMatchingObject>getMandatoryObjectsWithoutOptAndListChilds(java.util.List<ASTMatchingObject> allMatches)Removes every optional and listChild match-object.java.util.List<ASTMatchingObject>getMandatoryObjectsWithoutOptList(java.util.List<ASTMatchingObject> allMatches)Removes every optional and list match object.static ASTMatchingObjectgetMatchingObject(java.util.List<ASTMatchingObject> allObjects, java.lang.String name)ASTMatchingObjectgetObjectByName(java.util.List<ASTMatchingObject> allObjects, java.lang.String name)Gives the Object to a Name in a given List of Objectsjava.util.List<ASTMatchingObject>getOptionalMatchObjects(java.util.List<ASTMatchingObject> allMatches)Removes every mandatory Match object.java.util.List<ASTMatchingObject>getOptListObjects(java.util.List<ASTMatchingObject> allObjects)Removes every normal object.java.lang.StringgetPackageName()Get package name for code generationbooleanisLhsListChild(ASTMatchingObject object)booleanisLhsListChild(java.lang.String objectname)booleanisListChild(ASTMatchingObject object)Checks if the given object is in a list.booleanisListChild(java.lang.String objectname)booleanisListObject(java.lang.String objectName)Checks whether the object with the given name is a list object.booleanisNoOptionalName(java.util.List<ASTMatchingObject> matches, java.lang.String linkName)Checks if one of the InnerLinkObjects is an Optional objectbooleanisRhsListChild(ASTMatchingObject object)booleanisRhsListChild(java.lang.String objectname)booleanisWithinListStructure(java.lang.String objectName)booleanisWithinNegativeStructure(java.lang.String objectName)Checks if the object with the given name is within an negative structure (not[[..]]-element).booleanisWithinOptionalStructure(java.lang.String objectName)Checks if the object with the given name is within an optional structure.booleanpackageisPresentName()Check if package name for code generation is setvoidsetPackageName(java.lang.String packageName)Set package name for code generation
-
-
-
Constructor Detail
-
HierarchyHelper
public HierarchyHelper()
-
HierarchyHelper
public HierarchyHelper(ASTODRule astodRule)
-
-
Method Detail
-
isListObject
public boolean isListObject(java.lang.String objectName)
Checks whether the object with the given name is a list object.- Parameters:
objectName- the name of the object- Returns:
- whether it is a list
-
getPackageName
public java.lang.String getPackageName()
Get package name for code generation- Returns:
-
setPackageName
public void setPackageName(java.lang.String packageName)
Set package name for code generation- Parameters:
packageName-
-
packageisPresentName
public boolean packageisPresentName()
Check if package name for code generation is set- Returns:
-
getCustomImports
public java.util.List<java.lang.String> getCustomImports()
Get all custom imports for code generation- Returns:
-
addCustomImports
public void addCustomImports(java.lang.String customImport)
Add custom import for code generation- Parameters:
customImport-
-
getInnerLinkObjectsLHS
public java.util.List<ASTMatchingObject> getInnerLinkObjectsLHS(java.util.List<ASTMatchingObject> allMatches, ASTMatchingObject obj)
Calculates all inner objects of a given object- Parameters:
obj- The list from which we want the childs.allMatches- The list of all LHS match elements.- Returns:
- a List of the names of all (direct) childs from the list.
-
getListObjects
public java.util.List<ASTMatchingObject> getListObjects(java.util.List<ASTMatchingObject> allObjects)
Removes every mandatory object.- Parameters:
allObjects- list of all objects- Returns:
- a list of all found list objects
-
isListChild
public boolean isListChild(ASTMatchingObject object)
Checks if the given object is in a list.- Parameters:
object- The object to be checked- Returns:
- If the object is in a list
-
isListChild
public boolean isListChild(java.lang.String objectname)
-
isLhsListChild
public boolean isLhsListChild(java.lang.String objectname)
-
isLhsListChild
public boolean isLhsListChild(ASTMatchingObject object)
-
isRhsListChild
public boolean isRhsListChild(java.lang.String objectname)
-
isRhsListChild
public boolean isRhsListChild(ASTMatchingObject object)
-
getMandatoryObjectsWithoutOptAndListChilds
public java.util.List<ASTMatchingObject> getMandatoryObjectsWithoutOptAndListChilds(java.util.List<ASTMatchingObject> allMatches)
Removes every optional and listChild match-object.- Parameters:
allMatches- list of all match-objects- Returns:
- a list of match-objects without optional and listChild objects
-
getMandatoryObjectsWithoutListChilds
public java.util.List<ASTMatchingObject> getMandatoryObjectsWithoutListChilds(java.util.List<ASTMatchingObject> allMatches)
Removes every listChild match-object.- Parameters:
allMatches- list of all match-objects- Returns:
- a list of match-objects without listChild objects
-
getListChilds
public java.util.List<ASTMatchingObject> getListChilds(java.util.List<ASTMatchingObject> allObjects, ASTMatchingObject list)
Removes every optional and listChild match-object.- Parameters:
allObjects- list of all match-objects- Returns:
- a list of match-objects without optional and listChild objects
-
getListChildsWithOptionals
public java.util.List<ASTMatchingObject> getListChildsWithOptionals(java.util.List<ASTMatchingObject> allobjects, ASTMatchingObject list)
Gives all child objects from a given list of objects, including optionals- Parameters:
allobjects- the objects to search in- Returns:
- all objects in lists in the given objects
-
getListChilds
public java.util.List<ASTMatchingObject> getListChilds(java.util.List<ASTMatchingObject> allobjects)
Gives all objects in a List in the given list of objects, besides optionals- Parameters:
allobjects- the objects to search in- Returns:
- all objects in lists in the given objects
-
getListChildsWithOptionals
public java.util.List<ASTMatchingObject> getListChildsWithOptionals(java.util.List<ASTMatchingObject> allobjects)
Gives all objects in a List in the given list of objects- Parameters:
allobjects- the objects to search in- Returns:
- all objects in lists in the given objects
-
getListParent
public java.lang.String getListParent(java.lang.String object)
Gives the ListStructure Name the given objectName lies in- Parameters:
object- The name of the object- Returns:
- The name of the list Structure which contains the object
-
getListTree
public java.util.List<java.lang.String> getListTree(java.lang.String object)
Method to get the Treepath the object lies in.- Parameters:
object- The Object for which we want to find a path in the List-Structure Tree- Returns:
- A List starting with the root-list and ending with the list containing the given Object.
-
getObjectByName
public ASTMatchingObject getObjectByName(java.util.List<ASTMatchingObject> allObjects, java.lang.String name)
Gives the Object to a Name in a given List of Objects- Parameters:
allObjects- The List of objects where the object should be found in.name- The given objectname- Returns:
- The object which has the given name, null if no object was found
-
getMandatoryChangeObjects
public java.util.List<ASTChange> getMandatoryChangeObjects(java.util.List<ASTChange> allChanges)
Removes every Change object with the Optional type.- Parameters:
allChanges- list of all Change objects- Returns:
- a list of Changes without optional objects
-
getMandatoryChangeObjectsNoList
public java.util.List<ASTChange> getMandatoryChangeObjectsNoList(java.util.List<ASTChange> allChanges)
Removes every Change object with the Optional type and the list type.- Parameters:
allChanges- list of all Change objects- Returns:
- a list of Changes without optional objects and list objects
-
getChangeObjectsWhithoutCreate
public java.util.List<ASTChange> getChangeObjectsWhithoutCreate(ASTReplacement replacements)
-
getMandatoryChangeObjectsOnlyList
public java.util.List<ASTChange> getMandatoryChangeObjectsOnlyList(java.util.List<ASTChange> allChanges)
Only change objects with the list type.- Parameters:
allChanges- list of all Change objects- Returns:
- a list of Changes, which are list objects
-
getMandatoryDeleteObjects
public java.util.List<ASTDeleteOperation> getMandatoryDeleteObjects(java.util.List<ASTDeleteOperation> allDeletes)
Removes every Delete object with the Optional type.- Parameters:
allDeletes- list of all Delete objects- Returns:
- a list of Deletes without optional objects
-
getMandatoryMatchObjects
public java.util.List<ASTMatchingObject> getMandatoryMatchObjects(java.util.List<ASTMatchingObject> allMatches)
Removes every optional Match object.- Parameters:
allMatches- list of all Match objects- Returns:
- a list of Matches without optional objects
-
getMandatoryObjectsWithoutOptList
public java.util.List<ASTMatchingObject> getMandatoryObjectsWithoutOptList(java.util.List<ASTMatchingObject> allMatches)
Removes every optional and list match object.- Parameters:
allMatches- list of all Match objects- Returns:
- a list of Matches without optional and list objects
-
getOptionalMatchObjects
public java.util.List<ASTMatchingObject> getOptionalMatchObjects(java.util.List<ASTMatchingObject> allMatches)
Removes every mandatory Match object.- Parameters:
allMatches- list of all Match objects- Returns:
- a list of optional Match objects
-
isNoOptionalName
public boolean isNoOptionalName(java.util.List<ASTMatchingObject> matches, java.lang.String linkName)
Checks if one of the InnerLinkObjects is an Optional object- Parameters:
matches- list of matches to checklinkName- the name of the object to look for- Returns:
true, if the object with the given name is no optional
-
getOptListObjects
public java.util.List<ASTMatchingObject> getOptListObjects(java.util.List<ASTMatchingObject> allObjects)
Removes every normal object.- Parameters:
allObjects- list of all Match-objects- Returns:
- a list of optional Match objects
-
isWithinOptionalStructure
public boolean isWithinOptionalStructure(java.lang.String objectName)
Checks if the object with the given name is within an optional structure.- Parameters:
objectName- the object name- Returns:
- whether the object is within an optional structure
-
isWithinNegativeStructure
public boolean isWithinNegativeStructure(java.lang.String objectName)
Checks if the object with the given name is within an negative structure (not[[..]]-element).- Parameters:
objectName- the object name- Returns:
- whether the object is within a negative structure
-
isWithinListStructure
public boolean isWithinListStructure(java.lang.String objectName)
-
getMatchingObject
public static ASTMatchingObject getMatchingObject(java.util.List<ASTMatchingObject> allObjects, java.lang.String name)
-
-