Package com.gengoai.reflection
Class BeanDescriptor
- java.lang.Object
-
- com.gengoai.reflection.BeanDescriptor
-
- All Implemented Interfaces:
Serializable
public final class BeanDescriptor extends Object implements Serializable
Contains basic information about the read and write methods for a bean class.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
createInstance()
Constructs an instance of the wrapped class.Object
createInstanceQuietly()
Constructs an instance of the wrapped class ignoring any errors.boolean
equals(Object obj)
Class<?>
getBeanClass()
Method
getReadMethod(String methodName)
Gets a read method by its nameSet<String>
getReadMethodNames()
Collection<Method>
getReadMethods()
Method
getWriteMethod(String methodName)
Gets a write method by its nameSet<String>
getWriteMethodNames()
Collection<Method>
getWriteMethods()
int
hashCode()
boolean
hasReadMethod(String methodName)
Determines if the descriptor has a read method named with the given string.boolean
hasWriteMethod(String methodName)
Determines if the descriptor has a write method named with the given string.int
numberOfReadMethods()
int
numberOfWriteMethods()
-
-
-
Method Detail
-
createInstance
public Object createInstance() throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
Constructs an instance of the wrapped class.- Returns:
- An instance of the wrapped class
- Throws:
InstantiationException
- Something went wrong during instantiation.IllegalAccessException
- Couldn't access the class.NoSuchMethodException
InvocationTargetException
-
createInstanceQuietly
public Object createInstanceQuietly()
Constructs an instance of the wrapped class ignoring any errors.- Returns:
- An instance of the class or
null
if something went wrong.
-
getBeanClass
public Class<?> getBeanClass()
- Returns:
- The associated class information.
-
getReadMethod
public Method getReadMethod(String methodName)
Gets a read method by its name- Parameters:
methodName
- The name of the method- Returns:
- The method with the given name or
null
-
getReadMethodNames
public Set<String> getReadMethodNames()
- Returns:
- All of the names of the read methods
-
getReadMethods
public Collection<Method> getReadMethods()
- Returns:
- All of the read methods
-
getWriteMethod
public Method getWriteMethod(String methodName)
Gets a write method by its name- Parameters:
methodName
- The name of the method- Returns:
- The method with the given name or
null
-
getWriteMethodNames
public Set<String> getWriteMethodNames()
- Returns:
- All of the names of the write methods
-
getWriteMethods
public Collection<Method> getWriteMethods()
- Returns:
- All of the write methods
-
hasReadMethod
public boolean hasReadMethod(String methodName)
Determines if the descriptor has a read method named with the given string.- Parameters:
methodName
- The read method we want to check for- Returns:
- True if the method exists, false otherwise
-
hasWriteMethod
public boolean hasWriteMethod(String methodName)
Determines if the descriptor has a write method named with the given string.- Parameters:
methodName
- The write method we want to check for- Returns:
- True if the method exists, false otherwise
-
numberOfReadMethods
public int numberOfReadMethods()
- Returns:
- The number of read methods
-
numberOfWriteMethods
public int numberOfWriteMethods()
- Returns:
- The number of write methods
-
-