org.andromda.metafacades.uml
Class MetafacadeUtils

java.lang.Object
  extended byorg.andromda.metafacades.uml.MetafacadeUtils

public class MetafacadeUtils
extends Object

A class containing utlities for metafacade manipulation.

Author:
Chad Brandon, Wouter Zoons

Constructor Summary
MetafacadeUtils()
           
 
Method Summary
static void filterByNotType(Collection modelElements, Class type)
          Filters out the model elements from the modelElements collection that are of (or inherit from) the specified type type
static void filterByStereotype(Collection modelElements, String stereotype)
          Filters out the model elements from the modelElements collection that don't have the specified stereotype
static void filterByType(Collection modelElements, 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 Object getElementAsType(Object element, 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 void sortByFullyQualifiedName(List metafacades)
          Sorts given metafacades by their fully qualified name.
static String toRelationName(String roleName, String targetRoleName, 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 Object getElementAsType(Object element,
                                      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(Collection modelElements,
                                      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(Collection modelElements,
                                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(Collection modelElements,
                                   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 String toRelationName(String roleName,
                                    String targetRoleName,
                                    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(List metafacades)
Sorts given metafacades by their fully qualified name.

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


Copyright © 2003-2006 The AndroMDA Team. All Rights Reserved.