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 TypeMethodDescriptiondefault void
Append the other metadata's values to this metadata.default String
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 asmergeEqual(Object, Object)
but does not crash when the two values are unequal.org.variantsync.functjonal.category.InplaceSemigroup<T>
Metadata should be composable.void
setFromSnapshot
(LinkedHashMap<String, String> snapshot) static <T> String
Prints the given key, value pair to text.static String
Prints all key-value pairs to a single string.snapshot()
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
-
semigroup
org.variantsync.functjonal.category.InplaceSemigroup<T> semigroup()Metadata should be composable. Composition should be inplace to optimize performance. -
append
Append the other metadata's values to this metadata. The default implementation uses thesemigroup()
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 anAssertionError
is thrown.The value
null
is treated as the neutral element in the sense that no exception is thrown if an element isnull
. In this case return value is defined bymergeEqual(a, null) == a
andmergeEqual(b, null) == b
.- Type Parameters:
T
- the type of the objects to be merged- Parameters:
a
- the first element to mergeb
- the second element to merge- Returns:
a
orb
-
mergeIfEqualElse
Same asmergeEqual(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 toObject.equals(Object)
).The value
null
is treated as the neutral element in the sense that no exception is thrown if an element isnull
. In this case return value is defined bymergeIfEqualElse(a, null, f) == a
andmergeIfEqualElse(b, null, f) == b
.- Type Parameters:
T
- the type of the objects to be merged- Parameters:
a
- the first element to mergeb
- the second element to mergeifUnequal
- merge operator called when the two values are unequal- Returns:
a
if both given values are equal, otherwise the result ofifUnequal.apply(a, b)
-
show
Prints all key-value pairs to a single string. Falls back toshow(String, Object)
on each entry.- Parameters:
properties
- The key-value store to print.- Returns:
- A string showing all key-value pairs.
-
show
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
Export this metadata to the given file.- Parameters:
file
- File to write.- Returns:
- The exported file's content.
- See Also:
-