ca.infoway.messagebuilder.j5goodies
Class Generics

Package class diagram package Generics
java.lang.Object
  extended by ca.infoway.messagebuilder.j5goodies.Generics

public class Generics
extends Object

This class provides some utilities for dealing with Generics in the bean definitions of collections.

Author:
BC Holmes

Constructor Summary
Generics()
           
 
Method Summary
static Type getParameterType(PropertyDescriptor descriptor)
          Determine the return type of a collection property.
static Type getParameterType(Type type)
          Get the type of a particular parameterized type.
static boolean isCollectionParameterizedType(Type type)
          This method is used to determine if the type is a Parameterized Type that implements the Collection interface (typically a List or a Set).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Generics

public Generics()
Method Detail

getParameterType

public static Type getParameterType(PropertyDescriptor descriptor)

Determine the return type of a collection property. For example, consider the following getter:

 public List<String> getNames() {
    ...
 }
 

In this case, the getElementType method will return "String".

Parameters:
descriptor - - the property descriptor of the generic property
Returns:
- the Type of the parameterized return type

getParameterType

public static Type getParameterType(Type type)

Get the type of a particular parameterized type.

Parameters:
type - - the generic return type
Returns:
- the Type of the parameterized return type

isCollectionParameterizedType

public static boolean isCollectionParameterizedType(Type type)

This method is used to determine if the type is a Parameterized Type that implements the Collection interface (typically a List or a Set). Note that Maps do not implement the Collection interface.

Parameters:
type - - the generic return type
Returns:
- true if the type is a collection type that is parameterized


Copyright © 2013. All Rights Reserved.