- java.lang.Object
-
- io.github.mmm.bean.generator.BeanMethod
-
- Direct Known Subclasses:
BeanMethodGetter,BeanMethodProperty,BeanMethodSetter
public abstract class BeanMethod extends Object
Wrapper for aMethodof aWritableBean.- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected Methodmethodprotected StringpropertyName
-
Constructor Summary
Constructors Constructor Description BeanMethod(Method method, String propertyName)The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MethodgetMethod()StringgetParameterName()StringgetPropertyName()abstract Class<?>getPropertyType()booleanisSpecialized(BeanMethod other)static BeanMethodof(Method method)voidwrite(Writer writer)Writes the method.protected abstract voidwriteBody(Writer writer)Writes the method body (implementation).protected voidwriteParameters(Writer writer)Writes the method parameters.
-
-
-
Field Detail
-
method
protected final Method method
- See Also:
getMethod()
-
propertyName
protected final String propertyName
- See Also:
getPropertyName()
-
-
Constructor Detail
-
BeanMethod
public BeanMethod(Method method, String propertyName)
The constructor.- Parameters:
method- themethod.propertyName- theproperty name.
-
-
Method Detail
-
write
public void write(Writer writer) throws IOException
Writes the method.- Parameters:
writer- theWriter.- Throws:
IOException- on error.
-
writeParameters
protected void writeParameters(Writer writer) throws IOException
Writes the method parameters.- Parameters:
writer- theWriter.- Throws:
IOException- on error.
-
writeBody
protected abstract void writeBody(Writer writer) throws IOException
Writes the method body (implementation).- Parameters:
writer- theWriter.- Throws:
IOException- on error.
-
getPropertyName
public String getPropertyName()
- Returns:
- property the name of the property handled by this method.
-
getParameterName
public String getParameterName()
- Returns:
- property the name of the property handled by this method.
-
getPropertyType
public abstract Class<?> getPropertyType()
- Returns:
- the
Classreflecting the {ReadablePropertytype of the property value(and not thepropertyitself).
-
of
public static BeanMethod of(Method method)
- Parameters:
method- theMethodto introspect.- Returns:
- the corresponding
BeanMethodornullif not aBeanMethod(to implement).
-
isSpecialized
public boolean isSpecialized(BeanMethod other)
- Parameters:
other- theBeanMethodto compare.- Returns:
trueifthisBeanMethodis more specialized than the given one (e.g. it overrides the given method),falseotherwise.
-
-