@Beta public class MetadataEntity extends Object implements Iterable<MetadataEntity.KeyValue>
Represents either a CDAP entity or a custom entity in metadata APIs. A MetadataEntity
is an ordered
sequence of key/value pairs constructed using MetadataEntity.Builder
. Keys are case insensitive.
Example usage: Creating a MetadataEntity for Dataset
MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns") .appendAsType(MetadataEntity.DATASET, "myDataset").build();
Creating a MetadataEntity
for a custom entity: a field in a dataset:
MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns").append(MetadataEntity.DATASET, "ds") .appendAsType("field", "myField").build();
Every metadata entity has a type. If a type is not specifically specified by calling
MetadataEntity.Builder.appendAsType(String, String)
the last key in the hierarchy will be the type by
default. In some cases, the type is a key in middle and MetadataEntity.Builder.appendAsType(String, String)
helps in representing these. An example of this is ApplicationId which ends with "version"
although the type is "application".
MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns") .appendAsType(MetadataEntity.APPLICATION, "myApp").append(MetadataEntity.VERSION, "1").build();This class also provide helper methods for creating
MetadataEntity
for:
ofNamespace(String)
ofDataset(String, String)
and ofDataset(String)
.
The ofDataset(String)
lacks namespace information and does not represent complete information to
represent a Dataset. It is provided to conveniently refer to a Dataset in current namespace and should only be
used when it is known that the handler can fill in the namespace information.Modifier and Type | Class and Description |
---|---|
static class |
MetadataEntity.Builder
Builder for
MetadataEntity |
static class |
MetadataEntity.KeyValue
MetadataEntity key-value. |
Modifier and Type | Field and Description |
---|---|
static String |
APPLICATION |
static String |
ARTIFACT |
static String |
DATASET |
static String |
NAMESPACE |
static String |
PLUGIN |
static String |
PROGRAM |
static String |
PROGRAM_RUN |
static String |
SCHEDULE |
static String |
TYPE |
static String |
VERSION |
Constructor and Description |
---|
MetadataEntity(MetadataEntity metadataEntity) |
Modifier and Type | Method and Description |
---|---|
static MetadataEntity.Builder |
builder() |
static MetadataEntity.Builder |
builder(MetadataEntity metadataEntity) |
boolean |
containsKey(String key) |
boolean |
equals(Object o) |
String |
getDescription() |
Iterable<String> |
getKeys() |
String |
getType() |
String |
getValue(String key) |
int |
hashCode() |
List<MetadataEntity.KeyValue> |
head(String splitKey)
Returns a List of
MetadataEntity.KeyValue till the given splitKey (inclusive) |
Iterator<MetadataEntity.KeyValue> |
iterator() |
static MetadataEntity |
ofDataset(String datasetName)
Creates a
MetadataEntity representing the given datasetName. |
static MetadataEntity |
ofDataset(String namespace,
String datasetName)
Creates a
MetadataEntity representing the given datasetName in the specified namespace. |
static MetadataEntity |
ofNamespace(String namespace)
Creates a
MetadataEntity representing the given namespace. |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final String NAMESPACE
public static final String APPLICATION
public static final String ARTIFACT
public static final String VERSION
public static final String DATASET
public static final String TYPE
public static final String PROGRAM
public static final String SCHEDULE
public static final String PROGRAM_RUN
public static final String PLUGIN
public MetadataEntity(MetadataEntity metadataEntity)
public static MetadataEntity ofNamespace(String namespace)
MetadataEntity
representing the given namespace.namespace
- the name of the namespaceMetadataEntity
representing the namespace nameIllegalArgumentException
- if the key is a CDAP entity and the MetadataEntity is not correct to represent
the CDAP entitypublic static MetadataEntity ofDataset(String datasetName)
MetadataEntity
representing the given datasetName. To create a MetadataEntity
for a
dataset in a specified namespace please use ofDataset(String, String)
.datasetName
- the name of the datasetMetadataEntity
representing the dataset namepublic static MetadataEntity ofDataset(String namespace, String datasetName)
MetadataEntity
representing the given datasetName in the specified namespace.namespace
- the name of the namespacedatasetName
- the name of the datasetMetadataEntity
representing the dataset nameIllegalArgumentException
- if the key is a CDAP entity and the MetadataEntity is not correct to represent
the CDAP entitypublic List<MetadataEntity.KeyValue> head(String splitKey)
MetadataEntity.KeyValue
till the given splitKey (inclusive)splitKey
- the splitKey (inclusive)MetadataEntity.KeyValue
public String getDescription()
String
which describes the MetadataEntity
for a user in plain english.
If the MetadataEntity
represents a known CDAP entity then the description is worded to show relations
in the hierarchy.public String getType()
@Nullable public String getValue(String key)
public boolean containsKey(String key)
public static MetadataEntity.Builder builder()
public static MetadataEntity.Builder builder(MetadataEntity metadataEntity)
public Iterator<MetadataEntity.KeyValue> iterator()
iterator
in interface Iterable<MetadataEntity.KeyValue>
List
of MetadataEntity.KeyValue
representing the metadata entityCopyright © 2021 Cask Data, Inc. Licensed under the Apache License, Version 2.0.