Class SimpleMetadata
java.lang.Object
dev.jcputney.elearning.parser.output.metadata.SimpleMetadata
- All Implemented Interfaces:
MetadataComponent,Serializable
A simple implementation of the MetadataComponent interface that stores metadata in a map.
This class represents a leaf node in the composite pattern containing basic metadata values.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMetadata(@NonNull String key, Object value) Adds a metadata value with the given key.getMetadata(String key) Gets a metadata value by key.<T> Optional<T>getMetadata(String key, Class<T> type) Gets a metadata value by key, with type conversion.booleanhasMetadata(String key) Checks if this component contains metadata for the given key.
-
Constructor Details
-
SimpleMetadata
public SimpleMetadata()
-
-
Method Details
-
addMetadata
Adds a metadata value with the given key.- Parameters:
key- The key for the metadata.value- The value for the metadata.- Returns:
- This SimpleMetadata instance for method chaining.
-
getMetadata
Description copied from interface:MetadataComponentGets a metadata value by key.- Specified by:
getMetadatain interfaceMetadataComponent- Parameters:
key- The key to look up.- Returns:
- An Optional containing the value if found, or empty if not found.
-
getMetadata
Description copied from interface:MetadataComponentGets a metadata value by key, with type conversion.- Specified by:
getMetadatain interfaceMetadataComponent- Type Parameters:
T- The type to convert the value to.- Parameters:
key- The key to look up.type- The class to convert the value to.- Returns:
- An Optional containing the converted value if found, or empty if not found.
-
hasMetadata
Description copied from interface:MetadataComponentChecks if this component contains metadata for the given key.- Specified by:
hasMetadatain interfaceMetadataComponent- Parameters:
key- The key to check.- Returns:
- true if this component contains metadata for the key, false otherwise.
-