Package space.arim.dazzleconf.serialiser
Class ValueSerialiserMap
java.lang.Object
space.arim.dazzleconf.serialiser.ValueSerialiserMap
An immutable map of value serialisers, keyed by the type which they serialise.
- Author:
- A248
-
Method Summary
Modifier and TypeMethodDescriptionMap<Class<?>,ValueSerialiser<?>>
asMap()
Gets this value serialiser map as aMap
.static ValueSerialiserMap
empty()
Gets an empty value serialiser mapboolean
<T> ValueSerialiser<T>
getSerialiser(Class<T> type)
Deprecated.<T> Optional<ValueSerialiser<T>>
getSerialiserFor(Class<T> type)
Gets the value serialiser for a given typeint
hashCode()
static ValueSerialiserMap
of(Collection<? extends ValueSerialiser<?>> serialisers)
Creates from a collection of serialisers.static ValueSerialiserMap
of(Map<Class<?>,? extends ValueSerialiser<?>> serialisers)
Creates from a map of serialisers.toString()
-
Method Details
-
of
Creates from a collection of serialisers. If any two serialisers specify the same target type (ValueSerialiser.getTargetClass()
),IllegalArgumentException
is thrown- Parameters:
serialisers
- the value serialisers- Returns:
- the value serialiser map
- Throws:
NullPointerException
- if any serialiser is nullIllegalArgumentException
- if any value serialisers conflict
-
of
Creates from a map of serialisers. If any serialisers are at a mismatched key,IllegalArgumentException
is thrown- Parameters:
serialisers
- the value serialisers- Returns:
- the value serialiser map
- Throws:
NullPointerException
- if any serialiser is nullIllegalArgumentException
- if any value serialisers are at a mismatched key
-
empty
Gets an empty value serialiser map- Returns:
- an empty map
-
getSerialiser
Deprecated.UsegetSerialiserFor(Class)
insteadGets the value serialiser for a given type- Type Parameters:
T
- the type- Parameters:
type
- the type class- Returns:
- the value serialiser for the type or
null
if there is none
-
getSerialiserFor
Gets the value serialiser for a given type- Type Parameters:
T
- the type- Parameters:
type
- the type class- Returns:
- the value serialiser for the type or an empty optional if there is none
-
asMap
Gets this value serialiser map as aMap
. This map is immutable.- Returns:
- the map of classes to value serialisers, never
null
-
toString
-
hashCode
public int hashCode() -
equals
-
getSerialiserFor(Class)
instead