Interface Palette<T,R>
-
- Type Parameters:
T
- The type this palette will maintainR
- The type of registry used to build this palette
- All Known Subinterfaces:
Palette.Immutable<I,IR>
,Palette.Mutable<M,MR>
public interface Palette<T,R>
Represents a mapping for types to a local identifier. Can be used for mappingObject
s toint
id's for storage purposes, or for converting stored information to a representable format back intoObject
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Palette.Immutable<I,IR>
static interface
Palette.Mutable<M,MR>
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Palette.Immutable<T,R>
asImmutable()
Palette.Mutable<T,R>
asMutable(RegistryHolder registry)
java.util.Optional<PaletteReference<T,R>>
get(int id)
Gets thetype
represented by the given identifier from the mapping.default java.util.Optional<T>
get(int id, RegistryHolder holder)
java.util.OptionalInt
get(T type)
Gets the identifier for the giventype T
if it exists within the mapping.int
highestId()
Gets the highest identifier in this palette.java.util.stream.Stream<T>
stream()
Gets alltype T
s contained in this palette.java.util.stream.Stream<java.util.Map.Entry<T,java.lang.Integer>>
streamWithIds()
PaletteType<T,R>
type()
Gets the type of this palette.
-
-
-
Method Detail
-
type
PaletteType<T,R> type()
Gets the type of this palette.- Returns:
- The palette type
-
highestId
int highestId()
Gets the highest identifier in this palette.- Returns:
- The highest id
-
get
java.util.Optional<PaletteReference<T,R>> get(int id)
Gets thetype
represented by the given identifier from the mapping.- Parameters:
id
- The identifier- Returns:
- The type, if found
-
get
default java.util.Optional<T> get(int id, RegistryHolder holder)
-
get
java.util.OptionalInt get(T type)
Gets the identifier for the giventype T
if it exists within the mapping.- Parameters:
type
- The type- Returns:
- The identifier, if found
-
stream
java.util.stream.Stream<T> stream()
Gets alltype T
s contained in this palette.- Returns:
- All contained types
-
streamWithIds
java.util.stream.Stream<java.util.Map.Entry<T,java.lang.Integer>> streamWithIds()
-
asMutable
Palette.Mutable<T,R> asMutable(RegistryHolder registry)
-
asImmutable
Palette.Immutable<T,R> asImmutable()
-
-