Contents
Class Deferred<T>
java.lang.Object
com.hypixel.hytale.codec.lookup.Deferred<T>
- Type Parameters:
T- the type the value decodes to
A value that was read but not yet decoded. This lets the codec for its type be registered
after the file that names it was read.
A server reads its configuration before it loads the plugins, so a plugin cannot register the
codec for a type in time for the read. Holding the value undecoded moves the decode to the
first get(), which the server calls once the plugins are loaded.
-
Constructor Summary
ConstructorsConstructorDescriptionDeferred(BuilderCodecMapCodec<T> codec) Creates a holder for a value that the file does not carry, which decodes to the default of the codec. -
Method Summary
-
Constructor Details
-
Deferred
Creates a holder for a value that the file does not carry, which decodes to the default of the codec.- Parameters:
codec- the codec that decodes the value
-
-
Method Details
-
get
Decodes the value, once, and holds on to the result.- Returns:
- the value, or
nullif the file carries none and the codec has no default - Throws:
IllegalStateException- if the value names a type that no codec is registered for, which on a server means the plugin that owns the type is absent and its data must not be treated as the default. The check covers the type the value names, not a type nested inside it.
-
set
Replaces the value. The holder writes it back in place of what it read.- Parameters:
value- the value to hold
-
isEmpty
public boolean isEmpty()- Returns:
trueif the holder has nothing to write, which is so only when the file carried no value and the codec has no default to write in its place
-