Package net.sf.cglib.beans
Class BeanMap.Generator
- java.lang.Object
-
- net.sf.cglib.core.AbstractClassGenerator
-
- net.sf.cglib.beans.BeanMap.Generator
-
- All Implemented Interfaces:
ClassGenerator
- Enclosing class:
- BeanMap
public static class BeanMap.Generator extends AbstractClassGenerator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.cglib.core.AbstractClassGenerator
AbstractClassGenerator.ClassLoaderData, AbstractClassGenerator.Source
-
-
Constructor Summary
Constructors Constructor Description Generator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanMap
create()
Create a new instance of theBeanMap
.protected Object
firstInstance(Class type)
void
generateClass(org.objectweb.asm.ClassVisitor v)
protected ClassLoader
getDefaultClassLoader()
protected ProtectionDomain
getProtectionDomain()
Returns the protection domain to use when defining the class.protected Object
nextInstance(Object instance)
void
setBean(Object bean)
Set the bean that the generated map should reflect.void
setBeanClass(Class beanClass)
Set the class of the bean that the generated map should support.void
setRequire(int require)
Limit the properties reflected by the generated map.-
Methods inherited from class net.sf.cglib.core.AbstractClassGenerator
create, generate, getAttemptLoad, getClassLoader, getClassName, getCurrent, getNamingPolicy, getStrategy, getUseCache, setAttemptLoad, setClassLoader, setNamePrefix, setNamingPolicy, setStrategy, setUseCache, unwrapCachedValue, wrapCachedClass
-
-
-
-
Method Detail
-
setBean
public void setBean(Object bean)
Set the bean that the generated map should reflect. The bean may be swapped out for another bean of the same type usingsetBean(java.lang.Object)
. Calling this method overrides any value previously set usingsetBeanClass(java.lang.Class)
. You must call either this method orsetBeanClass(java.lang.Class)
beforecreate()
.- Parameters:
bean
- the initial bean
-
setBeanClass
public void setBeanClass(Class beanClass)
Set the class of the bean that the generated map should support. You must call either this method orsetBeanClass(java.lang.Class)
beforecreate()
.- Parameters:
beanClass
- the class of the bean
-
setRequire
public void setRequire(int require)
Limit the properties reflected by the generated map.- Parameters:
require
- any combination ofBeanMap.REQUIRE_GETTER
andBeanMap.REQUIRE_SETTER
; default is zero (any property allowed)
-
getDefaultClassLoader
protected ClassLoader getDefaultClassLoader()
- Specified by:
getDefaultClassLoader
in classAbstractClassGenerator
-
getProtectionDomain
protected ProtectionDomain getProtectionDomain()
Description copied from class:AbstractClassGenerator
Returns the protection domain to use when defining the class.Default implementation returns
null
for using a default protection domain. Sub-classes may override to use a more specific protection domain.- Overrides:
getProtectionDomain
in classAbstractClassGenerator
- Returns:
- the protection domain (
null
for using a default)
-
create
public BeanMap create()
Create a new instance of theBeanMap
. An existing generated class will be reused if possible.
-
generateClass
public void generateClass(org.objectweb.asm.ClassVisitor v) throws Exception
- Throws:
Exception
-
firstInstance
protected Object firstInstance(Class type)
- Specified by:
firstInstance
in classAbstractClassGenerator
-
nextInstance
protected Object nextInstance(Object instance)
- Specified by:
nextInstance
in classAbstractClassGenerator
-
-