pl.edu.agh.cast.model.mapper.internal
Class Helper

java.lang.Object
  extended by pl.edu.agh.cast.model.mapper.internal.Helper

public class Helper
extends Object

Helper class for the mapper - contains methods processing reflection data.

Author:
AGH CAST Team

Constructor Summary
Helper()
           
 
Method Summary
static Method getAnnotatedMethod(Class klass, String linkName)
          Return an annotated method whose annotation name is the given parameter.
static Constructor<Mappable> getConstructor(Class<Mappable> klass)
          Return default constructor for given class.
static MapLink getLinkData(Class klass, String linkName)
          Return link data (MapLink annotation) for the given mappable and link with given name.
static pl.edu.agh.cast.model.mapper.internal.AttributeEntry[] getMappedAttributes(Class<Mappable> klass)
          Get methods with MapAttribute annotations for the given class.
static pl.edu.agh.cast.model.mapper.internal.LinkEntry[] getMappedLinks(Class<Mappable> klass)
          Get methods with MapLink annotations for the given class.
static Method getSetter(Mappable object, Object linkedElement, String setterName)
          Returns the setter methods.
static boolean isSuperMapped(Class klass)
          Checks if given class is mapped to metamodel.
static Method[] mappedAttributeMethods(Class klass)
          Find all methods which have the MapAttribute annotation present.
static Class<Mappable> mappedClass(String typeName, Map<String,Class> typeMap)
          Returns the class for given type name and type map.
static Method[] mappedLinkMethods(Class klass)
          Find all methods which have the MapAttribute annotation present.
static String mappedTypeName(Class klass)
          Get mapped type name for given class.
static String objectAccessor(Class klass, String linkName)
          Returns the name of the accessor (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Helper

public Helper()
Method Detail

getConstructor

public static Constructor<Mappable> getConstructor(Class<Mappable> klass)
                                            throws SecurityException,
                                                   NoSuchMethodException
Return default constructor for given class.

Parameters:
klass - The class
Returns:
the default constructor
Throws:
SecurityException
NoSuchMethodException

objectAccessor

public static String objectAccessor(Class klass,
                                    String linkName)
Returns the name of the accessor (i.e. getter/setter name without "get/set") for the link with given name

Parameters:
klass - The klass for which the accessor is to be returned.
linkName - The name of the link.
Returns:
Accessor (getter/setter name without "get/set").

mappedTypeName

public static String mappedTypeName(Class klass)
Get mapped type name for given class. By default the type name is the same as FQ class name, but it might be different to allow polimorphic mapping

Parameters:
klass - The klass of the mapped object
Returns:
Mapped type name

getLinkData

public static MapLink getLinkData(Class klass,
                                  String linkName)
Return link data (MapLink annotation) for the given mappable and link with given name.

Parameters:
klass - The class where the link should be looked for.
linkName - The name of the link
Returns:
The MapLinkAnnotation

getAnnotatedMethod

public static Method getAnnotatedMethod(Class klass,
                                        String linkName)
Return an annotated method whose annotation name is the given parameter.

Parameters:
klass - The class for which the method is returned.
linkName - The name of the link.
Returns:
The method which is annotaded as a link with given name.

mappedAttributeMethods

public static Method[] mappedAttributeMethods(Class klass)
Find all methods which have the MapAttribute annotation present.

Parameters:
klass - Class which is searched for the methods
Returns:
Methods which have the MapAttribute annotation present.

mappedLinkMethods

public static Method[] mappedLinkMethods(Class klass)
Find all methods which have the MapAttribute annotation present.

Parameters:
klass - Class which is searched for the methods
Returns:
Methods which have the MapLink annotation present.

isSuperMapped

public static boolean isSuperMapped(Class klass)
Checks if given class is mapped to metamodel.

Parameters:
klass - Checked class
Returns:
True if the class is mapped.

getSetter

public static Method getSetter(Mappable object,
                               Object linkedElement,
                               String setterName)
Returns the setter methods. Walks through argument's class hierarchy (including implemented directly implemented interfaces) trying to find the proper setter. If not found throws RuntimeException.

Parameters:
object - The object whose class is looked for the setter.
linkedElement - The object whose class is used to determine the setters argument
setterName - The name of the setter method (with set in it.)
Returns:
Setter in class of object, which accepts linkedElement as argument.

getMappedLinks

public static pl.edu.agh.cast.model.mapper.internal.LinkEntry[] getMappedLinks(Class<Mappable> klass)
Get methods with MapLink annotations for the given class.

Parameters:
klass - The class for which methods with annotations are returned.
Returns:
Array of pairs: method -- annotation

getMappedAttributes

public static pl.edu.agh.cast.model.mapper.internal.AttributeEntry[] getMappedAttributes(Class<Mappable> klass)
Get methods with MapAttribute annotations for the given class.

Parameters:
klass - The class for which methods with annotations are returned.
Returns:
Array of pairs: method -- annotation

mappedClass

public static Class<Mappable> mappedClass(String typeName,
                                          Map<String,Class> typeMap)
                                   throws ClassNotFoundException
Returns the class for given type name and type map.

Parameters:
typeName - The name of the type in base model.
typeMap - The type map.
Returns:
The class for given type name.
Throws:
ClassNotFoundException


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.