Package org.apache.nlpcraft.model
Interface NCMetadata
-
- All Known Subinterfaces:
NCCustomElement
,NCElement
,NCModel
,NCModelView
,NCToken
- All Known Implementing Classes:
NCModelAdapter
,NCModelFileAdapter
public interface NCMetadata
Provides support for map-based metadata.Read full documentation in Data Model section and review examples.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Map<String,Object>
getMetadata()
Gets metadata.default <T> T
meta(String prop)
Shortcut method to get given metadata property.default <T> T
meta(String prop, T dflt)
Shortcut method to get given metadata property.default <T> Optional<T>
metaOpt(String prop)
Shortcut method to get given optional metadata property.default <T> T
metax(String prop)
Shortcut method to get given mandatory metadata property.
-
-
-
Method Detail
-
getMetadata
Map<String,Object> getMetadata()
Gets metadata.- Returns:
- Metadata.
- See Also:
meta(String)
,metaOpt(String)
,meta(String, Object)
-
metaOpt
default <T> Optional<T> metaOpt(String prop)
Shortcut method to get given optional metadata property. Equivalent to:Optional.ofNullable((T)getMetadata().get(prop));
- Type Parameters:
T
- Type of the metadata property.- Parameters:
prop
- Metadata property name.- Returns:
- Metadata optional property value.
-
meta
default <T> T meta(String prop)
Shortcut method to get given metadata property. Equivalent to:(T)getMetadata().get(prop);
- Type Parameters:
T
- Type of the metadata property.- Parameters:
prop
- Metadata property name.- Returns:
- Metadata property value or
null
if given metadata property not found.
-
metax
default <T> T metax(String prop) throws org.apache.nlpcraft.common.NCException
Shortcut method to get given mandatory metadata property. Equivalent to:T t = (T)getMetadata().get(prop); if (t == null) throw new NCException("Mandatory metadata property not found: " + prop); else return t;
- Type Parameters:
T
- Type of the metadata property.- Parameters:
prop
- Metadata property name.- Returns:
- Metadata property value or throws an exception if given metadata property not found.
- Throws:
org.apache.nlpcraft.common.NCException
- Thrown if given metadata property not found.
-
meta
default <T> T meta(String prop, T dflt)
Shortcut method to get given metadata property. Equivalent to:getMetadata().get(tokId, prop, dflt);
- Type Parameters:
T
- Type of the metadata property.- Parameters:
prop
- Metadata property name.dflt
- Default value to return if specified one isn't set.- Returns:
- Metadata property value or default value if one isn't set.
-
-