org.clazzes.util.lifecycle.impl
Class ReflectionRecycler
java.lang.Object
org.clazzes.util.lifecycle.impl.AbstractObjectFactoryImpl<T>
org.clazzes.util.lifecycle.impl.AbstractRecyclerImpl<java.lang.String>
org.clazzes.util.lifecycle.impl.ReflectionRecycler
- All Implemented Interfaces:
- ObjectFactory<java.lang.String>, Recycler<java.lang.String>
public class ReflectionRecycler
- extends AbstractRecyclerImpl<java.lang.String>
- implements Recycler<java.lang.String>
A basic example implementation of Recycler
using reflection and a String
key.
Classes implementing Recyclable
must be first registered with a key using registerClass(String, Class)
.
Calling #get(String)
will then return a new instance of the class corresponding to the given key.
- Author:
- rbreuss
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReflectionRecycler
public ReflectionRecycler()
createNew
protected ObjectCreatable<java.lang.String> createNew(java.lang.String key)
- Specified by:
createNew
in class AbstractObjectFactoryImpl<java.lang.String>
registerClass
public void registerClass(java.lang.String key,
java.lang.Class<? extends ObjectCreatable<java.lang.String>> clazz)
- Registers a class for a
key
. Calling #get(String)
with a registered key will return a new
instance of the appropriate class.
- Parameters:
key
- A String
key to address the classclazz
- a class from which to create an object.
Copyright © 2010. All Rights Reserved.