org.ubercraft.sucre.reflect
Class Reflect

java.lang.Object
  extended by org.ubercraft.sucre.reflect.Reflect

public class Reflect
extends Object

Main entry point to get and/or register reflector factories and reflectors by type.


Field Summary
static Reflect FIELDS
          A shared instance for field-based access.
static Reflect METHODS
          A shared instance for method-based access.
 
Constructor Summary
Reflect()
          Create a new instance, defaulting to the built-in method reflection factory.
Reflect(Class<? extends ReflectorFactory> defaultFactoryClass)
          Create a new instance with the given default reflector factory type.
 
Method Summary
 void clearCache()
          Completely clears the reflector cache.
 Reflector getReflector(Class<?> type)
          Gets the reflector for a type.
 void preCache(Class<?> type)
          Causes the reflector for the given type to be pre-cached.
 void setReflectorFactoryClass(Class<?> type, Class<? extends ReflectorFactory> clazz)
          Set reflector factory class for a type (pass null factory class to unset).
 void unCache(Class<?> type)
          Removes any cached reflector for the given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHODS

public static final Reflect METHODS
A shared instance for method-based access.


FIELDS

public static final Reflect FIELDS
A shared instance for field-based access.

Constructor Detail

Reflect

public Reflect()
Create a new instance, defaulting to the built-in method reflection factory.


Reflect

public Reflect(Class<? extends ReflectorFactory> defaultFactoryClass)
Create a new instance with the given default reflector factory type.

Method Detail

setReflectorFactoryClass

public void setReflectorFactoryClass(Class<?> type,
                                     Class<? extends ReflectorFactory> clazz)
Set reflector factory class for a type (pass null factory class to unset).


preCache

public void preCache(Class<?> type)
Causes the reflector for the given type to be pre-cached.


unCache

public void unCache(Class<?> type)
Removes any cached reflector for the given type.


clearCache

public void clearCache()
Completely clears the reflector cache.


getReflector

public Reflector getReflector(Class<?> type)
Gets the reflector for a type. Hits the cache first to avoid re-creating the reflector everytime.



Copyright © 2013. All Rights Reserved.