|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface HasMetadata
A standard interface implemented by classes that have metadata attached to their instances. This provides methods to retrieve the values of attached metadata items. The methods on this interface are designed so that the do not fail with an exception if metadata is missing, or does not match the expected type. If such problems do occur, implementations should log the problem and fall back to returning the default value.
| Method Summary | ||
|---|---|---|
Object |
mdObject(String mdName,
Object defaultValue)
Returns the untyped value of a metadata item. |
|
String |
mdString(String mdName,
String defaultValue)
Returns the string value of a metadata item. |
|
com.ca.commons.functional.Option<DataModelValue> |
mdValue(String mdName)
|
|
|
mdValue(String mdName,
T defaultValue)
Tries to retrieve the value of the metadata item as a particular type. |
|
|
mdValue(String mdName,
T defaultValue,
Class<? extends T> type)
Tries to retrieve the value of a metadata item as a particular type. |
|
| Method Detail |
|---|
@Nullable
Object mdObject(@NotNull
String mdName,
@Nullable
Object defaultValue)
mdValue(mdName, defaultValue, Object.class).
mdName - The name of the metadata item.defaultValue - A default value to return if the named item is not found.
mdValue(String, Object, Class)
@Nullable
String mdString(@NotNull
String mdName,
@Nullable
String defaultValue)
mdValue(mdName, defaultValue, String.class).
mdName - The name of the metadata item.defaultValue - A default value to return if the named item is
not found, or its value is not a string.
mdValue(String, Object, Class)
@NotNull
<T> T mdValue(@NotNull
String mdName,
@NotNull
T defaultValue)
mdValue(mdName, defaultValue, defaultValue.getClass()).
mdName - The name of the metadata item to retrieve.defaultValue - The default value to return if the metadata item
cannot be retrieved. Also indicates the type of value expected
by the caller.
mdValue(String, Object, Class)
@Nullable
<T> T mdValue(@NotNull
String mdName,
@Nullable
T defaultValue,
@NotNull
Class<? extends T> type)
mdName - The name of the metadata item to retrieve.defaultValue - The default value to return if the metadata item
cannot be retrieved.type - A class object indicating the type of the value that
is expected.
type.isInstance(returnedValue)
is always true.
@NotNull
com.ca.commons.functional.Option<DataModelValue> mdValue(@NotNull
String mdName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||