Class SimpleMetadata<V,Derived extends SimpleMetadata<V,Derived>>

java.lang.Object
org.variantsync.diffdetective.analysis.SimpleMetadata<V,Derived>
Type Parameters:
V - The type of the value to store (e.g., Integer when we want to count something).
Derived - The type of the subclass that derives this class.
All Implemented Interfaces:
Metadata<Derived>
Direct Known Subclasses:
Analysis.RuntimeWithMultithreadingResult, Analysis.TotalNumberOfCommitsResult

public abstract class SimpleMetadata<V,Derived extends SimpleMetadata<V,Derived>> extends Object implements Metadata<Derived>
Default implementation for metadata that just wraps a single value. TODO: Move this implementation to Functjonal.
Author:
Paul Bittner
  • Field Details

  • Constructor Details

    • SimpleMetadata

      public SimpleMetadata(V initialValue, String valueName, BiFunction<V,V,V> compose)
      Create simple metadata with the given default value, name, and composition operator. Creating simple metadata this way, will not implement the parse method, which makes reading a corresponding value from a string crash. If you need parsing, use SimpleMetadata(Object, String, BiFunction, Function)
      Parameters:
      initialValue - initial value of the stored value (e.g., 0 for integer)
      valueName - the name this value should have
      compose - A binary function which composes two values (e.g., + for integer).
    • SimpleMetadata

      protected SimpleMetadata(V initialValue, String valueName, BiFunction<V,V,V> compose, Function<String,V> parse)
      Create simple metadata with the given default value, name, and composition operator.
      Parameters:
      initialValue - initial value of the stored value (e.g., 0 for integer)
      valueName - the name this value should have
      compose - A binary function which composes two values (e.g., + for integer).
      parse - A method to parse the corresponding value from a string that contains just the string representation of the value. This should be inverse to V::toString .
  • Method Details

    • snapshot

      public LinkedHashMap<String,?> snapshot()
      Description copied from interface: Metadata
      Create a key-value store of the metadata that can be used for serialization.
      Specified by:
      snapshot in interface Metadata<V>
      Returns:
      A LinkedHashMap that stores all relevant properties to export. The return type has to be a LinkedHashMap to obtain insertion-order iteration.
    • setFromSnapshot

      public void setFromSnapshot(LinkedHashMap<String,String> snapshot)
      Specified by:
      setFromSnapshot in interface Metadata<V>
    • semigroup

      public org.variantsync.functjonal.category.InplaceSemigroup<Derived> semigroup()
      Description copied from interface: Metadata
      Metadata should be composable. Composition should be inplace to optimize performance.
      Specified by:
      semigroup in interface Metadata<V>