public class MappedObject
extends java.lang.Object
implements java.util.Map<java.lang.String,java.lang.Object>
Map
interface where the field names are the keys.
The contained object can be replaced whenever needed.
Constructor and Description |
---|
MappedObject(java.lang.Object object)
Creates an instance on the given object and ignores problems silently.
|
MappedObject(java.lang.Object object,
boolean silent)
Creates an instance on the given object and handles
problems silently if silent is true, otherwise problems
will cause a
ReflectionException . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Does nothing.
|
boolean |
containsKey(java.lang.Object fieldName) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> |
entrySet() |
java.lang.Object |
get(java.lang.Object fieldName) |
protected FieldProxy<java.lang.Object> |
getFieldAccessor(java.lang.String fieldName) |
protected java.util.Map<java.lang.String,FieldProxy<java.lang.Object>> |
getFieldAccessors() |
java.lang.Object |
getObject()
Returns the original object wrapped by this to a
Map interface. |
java.lang.Class<?> |
getObjectType()
Returns the type of the wrapped object.
|
protected void |
handleProblem(java.lang.String message,
java.lang.Object... args)
Ignores the problem if silent=true, otherwise throws a
ReflectionException . |
protected void |
initFieldAccessors() |
boolean |
isEmpty() |
boolean |
isNull()
Returns whether or not the underlying object is null.
|
boolean |
isSilent()
Returns true if this object has been configured to ignore
exceptions silently.
|
java.util.Set<java.lang.String> |
keySet()
Returns all field names of the underlying object.
|
java.lang.Object |
put(java.lang.String fieldName,
java.lang.Object value) |
void |
putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map) |
java.lang.Object |
remove(java.lang.Object fieldName)
Returns the value for the given fieldName, but does not remove anything.
|
void |
setObject(java.lang.Object object)
Sets the object to be wrapped for allowing it being used as
Map . |
protected void |
setSilent(boolean silent) |
int |
size() |
java.util.Collection<java.lang.Object> |
values() |
public MappedObject(java.lang.Object object)
object
- The object to be wrapped (may be null).public MappedObject(java.lang.Object object, boolean silent)
ReflectionException
.object
- The object to be wrapped (may be null).silent
- Defines whether or not problems should silently be ignored.public java.lang.Object getObject()
Map
interface.public void setObject(java.lang.Object object)
Map
.object
- The object to be wrapped (may be null).public java.lang.Class<?> getObjectType()
Void.TYPE
.public java.lang.Object get(java.lang.Object fieldName)
get
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object put(java.lang.String fieldName, java.lang.Object value)
put
in interface java.util.Map<java.lang.String,java.lang.Object>
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
putAll
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Collection<java.lang.Object> values()
values
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsKey(java.lang.Object fieldName)
containsKey
in interface java.util.Map<java.lang.String,java.lang.Object>
public int size()
size
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object remove(java.lang.Object fieldName)
get(Object)
.remove
in interface java.util.Map<java.lang.String,java.lang.Object>
ReflectionException
- if the filed cannot be found and silent is false.public void clear()
clear
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean isNull()
public boolean isSilent()
protected FieldProxy<java.lang.Object> getFieldAccessor(java.lang.String fieldName)
protected void initFieldAccessors()
protected void handleProblem(java.lang.String message, java.lang.Object... args)
ReflectionException
.protected void setSilent(boolean silent)
protected java.util.Map<java.lang.String,FieldProxy<java.lang.Object>> getFieldAccessors()