org.andromda.metafacades.uml
Class MetafacadeUtils

java.lang.Object
  extended by org.andromda.metafacades.uml.MetafacadeUtils

public class MetafacadeUtils
extends java.lang.Object

A class containing utlities for metafacade manipulation.

Author:
Chad Brandon, Wouter Zoons

Constructor Summary
MetafacadeUtils()
           
 
Method Summary
static void filterByNotType(java.util.Collection modelElements, java.lang.Class type)
          Filters out the model elements from the modelElements collection that are of (or inherit from) the specified type type
static void filterByStereotype(java.util.Collection modelElements, java.lang.String stereotype)
          Filters out the model elements from the modelElements collection that don't have the specified stereotype
static void filterByType(java.util.Collection modelElements, java.lang.Class type)
          Filters out the model elements from the modelElements collection that are not of (or do not inherit from) the specified type type
static java.lang.Object getElementAsType(java.lang.Object element, java.lang.Class type)
          Checks to see if the element is the specified type and if so casts it to the object and returns it, otherwise it returns null.
static java.lang.String getSignature(java.lang.String name, java.util.Collection arguments, boolean withArgumentNames, java.lang.String argumentModifier)
          Creates a typed argument list with the given arguments.
static java.lang.String getTypedArgumentList(java.util.Collection arguments, boolean withArgumentNames, java.lang.String modifier)
          Creates a typed argument list with the given arguments.
static void sortByFullyQualifiedName(java.util.List metafacades)
          Sorts given metafacades by their fully qualified name.
static java.lang.String toRelationName(java.lang.String roleName, java.lang.String targetRoleName, java.lang.String separator)
          

Returns a consistent name for a relation, independent from the end of the relation one is looking at.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetafacadeUtils

public MetafacadeUtils()
Method Detail

getElementAsType

public static java.lang.Object getElementAsType(java.lang.Object element,
                                                java.lang.Class type)
Checks to see if the element is the specified type and if so casts it to the object and returns it, otherwise it returns null.

Parameters:
element - the element to check.
type - the Class type.
Returns:
the element has the given type or null.

filterByStereotype

public static void filterByStereotype(java.util.Collection modelElements,
                                      java.lang.String stereotype)
Filters out the model elements from the modelElements collection that don't have the specified stereotype

Parameters:
modelElements - the model elements to filter.
stereotype - the stereotype that a model element must have in order to stay remain within the modelElements collection.

filterByType

public static void filterByType(java.util.Collection modelElements,
                                java.lang.Class type)
Filters out the model elements from the modelElements collection that are not of (or do not inherit from) the specified type type

Parameters:
modelElements - the model elements to filter.
type - the type of Class.

filterByNotType

public static void filterByNotType(java.util.Collection modelElements,
                                   java.lang.Class type)
Filters out the model elements from the modelElements collection that are of (or inherit from) the specified type type

Parameters:
modelElements - the model elements to filter.
type - the type of Class.

toRelationName

public static java.lang.String toRelationName(java.lang.String roleName,
                                              java.lang.String targetRoleName,
                                              java.lang.String separator)

Returns a consistent name for a relation, independent from the end of the relation one is looking at.

In order to guarantee consistency with relation names, they must appear the same whichever angle (ie entity) that you come from. For example, if you are at Customer end of a relationship to an Address then your relation may appear with the name Customer-Address. But if you are in the Address entity looking at the Customer then you will get an error because the relation will be called Address-Customer. A simple way to guarantee that both ends of the relationship have the same name is merely to use alphabetical ordering.

Parameters:
roleName - name of role in relation
targetRoleName - name of target role in relation
separator - character used to separate words
Returns:
uniform mapping name (in alphabetical order)

sortByFullyQualifiedName

public static void sortByFullyQualifiedName(java.util.List metafacades)
Sorts given metafacades by their fully qualified name.

Parameters:
metafacades - the collection of model elements to sort.

getTypedArgumentList

public static java.lang.String getTypedArgumentList(java.util.Collection arguments,
                                                    boolean withArgumentNames,
                                                    java.lang.String modifier)
Creates a typed argument list with the given arguments. If the withArgumentNames flag is true, the argument names are included in the list.

Parameters:
arguments - the arguments from which to create the list.
withArgumentNames - whether or not to include the argument names.
modifier -

getSignature

public static java.lang.String getSignature(java.lang.String name,
                                            java.util.Collection arguments,
                                            boolean withArgumentNames,
                                            java.lang.String argumentModifier)
Creates a typed argument list with the given arguments. If the withArgumentNames flag is true, the argument names are included in the list.

Parameters:
arguments - the arguments from which to create the list.
withArgumentNames - whether or not to include the argument names.
modifier -


Copyright © 2003-2008 AndroMDA.org. All Rights Reserved.