Interface Metadata<T>

Type Parameters:
T - The type of metadata. Should be the subclasses type.
All Known Implementing Classes:
Analysis.RuntimeWithMultithreadingResult, Analysis.TotalNumberOfCommitsResult, AnalysisResult, AutomationResult, ConstructionValidation.ComparisonResult, ConstructionValidation.Result, EditClassCount, ExplainedFilterSummary, LineGraphExport.Statistic, LineGraphExportAnalysis.Result, SimpleMetadata, StatisticsAnalysis.Result, VariationDiffSerializeDebugData

public interface Metadata<T>
Generic interface to model composable and printable metadata.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    append(T other)
    Append the other metadata's values to this metadata.
    default String
    exportTo(Path file)
    Export this metadata to the given file.
    static <T> T
    mergeEqual(T a, T b)
    Composes two equal values by returning that value unmodified.
    static <T> T
    mergeIfEqualElse(T a, T b, BiFunction<T,T,T> ifUnequal)
    Same as mergeEqual(Object, Object) but does not crash when the two values are unequal.
    org.variantsync.functjonal.category.InplaceSemigroup<T>
    Metadata should be composable.
    void
     
    static <T> String
    show(String name, T value)
    Prints the given key, value pair to text.
    static String
    show(Map<String,?> properties)
    Prints all key-value pairs to a single string.
    Create a key-value store of the metadata that can be used for serialization.
  • Method Details

    • snapshot

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

      void setFromSnapshot(LinkedHashMap<String,String> snapshot)
    • semigroup

      org.variantsync.functjonal.category.InplaceSemigroup<T> semigroup()
      Metadata should be composable. Composition should be inplace to optimize performance.
    • append

      default void append(T other)
      Append the other metadata's values to this metadata. The default implementation uses the semigroup() for this purpose.
      Parameters:
      other - The metadata to append to this metadata. Remains unchanged (if the semigroup leaves it unchanged).
    • mergeEqual

      static <T> T mergeEqual(T a, T b)
      Composes two equal values by returning that value unmodified. This method is intended to be used to implement a semigroup for objects which can't be merged but should always be the same anyway. If !a.equals(b) then an AssertionError is thrown.

      The value null is treated as the neutral element in the sense that no exception is thrown if an element is null. In this case return value is defined by mergeEqual(a, null) == a and mergeEqual(b, null) == b.

      Type Parameters:
      T - the type of the objects to be merged
      Parameters:
      a - the first element to merge
      b - the second element to merge
      Returns:
      a or b
    • mergeIfEqualElse

      static <T> T mergeIfEqualElse(T a, T b, BiFunction<T,T,T> ifUnequal)
      Same as mergeEqual(Object, Object) but does not crash when the two values are unequal. Instead, both values are merged using the supplied function. The supplied function is called only if the two given values are unequal (according to Object.equals(Object)).

      The value null is treated as the neutral element in the sense that no exception is thrown if an element is null. In this case return value is defined by mergeIfEqualElse(a, null, f) == a and mergeIfEqualElse(b, null, f) == b.

      Type Parameters:
      T - the type of the objects to be merged
      Parameters:
      a - the first element to merge
      b - the second element to merge
      ifUnequal - merge operator called when the two values are unequal
      Returns:
      a if both given values are equal, otherwise the result of ifUnequal.apply(a, b)
    • show

      static String show(Map<String,?> properties)
      Prints all key-value pairs to a single string. Falls back to show(String, Object) on each entry.
      Parameters:
      properties - The key-value store to print.
      Returns:
      A string showing all key-value pairs.
    • show

      static <T> String show(String name, T value)
      Prints the given key, value pair to text.
      Type Parameters:
      T - The type of the metadata value.
      Parameters:
      name - Name of the metadata entry.
      value - Value of the metadata entry.
      Returns:
      A String name: value\n.
    • exportTo

      default String exportTo(Path file)
      Export this metadata to the given file.
      Parameters:
      file - File to write.
      Returns:
      The exported file's content.
      See Also: