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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionSimpleMetadata(V initialValue, String valueName, BiFunction<V, V, V> compose) Create simple metadata with the given default value, name, and composition operator.protectedSimpleMetadata(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. -
Method Summary
Modifier and TypeMethodDescriptionorg.variantsync.functjonal.category.InplaceSemigroup<Derived> Metadata should be composable.voidsetFromSnapshot(LinkedHashMap<String, String> snapshot) snapshot()Create a key-value store of the metadata that can be used for serialization.
-
Field Details
-
value
-
valueName
-
compose
-
parser
-
-
Constructor Details
-
SimpleMetadata
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, useSimpleMetadata(Object, String, BiFunction, Function)- Parameters:
initialValue- initial value of the stored value (e.g., 0 for integer)valueName- the name this value should havecompose- 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 havecompose- 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 toV::toString.
-
-
Method Details
-
snapshot
Description copied from interface:MetadataCreate a key-value store of the metadata that can be used for serialization. -
setFromSnapshot
- Specified by:
setFromSnapshotin interfaceMetadata<V>
-
semigroup
Description copied from interface:MetadataMetadata should be composable. Composition should be inplace to optimize performance.
-