Package org.nuiton.eugene.models.object
Class ObjectModelBuilder
- java.lang.Object
-
- org.nuiton.eugene.models.object.ObjectModelBuilder
-
- Direct Known Subclasses:
JavaBuilder
public class ObjectModelBuilder extends Object
Builder to fill an empty ObjectModel. The object model name is important if you want to use the model in generators. Created: 3 nov. 2009- Author:
- Florian Desbois - desbois@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectModelImpl
model
-
Constructor Summary
Constructors Constructor Description ObjectModelBuilder(String name)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectModelAttribute
addAssociation(ObjectModelClassifier classifierA, ObjectModelClassifier classifierB, String roleName, int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
Add an association A to B.ObjectModelAttribute
addAttribute(ObjectModelClassifier classifier, String name, String type)
Add an attribute to a classifier (interface, class, enum) without default value.ObjectModelAttribute
addAttribute(ObjectModelClassifier classifier, String name, String type, String value, ObjectModelModifier... modifiers)
Add an attribute to a classifier (interface, class, enum).void
addComment(ObjectModelElement element, String comment)
Add a comment to an element.void
addException(ObjectModelOperation operation, String exception)
Add an exception to an operation.ObjectModelClassifier
addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name, ObjectModelModifier... modifiers)
Add a superclass to an other class.void
addInterface(ObjectModelClassifier classifier, String interfaceQualifiedName)
Add an interface to a classifier.void
addLiteral(ObjectModelEnumeration enumz, String name)
ObjectModelOperation
addOperation(ObjectModelClassifier classifier, String name, String returnType, ObjectModelModifier... modifiers)
Add an operation to a classifier.ObjectModelOperation
addOperation(ObjectModelClassifier classifier, ObjectModelOperation operation)
Add an operation to a classifier.ObjectModelParameter
addParameter(ObjectModelOperation operation, String type, String name)
Add a parameter to an operation.ObjectModelAttribute
addReverseAssociation(ObjectModelAttribute attrAssociation, String roleName, int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
Create reverse association from an other association.void
addStereotype(ObjectModelElement element, String stereotype)
Add a stereotype to an element.void
addSuperclass(ObjectModelClass clazz, String superclassQualifiedName)
Add a superclass to an other class.void
addTagValue(String name, String value)
Add a tagValue to the model.void
addTagValue(ObjectModelElement element, String name, String value)
Add a tagValue to an elementObjectModelAssociationClass
createAssociationClass(String name, String packageName, ObjectModelAttribute attrAssociationA, ObjectModelAttribute attrAssociationB, ObjectModelModifier... modifiers)
Create association class.ObjectModelClass
createClass(String name, String packageName, ObjectModelModifier... modifiers)
Create a new class in the model.protected ObjectModelClass
createClass(ObjectModelClassImpl clazz, String name, String packageName, ObjectModelModifier... modifiers)
ObjectModelEnumeration
createEnumeration(String name, String packageName)
Create a new interface in the model.ObjectModelInterface
createInterface(String name, String packageName)
Create a new interface in the model.ObjectModel
getModel()
Get the building modelprotected void
setClassModifiers(ObjectModelClassImpl clazz, ObjectModelModifier... modifiers)
Set modifiers to a class.void
setDocumentation(ObjectModelElement element, String documentation)
Set the documentation of an element in the model.void
setMaxMultiplicity(ObjectModelAttribute attribute, int multiplicity)
Set the max multiplicity of an attribute in the model.void
setMinMultiplicity(ObjectModelAttribute attribute, int multiplicity)
Set the min multiplicity of an attribute in the model.void
setNavigable(ObjectModelAttribute attribute, boolean navigable)
Set the navigable flag of an attribute in the model.void
setOperationBody(ObjectModelOperation operation, String body)
Set the body code for an Operation.
-
-
-
Field Detail
-
model
protected ObjectModelImpl model
-
-
Constructor Detail
-
ObjectModelBuilder
public ObjectModelBuilder(String name)
Constructor. Must have a name for the new model created.- Parameters:
name
- model name
-
-
Method Detail
-
getModel
public ObjectModel getModel()
Get the building model- Returns:
- the ObjectModel which is currently built
-
addTagValue
public void addTagValue(String name, String value)
Add a tagValue to the model.- Parameters:
name
- tagValue namevalue
- tagValue value
-
addTagValue
public void addTagValue(ObjectModelElement element, String name, String value)
Add a tagValue to an element- Parameters:
element
- where the tag value will be addedname
- tagValue namevalue
- tagValue value
-
createClass
public ObjectModelClass createClass(String name, String packageName, ObjectModelModifier... modifiers)
Create a new class in the model. Modifiers allowed : ABSTRACT, STATIC.- Parameters:
name
- class namepackageName
- class packagemodifiers
- class modifiers- Returns:
- the new ObjectModelClass added to the model
-
createClass
protected ObjectModelClass createClass(ObjectModelClassImpl clazz, String name, String packageName, ObjectModelModifier... modifiers) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
setClassModifiers
protected void setClassModifiers(ObjectModelClassImpl clazz, ObjectModelModifier... modifiers) throws IllegalArgumentException
Set modifiers to a class. Only STATIC and ABSTRACT are actually supported.- Parameters:
clazz
- ObjectModelClassImpl where modifiers will be setmodifiers
- Array of ObjectModelModifier to set- Throws:
IllegalArgumentException
- for unsupported modifier
-
createInterface
public ObjectModelInterface createInterface(String name, String packageName)
Create a new interface in the model.- Parameters:
name
- interface namepackageName
- interface package- Returns:
- the new ObjectModelInterface added to the model
-
createEnumeration
public ObjectModelEnumeration createEnumeration(String name, String packageName)
Create a new interface in the model.- Parameters:
name
- interface namepackageName
- interface package- Returns:
- the new ObjectModelInterface added to the model
-
addAttribute
public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type)
Add an attribute to a classifier (interface, class, enum) without default value. Default visibility is set to PUBLIC.- Parameters:
classifier
- where the attribute will be addedname
- attribute nametype
- attribute type (full qualified name)- Returns:
- the new ObjectModelAttribute added
-
addAttribute
public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type, String value, ObjectModelModifier... modifiers) throws IllegalArgumentException
Add an attribute to a classifier (interface, class, enum). Modifiers allowed : STATIC, FINAL, TRANSIENT, PUBLIC, PRIVATE, PROTECTED, PACKAGE, ORDERED, UNIQUE. The last visibility set will be keeped.- Parameters:
classifier
- where the attribute will be addedname
- attribute nametype
- attribute type (full qualified name)value
- default value for the attributemodifiers
- attribute modifiers- Returns:
- the new ObjectModelAttribute added
- Throws:
IllegalArgumentException
- illegal Modifier- See Also:
ObjectModelModifier.isVisibility()
-
addAssociation
public ObjectModelAttribute addAssociation(ObjectModelClassifier classifierA, ObjectModelClassifier classifierB, String roleName, int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers) throws IllegalArgumentException
Add an association A to B. Create only attribute association for classifierA. MODIFIERS allowed : PUBLIC, PRIVATE, PACKAGE, PROTECTED, AGGREGATE, COMPOSITE, ORDERED, UNIQUE STATIC, NAVIGABLE. You have to use methodaddReverseAssociation(ObjectModelAttribute, String, int, int, ObjectModelModifier...)
to create attribute association for classifierB.- Parameters:
classifierA
- classifier fromclassifierB
- classifier toroleName
- role of A in associationminMultiplicity
- minimum multiplicity of A in associationmaxMultiplicity
- maximum multiplicity of A in associationmodifiers
- for the association- Returns:
- the attribute corresponding to the association for classifierA
- Throws:
IllegalArgumentException
- illegal modifier
-
addReverseAssociation
public ObjectModelAttribute addReverseAssociation(ObjectModelAttribute attrAssociation, String roleName, int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
Create reverse association from an other association. MODIFIERS allowed : PUBLIC, PRIVATE, PACKAGE, PROTECTED, AGGREGATE, COMPOSITE, ORDERED, UNIQUE STATIC, NAVIGABLE.- Parameters:
attrAssociation
- other association A to BroleName
- role of B in associationminMultiplicity
- minimum multiplicity of B in associationmaxMultiplicity
- maximum multiplicity of B in associationmodifiers
- for the association- Returns:
- the attribute corresponding to the association for classifierB
- See Also:
addAssociation(ObjectModelClassifier, ObjectModelClassifier, String, int, int, ObjectModelModifier...)
-
createAssociationClass
public ObjectModelAssociationClass createAssociationClass(String name, String packageName, ObjectModelAttribute attrAssociationA, ObjectModelAttribute attrAssociationB, ObjectModelModifier... modifiers)
Create association class. The two extremities of the association must be existing before creating the association class. Modifiers allowed : ABSTRACT, STATIC.- Parameters:
name
- association class namepackageName
- association package nameattrAssociationA
- attribute association for classifierA involved in association classattrAssociationB
- attribute association for classifierB involved in association classmodifiers
- for the association class- Returns:
- the new association class created with participants A and B
-
addOperation
public ObjectModelOperation addOperation(ObjectModelClassifier classifier, String name, String returnType, ObjectModelModifier... modifiers) throws IllegalArgumentException
Add an operation to a classifier. Modifiers allowed : STATIC, ABSTRACT, PUBLIC, PRIVATE, PROTECTED, PACKAGE. The last visibility set will be keeped.- Parameters:
classifier
- where the operation will be addedname
- operation namereturnType
- operation type (full qualified name)modifiers
- operation modifiers- Returns:
- the new ObjectModelOperation added
- Throws:
IllegalArgumentException
- illegal Modifier
-
addOperation
public ObjectModelOperation addOperation(ObjectModelClassifier classifier, ObjectModelOperation operation)
Add an operation to a classifier. Modifiers allowed : STATIC, ABSTRACT, PUBLIC, PRIVATE, PROTECTED, PACKAGE. The last visibility set will be keeped.- Parameters:
classifier
- where the operation will be addedoperation
- operation to add- Returns:
- the added operation (says the given parameter)
- Since:
- 2.1.2
-
setOperationBody
public void setOperationBody(ObjectModelOperation operation, String body)
Set the body code for an Operation.- Parameters:
operation
- where the code will be addedbody
- code to add to the operation
-
addInterface
public void addInterface(ObjectModelClassifier classifier, String interfaceQualifiedName)
Add an interface to a classifier. The interface may not exist in model.- Parameters:
classifier
- where the interface will be addedinterfaceQualifiedName
- interface qualified name
-
addSuperclass
public void addSuperclass(ObjectModelClass clazz, String superclassQualifiedName)
Add a superclass to an other class. The superclass may not exist in model.- Parameters:
clazz
- where the superclass will be addedsuperclassQualifiedName
- superclass qualified name
-
addInnerClassifier
public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name, ObjectModelModifier... modifiers) throws IllegalArgumentException
Add a superclass to an other class. The superclass may not exist in model.- Parameters:
clazz
- where the superclass will be addedtype
- type of inner classifier to createname
- superclass qualified namemodifiers
- modifiers of the inner classifier- Returns:
- the new instanciated inner classifier
- Throws:
IllegalArgumentException
- if giventype
is not a concrete classifier type
-
addParameter
public ObjectModelParameter addParameter(ObjectModelOperation operation, String type, String name)
Add a parameter to an operation.- Parameters:
operation
- where the parameter will be addedtype
- paremeter type (full qualified name)name
- parameter name- Returns:
- the new ObjectModelParameter added
-
addException
public void addException(ObjectModelOperation operation, String exception)
Add an exception to an operation.- Parameters:
operation
- where the exception will be addedexception
- name of the exception (full qualified name)
-
setDocumentation
public void setDocumentation(ObjectModelElement element, String documentation)
Set the documentation of an element in the model.- Parameters:
element
- where the documentation will be setteddocumentation
- String documentation for the element
-
addStereotype
public void addStereotype(ObjectModelElement element, String stereotype)
Add a stereotype to an element.- Parameters:
element
- where the stereotype will be addedstereotype
- name
-
addLiteral
public void addLiteral(ObjectModelEnumeration enumz, String name)
-
addComment
public void addComment(ObjectModelElement element, String comment)
Add a comment to an element.- Parameters:
element
- where the comment will be addedcomment
- comment to add- Since:
- 2.1.2
-
setMinMultiplicity
public void setMinMultiplicity(ObjectModelAttribute attribute, int multiplicity)
Set the min multiplicity of an attribute in the model.- Parameters:
attribute
- where the multiplicity will be settedmultiplicity
- String description for the element
-
setMaxMultiplicity
public void setMaxMultiplicity(ObjectModelAttribute attribute, int multiplicity)
Set the max multiplicity of an attribute in the model.- Parameters:
attribute
- where the multiplicity will be settedmultiplicity
- String description for the element
-
setNavigable
public void setNavigable(ObjectModelAttribute attribute, boolean navigable)
Set the navigable flag of an attribute in the model.- Parameters:
attribute
- where the navigable flag will be settednavigable
- navigable flag value to set- Since:
- 2.3
-
-