org.decisiondeck.jmcda.xws.transformer
Class Transformers<F>

java.lang.Object
  extended by org.decisiondeck.jmcda.xws.transformer.Transformers<F>
Type Parameters:
F - the function type.

public class Transformers<F>
extends Object

Contains a set of functions, called transformers, accessible by return type. One transformer maximum for a given return type.


Constructor Summary
Transformers()
           
Transformers(boolean uniqueInputType, boolean uniqueReturnType)
           
Transformers(Set<F> functions)
          Creates a transformers object holding the given functions.
 
Method Summary
 void add(F function)
          Adds the given function to this set of functions.
 void addAll(Set<F> functions)
          Adds all the given functions to this set of functions.
 boolean containsFromTypeExact(Type fromType)
          Tests whether the given from type has an associated function.
 boolean containsReturnType(Type returnType)
          Tests whether the given return type has an associated function.
 Method getApplyMethod(Class<? extends F> function)
          Retrieves the apply method of the given class implementing a function.
static Method getApplyMethodGeneric(Class<?> function)
          Retrieves the apply method of the given class.
 Type getRequired(Type returnType)
          Retrieves the type of the required parameter to use the function associated to the given return type, or the function compatible with the given return type.
 F getTransformerFromExact(Type fromType)
          Retrieves the transformer function associated with the given input type.
 F getTransformerFromLaxist(Type fromType)
          Retrieves the transformer function associated with the given input type, or that is able to transform the given input type.
 F getTransformerTo(Type returnType)
          Retrieves the transformer function associated with the given return type.
 F getTransformerToLaxist(Type returnType)
          Retrieves the transformer function that returns the given type, or if no exact transformer is found, the transformer that is able to return the given type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transformers

public Transformers(boolean uniqueInputType,
                    boolean uniqueReturnType)

Transformers

public Transformers(Set<F> functions)
Creates a transformers object holding the given functions. No reference is kept to the given set.

Parameters:
functions - not null.

Transformers

public Transformers()
Method Detail

addAll

public void addAll(Set<F> functions)
Adds all the given functions to this set of functions.

Parameters:
functions - not null.

add

public void add(F function)
Adds the given function to this set of functions.

Parameters:
function - not null.

containsReturnType

public boolean containsReturnType(Type returnType)
Tests whether the given return type has an associated function.

Parameters:
returnType - not null.
Returns:
true iff at least one function in this object has the given return type.

containsFromTypeExact

public boolean containsFromTypeExact(Type fromType)
Tests whether the given from type has an associated function.

Parameters:
fromType - not null.
Returns:
true iff at least one function in this object has the given type as input type.

getApplyMethodGeneric

public static Method getApplyMethodGeneric(Class<?> function)
Retrieves the apply method of the given class. Only one apply method must be declared, or one with object types and one with non-object types, the later one being chosen in this case. The returned method is guaranteed to have only one parameter.

Parameters:
function - not null.
Returns:
not null.

getApplyMethod

public Method getApplyMethod(Class<? extends F> function)
Retrieves the apply method of the given class implementing a function. Only one apply method must be declared, or one with object types and one with non-object types, the later one being chosen in this case. The returned method is guaranteed to have only one parameter.

Parameters:
function - not null.
Returns:
not null.

getRequired

public Type getRequired(Type returnType)
Retrieves the type of the required parameter to use the function associated to the given return type, or the function compatible with the given return type. The return type must have a unique associated function.

Parameters:
returnType - not null.
Returns:
not null.
See Also:
containsReturnType(Type)

getTransformerFromExact

public F getTransformerFromExact(Type fromType)
Retrieves the transformer function associated with the given input type. The input type must be associated with a unique function.

Parameters:
fromType - not null.
Returns:
not null.

getTransformerFromLaxist

public F getTransformerFromLaxist(Type fromType)
Retrieves the transformer function associated with the given input type, or that is able to transform the given input type. There must be a unique function satisfying that definition, if inexact. For example, if a transformer function is defined from List, and the given from type is LinkedList, that function is returned.

Parameters:
fromType - not null.
Returns:
null iff not found.

getTransformerTo

public F getTransformerTo(Type returnType)
Retrieves the transformer function associated with the given return type. The return type must be contained in this object.

Parameters:
returnType - not null, in this object.
Returns:
not null.

getTransformerToLaxist

public F getTransformerToLaxist(Type returnType)
Retrieves the transformer function that returns the given type, or if no exact transformer is found, the transformer that is able to return the given type. There must be at most one exact function. If inexact, there must be at most one compatible function.

Parameters:
returnType - not null.
Returns:
null if not found.


Copyright © 2011. All Rights Reserved.