nl.knowledgeplaza.util
Class TypeTokenTree

java.lang.Object
  extended by nl.knowledgeplaza.util.TypeTokenTree

public class TypeTokenTree
extends Object

http://www.jquantlib.org/index.php/Using_TypeTokens_to_retrieve_generic_parameters TypeTokenTree is a helper class intended to return a TypeToken root.

A typical usage consists on obtain a TypeToken root which can be used to traverse a hierarchy of generic parameters. Each TypeToken holds a Class information and contains a list of children nodes. A typical usage is in the context of retrieving actual generic parameters. The example below shows how a generic class can verify at instantiation time which actual generic parameters where passed by the caller. public class TimeSeries { public TimeSeries() { this.klass = new TypeTokenTree(this.getClass()).getRoot().get(0).getElement(); if (Double.class.isAssignableFrom(klass)) { this.delegate = new SeriesDouble(); } else if (IntervalPrice.class.isAssignableFrom(klass)) { this.delegate = new SeriesIntervalPrice(); } else { throw new UnsupportedOperationException("only Double and IntervalPrice are supported"); } } } Below you can see how the caller code looks like: TimeSeries ts = new TimeSeries() { } Notice that ts is an anonymous class, denoted by { }.

Author:
Richard Gomes
See Also:
Using TypeTokens to retrieve generic parameters, TypeToken

Constructor Summary
TypeTokenTree()
           
TypeTokenTree(Class<?> klass)
           
 
Method Summary
 TypeToken getRoot()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeTokenTree

public TypeTokenTree()

TypeTokenTree

public TypeTokenTree(Class<?> klass)
Method Detail

getRoot

public TypeToken getRoot()


Copyright © 2012 KnowledgePlaza. All Rights Reserved.