public abstract class ObjectAttribute<O,T> extends Object
The ObjectAttribute class has the following characteristics:
get(java.lang.Object) and set(java.lang.Object,java.lang.Object) methods to implement general-purpose
setter and getter methods, thereby making the code cleaner.ObjectAttribute class to encapsulate only the accessible attribute of object B and
transfer it to object A.set(java.lang.Object,java.lang.Object) method to set an object attribute to read-only.| 构造器 | 说明 |
|---|---|
ObjectAttribute(Class<T> attrType,
String attrName) |
A constructor used to create an
ObjectAttribute instance based on the specified attribute type and name. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
abstract T |
get(O obj) |
Obtains the attribute value of a specified object.
|
Class<T> |
getAttrType() |
Obtains the type of the attribute encapsulated in the current
ObjectAttribute object. |
String |
getName() |
Obtains the name of the attribute encapsulated in the current
ObjectAttribute object. |
boolean |
isReadOnly() |
Checks whether the attribute encapsulated in the current
ObjectAttribute object is read-only. |
void |
set(O obj,
T value) |
Sets the attribute value of a specified object.
|
public abstract T get(O obj)
ObjectAttribute object.obj - Indicates the object to be accessed.ObjectAttribute object.public void set(O obj, T value)
ObjectAttribute object.obj - Indicates the object to be accessed.value - Indicates the attribute value to set.public boolean isReadOnly()
ObjectAttribute object is read-only.
If true is returned, an UnsupportedOperationException exception will be thrown when you call the
set(java.lang.Object,java.lang.Object) method.
true if the attribute is read-only, indicating that the attribute value cannot be updated
by the set(java.lang.Object,java.lang.Object) method.public String getName()
ObjectAttribute object.