Class 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
    • 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 name
        value - 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 added
        name - tagValue name
        value - 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 name
        packageName - class package
        modifiers - class modifiers
        Returns:
        the new ObjectModelClass added to the model
      • createInterface

        public ObjectModelInterface createInterface​(String name,
                                                    String packageName)
        Create a new interface in the model.
        Parameters:
        name - interface name
        packageName - 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 name
        packageName - 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 added
        name - attribute name
        type - attribute type (full qualified name)
        Returns:
        the new ObjectModelAttribute added
      • 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 name
        packageName - association package name
        attrAssociationA - attribute association for classifierA involved in association class
        attrAssociationB - attribute association for classifierB involved in association class
        modifiers - 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 added
        name - operation name
        returnType - 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 added
        operation - 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 added
        body - 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 added
        interfaceQualifiedName - 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 added
        superclassQualifiedName - superclass qualified name
      • addParameter

        public ObjectModelParameter addParameter​(ObjectModelOperation operation,
                                                 String type,
                                                 String name)
        Add a parameter to an operation.
        Parameters:
        operation - where the parameter will be added
        type - 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 added
        exception - 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 setted
        documentation - 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 added
        stereotype - name
      • addComment

        public void addComment​(ObjectModelElement element,
                               String comment)
        Add a comment to an element.
        Parameters:
        element - where the comment will be added
        comment - 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 setted
        multiplicity - 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 setted
        multiplicity - 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 setted
        navigable - navigable flag value to set
        Since:
        2.3