Class SimpleMetadata

java.lang.Object
dev.jcputney.elearning.parser.output.metadata.SimpleMetadata
All Implemented Interfaces:
MetadataComponent, Serializable

public class SimpleMetadata extends Object implements MetadataComponent
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 Details

    • SimpleMetadata

      public SimpleMetadata()
  • Method Details

    • addMetadata

      public SimpleMetadata addMetadata(@NonNull @NonNull String key, Object value)
      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

      public Optional<Object> getMetadata(String key)
      Description copied from interface: MetadataComponent
      Gets a metadata value by key.
      Specified by:
      getMetadata in interface MetadataComponent
      Parameters:
      key - The key to look up.
      Returns:
      An Optional containing the value if found, or empty if not found.
    • getMetadata

      public <T> Optional<T> getMetadata(String key, Class<T> type)
      Description copied from interface: MetadataComponent
      Gets a metadata value by key, with type conversion.
      Specified by:
      getMetadata in interface MetadataComponent
      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

      public boolean hasMetadata(String key)
      Description copied from interface: MetadataComponent
      Checks if this component contains metadata for the given key.
      Specified by:
      hasMetadata in interface MetadataComponent
      Parameters:
      key - The key to check.
      Returns:
      true if this component contains metadata for the key, false otherwise.