public class ClassMock extends Object implements IClassReader, IClassWriter, Cloneable
| Modifier and Type | Method and Description |
|---|---|
IAnnotationPropertyWriter |
annotation(Class<? extends Annotation> annotation)
Add an annotation to this.
|
IAnnotationPropertyWriter |
annotation(Class<? extends Annotation> annotation,
LocationEnum location)
Add an annotation and defining the location of it.
|
IAnnotationPropertyWriter |
annotation(IAnnotationReader annotation)
Add a annotation wrapper to this.
|
Collection<IAnnotationReader> |
annotations()
List all the annotations defined for your entity.
|
IClassWriter |
asAbstract()
Define your generated entity to be an Abstract Class.
|
IClassWriter |
asAnnotation()
Define your generated entity to be an Annotation.
|
IClassWriter |
asClass()
Define your generated entity to be a Concrete Class (default).
|
IClassWriter |
asEnum()
Define your generated entity to be an Enum.
|
IClassWriter |
asInterface()
Define your generated entity to be an Interface.
|
Class<?> |
build()
Build your entity.
|
protected Object |
clone() |
IClassWriter |
clone(String name)
Define a clone of all defined for your entity,
but with a new name because the old one is already in use.
|
boolean |
equals(Object obj) |
IFieldWriter |
field(String name,
Class<?> type)
Add a field to your entity.
|
IFieldWriter |
fieldByParse(String fieldSignature)
Define a way to parse a field with all properties and annotations from a String.
|
Collection<IFieldReader> |
fields()
List all the fields defined for your entity.
|
int |
hashCode() |
Collection<Class<?>> |
interfaces()
List the interfaces that your generated entity will implements.
|
IClassWriter |
interfaces(Class<?>... classes)
Define the interfaces that your generated entity will implements.
|
boolean |
isAbstract()
Inform if it's an Abstract Class.
|
boolean |
isAnnotation()
Inform if it's an Annotation.
|
boolean |
isClass()
Inform if it's a Concrete Class.
|
boolean |
isEnum()
Inform if it's an Enum.
|
boolean |
isInterface()
Inform if it's an Interface.
|
IMethodWriter |
method(IMethodReader method)
Add a method to your entity.
|
IMethodWriter |
method(String name)
Add a method to your entity.
|
IMethodWriter |
methodByParse(String methodSignature)
Define a way to parse a method with all properties and annotations from a String.
|
Collection<IMethodReader> |
methods()
List all the methods defined for your entity.
|
Collection<ModifierEnum> |
modifiers()
Inform the modifiers that you want in your entity.
|
IClassWriter |
modifiers(ModifierEnum... modifiers)
Define the modifiers that you want in your entity.
|
String |
name()
Inform the defined name.
|
IClassWriter |
name(String name)
Define the name of your entity, you can also inform the package as a prefix.
|
static IClassWriter |
of(String name)
Define a name for your Entity.
|
ISuperClassReader |
superclass()
Inform the super class that your generated entity will extends.
|
ISuperClassWriter |
superclass(Class<?> superclass)
Define a super class that your generated entity will extends.
|
String |
toString() |
JavaEnum |
version()
Inform the version of JRE that your entity will be compiled.
|
IClassWriter |
version(JavaEnum javaEnum)
Define the version of JRE that your entity will be compiled.
|
VisibilityEnum |
visibility()
Inform the visibility of your entity.
|
IClassWriter |
visibility(VisibilityEnum visibility)
Define the visibility of your entity.
|
public static IClassWriter of(String name)
name - of the entitypublic IClassWriter asClass()
IClassWriterasClass in interface IClassWriterpublic IClassWriter asInterface()
IClassWriterasInterface in interface IClassWriterpublic IClassWriter asAbstract()
IClassWriterasAbstract in interface IClassWriterpublic IClassWriter asEnum()
IClassWriterasEnum in interface IClassWriterpublic IClassWriter asAnnotation()
IClassWriterasAnnotation in interface IClassWriterpublic IClassWriter name(String name)
IClassWriterEx: my.fake.package.MyGenericDynClass
name in interface IClassWritername - of the entitypublic IClassWriter visibility(VisibilityEnum visibility)
IClassWriterEx: PUBLIC, PRIVATE or PROTECTED
visibility in interface IClassWritervisibility - of the entitypublic ISuperClassWriter superclass(Class<?> superclass)
IClassWritersuperclass in interface IClassWritersuperclass - to be extendedpublic IClassWriter interfaces(Class<?>... classes)
IClassWriterinterfaces in interface IClassWriterclasses - of interfacespublic IAnnotationPropertyWriter annotation(Class<? extends Annotation> annotation)
IAnnotationWriterannotation in interface IAnnotationWriterannotation - to associatepublic IAnnotationPropertyWriter annotation(Class<? extends Annotation> annotation, LocationEnum location)
IAnnotationWriterannotation in interface IAnnotationWriterannotation - to associatelocation - to bepublic IAnnotationPropertyWriter annotation(IAnnotationReader annotation)
IAnnotationWriterannotation in interface IAnnotationWriterannotation - to associatepublic IFieldWriter field(String name, Class<?> type)
IClassWriterfield in interface IClassWritername - of the fieldtype - class type of the fieldpublic IFieldWriter fieldByParse(String fieldSignature)
IClassWriter- Semicolon is Optional
- Is better specify all class type with their respective packages, if you don't it will try to find your class type for you. So, it is possible to load a class type with the same name but in a different package.
Ex:
java.lang.String myField; // the default visibility is private
Ex:
final static String myField; // with modifiers (static and final)
Ex:
public String myField; // with visibility (public)
Ex:
private static final String myField; // with visibility and modifiers
Ex:
@Id // with annotation
@Column(name = \"MY_COLUMN_NAME\", nullable = false) // annotation and properties
private static final String myField; // with visibility and modifiers
fieldByParse in interface IClassWriterfieldSignature - the signature of your field to parse.public IMethodWriter method(IMethodReader method)
IClassWritermethod in interface IClassWritermethod - to be addedpublic IMethodWriter method(String name)
IClassWritermethod in interface IClassWritername - of the method to be addedpublic IMethodWriter methodByParse(String methodSignature)
IClassWriter- parentheses and braces are Optional
- Is better specify all class type with their respective packages, if you don't it will try to find your class type for you. So, it is possible to load a class type with the same name but in a different package.
Ex:
java.lang.String getMyMethod(){}; // the default visibility is public
Ex:
final static String getMyMethod; // with modifiers (static and final)
Ex:
public String getMyMethod; // with visibility (public)
Ex:
private static final String getMyMethod; // with visibility and modifiers
Ex:
@Id // with annotation
@Column(name = \"MY_COLUMN_NAME\", nullable = false) // annotation
private static final String getMyMethod; // with visibility and modifiers
Ex:
public String findById(@NotNull String code) throws NullPointerException; // with parameter and exception
methodByParse in interface IClassWritermethodSignature - the signature of your method to parse.public boolean isClass()
IClassReaderisClass in interface IClassReaderpublic boolean isInterface()
IClassReaderisInterface in interface IClassReaderpublic boolean isAbstract()
IClassReaderisAbstract in interface IClassReaderpublic boolean isEnum()
IClassReaderisEnum in interface IClassReaderpublic boolean isAnnotation()
IClassReaderisAnnotation in interface IClassReaderpublic String name()
IClassReadername in interface IClassReaderpublic VisibilityEnum visibility()
IClassReadervisibility in interface IClassReaderpublic ISuperClassReader superclass()
IClassReadersuperclass in interface IClassReaderpublic Collection<Class<?>> interfaces()
IClassReaderinterfaces in interface IClassReaderpublic Collection<IFieldReader> fields()
IClassReaderfields in interface IClassReaderpublic Collection<IMethodReader> methods()
IClassReadermethods in interface IClassReaderpublic Collection<IAnnotationReader> annotations()
IClassReaderannotations in interface IClassReaderpublic IClassWriter modifiers(ModifierEnum... modifiers)
IClassWriterEx: FINAL, ABSTRACT...
modifiers in interface IClassWritermodifiers - of the entitypublic Collection<ModifierEnum> modifiers()
IClassReadermodifiers in interface IClassReaderpublic IClassWriter version(JavaEnum javaEnum)
IClassWriterversion in interface IClassWriterjavaEnum - the version of java entitypublic JavaEnum version()
IClassReaderversion in interface IClassReaderpublic Class<?> build()
IClassWriterbuild in interface IClassWriterprotected Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic IClassWriter clone(String name)
IClassWriterclone in interface IClassWritername - of your new entityCopyright © 2018 Esfinge Framework. All rights reserved.