Class CompositeMetadata
java.lang.Object
dev.jcputney.elearning.parser.output.metadata.CompositeMetadata
- All Implemented Interfaces:
MetadataComponent,Serializable
A composite implementation of the MetadataComponent interface that can contain other metadata
components.
This class represents a composite node in the composite pattern, containing other metadata components. When queried for metadata, it searches through its child components in order until it finds a match.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddComponent(@NonNull MetadataComponent component) Adds a metadata component to this composite.addComponents(@NonNull List<MetadataComponent> components) Adds multiple metadata components to this composite.Gets all components in this composite.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
-
CompositeMetadata
public CompositeMetadata()
-
-
Method Details
-
addComponent
Adds a metadata component to this composite.- Parameters:
component- The component to add.- Returns:
- This CompositeMetadata instance for method chaining.
-
addComponents
Adds multiple metadata components to this composite.- Parameters:
components- The components to add.- Returns:
- This CompositeMetadata 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.
-
getComponents
Gets all components in this composite.- Returns:
- A list of all components.
-