Package org.storynode.pigeon.wrap
Class Metadata<T>
java.lang.Object
org.storynode.pigeon.wrap.Metadata<T>
- Type Parameters:
T- The type of the inner value
- All Implemented Interfaces:
SafelyWrapped<T>,Wrapped<T>
Wraps a value associating it with arbitrary metadata
- Since:
- 1.0.0
- Author:
- Andrea Coronese
-
Constructor Details
-
Method Details
-
from
@NotNull public static <T> @NotNull Result<Metadata<T>,? extends Throwable> from(@NotNull @NotNull Wrapped<T> wrapped) Tries to create aMetadatainstance from anotherWrappedvalue. SinceWrapped.unwrap()can fail in some implementations (like inResult) this returns aResultcontaining theUnwrapExceptionobtained when unwrapping the originally wrapped value, if any is thrown.
If the originalWrappedis already aMetadatainstance then its metadata will be copied into the new instance. -
from
@NotNull public static <T> @NotNull Result<Metadata<T>,? extends Throwable> from(@NotNull @NotNull Wrapped<T> wrapped, Map<Object, Object> additionalMetadata) Tries to create aMetadatainstance from anotherWrappedvalue. SinceWrapped.unwrap()can fail in some implementations (like inResult) this returns aResultcontaining theUnwrapExceptionobtained when unwrapping the originally wrapped value, if any is thrown.
If the originalWrappedis already aMetadatainstance then its metadata will be copied into the new instance. -
unwrap
Gets the wrapped value. This method is allowed to throw aUnwrapExceptionif the specific implementors requires so. -
toTuple
APaircomposed by the value and its metadata map- Returns:
- a
Pairobject with the value and the metadata
-