public interface DataSource
ConfigSource
, ConfigDiff
, TaskSource
, and TaskReport
.
It had two following methods that return Jackson's instances till v0.9, but they are removed so that Jackson on the core side can be hidden from plugins.
Iterable<Map.Entry<String, JsonNode>> getAttributes()
ObjectNode getObjectNode()
Modifier and Type | Method and Description |
---|---|
DataSource |
deepCopy()
Creates a deep copy of itself.
|
<E> E |
get(Class<E> type,
String attrName)
Returns an attribute value of
attrName as type . |
<E> E |
get(Class<E> type,
String attrName,
E defaultValue)
Returns an attribute value of
attrName as type . |
List<String> |
getAttributeNames()
Returns a
List of attribute names under this node. |
default <E> List<E> |
getListOf(Class<E> type,
String attrName)
Returns listed attribute values under
attrName as List<type> . |
DataSource |
getNested(String attrName)
Returns a nested value under
attrName . |
DataSource |
getNestedOrGetEmpty(String attrName)
Returns a nested value under
attrName . |
DataSource |
getNestedOrSetEmpty(String attrName)
Returns a nested value under
attrName . |
boolean |
has(String attrName)
Returns
true if it has an attribute named attrName . |
default boolean |
hasList(String attrName)
Returns
true if it has a list attribute named attrName . |
default boolean |
hasNested(String attrName)
Returns
true if it has a nested attribute named attrName . |
boolean |
isEmpty()
Returns
true if it is empty. |
DataSource |
merge(DataSource other)
Merges another
DataSource into itself. |
DataSource |
remove(String attrName)
Removes the attribute named
attrName . |
DataSource |
set(String attrName,
Object v)
Sets a value for
attrName . |
DataSource |
setAll(DataSource other)
Sets all attributes in
other into itself. |
DataSource |
setNested(String attrName,
DataSource v)
Sets a nested value for
attrName . |
default String |
toJson()
Returns a JSON representation of itself.
|
default Map<String,Object> |
toMap()
Returns a
Map representation of itself. |
List<String> getAttributeNames()
List
of attribute names under this node.List
of attribute namesboolean isEmpty()
true
if it is empty.true
if it is emptyboolean has(String attrName)
true
if it has an attribute named attrName
.attrName
- name of the attribute to look fortrue
if it has an attribute named attrName
default boolean hasList(String attrName)
true
if it has a list attribute named attrName
.
Do not use this method if you want your plugin to keep working with Embulk v0.9. A plugin that calls it would work only on Embulk v0.10.41 or later.
An implementation of DataSource
should implement its own hasList
in its own efficient way.
The default
implementation in DataSource
is a "polyfill". It works, but in an inefficient way.
attrName
- name of the list attribute to look fortrue
if it has a list attribute named attrName
default boolean hasNested(String attrName)
true
if it has a nested attribute named attrName
.
Do not use this method if you want your plugin to keep working with Embulk v0.9. A plugin that calls it would work only on Embulk v0.10.41 or later.
An implementation of DataSource
should implement its own hasNested
in its own efficient way.
The default
implementation in DataSource
is a "polyfill". It works, but in an inefficient way.
attrName
- name of the nested attribute to look fortrue
if it has a nested attribute named attrName
<E> E get(Class<E> type, String attrName)
attrName
as type
.E
- the class to get the value astype
- the class to get the value asattrName
- name of the attribute to look forattrName
as type
<E> E get(Class<E> type, String attrName, E defaultValue)
attrName
as type
.E
- the class to get the value astype
- the class to get the value asattrName
- name of the attribute to look fordefaultValue
- the default value in case a value does not exist for attrName
attrName
as type
default <E> List<E> getListOf(Class<E> type, String attrName)
attrName
as List<type>
.
It returns an empty list if the attribute does not exist. It does not throw an exception for such a case
unlike getNested(String)
. It is because an empty list is observed often in the wild, and users have
to take care in representing an empty list in YAML (explicit "[]"
).
Do not use this method if you want your plugin to keep working with Embulk v0.9. A plugin that calls it would work only on Embulk v0.10.41 or later.
An implementation of DataSource
should implement its own getListOf
in its own appropriate way.
The default
implementation in DataSource
is a "polyfill". It somehow works, but is not perfect.
It does not check nor convert the type of each element in the list.
DataSource getNested(String attrName)
attrName
.attrName
- name of the nested attribute to look forattrName
DataSource getNestedOrSetEmpty(String attrName)
attrName
. Sets an empty object node "{}"
there if it is empty.attrName
- name of the nested attribute to look forattrName
DataSource getNestedOrGetEmpty(String attrName)
attrName
. Returns an empty object node "{}"
there if it is empty.attrName
- name of the nested attribute to look forattrName
DataSource set(String attrName, Object v)
attrName
.attrName
- name of the attribute to set the value atv
- the value Object
to setDataSource setNested(String attrName, DataSource v)
attrName
.attrName
- name of the attribute to set the nested value atv
- the nested value to setDataSource setAll(DataSource other)
other
into itself.other
- the other DataSource
to setDataSource remove(String attrName)
attrName
.attrName
- name of the attribute to removeDataSource deepCopy()
DataSource
instance that is deep-copied from itselfDataSource merge(DataSource other)
DataSource
into itself.other
- the other DataSource
to mergeDataSource
is mergeddefault String toJson()
String