Class ConverterRegistry.Context
java.lang.Object
com.ultikits.ultitools.config.convert.ConverterRegistry.Context
- All Implemented Interfaces:
ConversionContext
- Enclosing class:
ConverterRegistry
@Internal
public static final class ConverterRegistry.Context
extends Object
implements ConversionContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<ConversionFailure> private final StringThe entries of the file map at this location by their key text, first in map order; built once, on the first lookup that misses an exact key, so binding every key of a map visits its file entries once, not once per key (PR #687 local Codex run 2).private final ObjectThe plain value the file holds atpath, ornullwhen unknown.private final ConverterRegistryprivate final Type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateContext(ConverterRegistry registry, String file, List<String> path, Type type, List<ConversionFailure> failures, Object fileValue) -
Method Summary
Modifier and TypeMethodDescriptionThe nested context carries the file's value at the nested location: the entry undersegmentwhen the file value is a map, the element at that index when it is a list andsegmentis an index, else none.entriesByText(Map<?, ?> entries) entriesby key text (String.valueOf), keeping the first entry in map order for each text.file()private ObjectThe file's value undersegment: the entry whose key is exactly that text, else the first entry in map order whose key reads as that text, through the index built once per map.<V> VConverts a nested document value through the same registry.path()Readsplainasdeclaredthrough the same registry path the loader uses, at this context's location, without recording anything in this conversion's failure list: a refusal, or any nested omission, goes to a throw-away list and makes the probe fail.readSerializable(Object plain, Class<? extends org.bukkit.configuration.serialization.ConfigurationSerializable> factory) Applies the ordinary registered hierarchy before delegate-aware Bukkit fallback.<V> Vvoidrecord(Object raw, ConversionException cause) Converts a nested Java value using its runtime type and the same registry.writeTyped(Object value, Type declared)
-
Field Details
-
registry
-
file
-
path
-
type
-
failures
-
fileValue
The plain value the file holds atpath, ornullwhen unknown. Writes carry it so a typed map key can be written under the file's own key text; reads never use it. -
fileEntriesByText
The entries of the file map at this location by their key text, first in map order; built once, on the first lookup that misses an exact key, so binding every key of a map visits its file entries once, not once per key (PR #687 local Codex run 2).
-
-
Constructor Details
-
Context
private Context(ConverterRegistry registry, String file, List<String> path, Type type, List<ConversionFailure> failures, Object fileValue)
-
-
Method Details
-
readSerializable
public Object readSerializable(Object plain, Class<? extends org.bukkit.configuration.serialization.ConfigurationSerializable> factory) throws ConversionException Applies the ordinary registered hierarchy before delegate-aware Bukkit fallback.- Parameters:
plain- nested tagged mapfactory- registered alias factory- Returns:
- hydrated value
- Throws:
ConversionException- on alias conversion failure
-
file
- Specified by:
filein interfaceConversionContext- Returns:
- the configuration file's module-relative name
-
path
- Specified by:
pathin interfaceConversionContext- Returns:
- an immutable list of whole path segments
-
declaredType
- Specified by:
declaredTypein interfaceConversionContext- Returns:
- the declared Java type, including generic arguments
-
toPlain
Description copied from interface:ConversionContextConverts a nested Java value using its runtime type and the same registry.- Specified by:
toPlainin interfaceConversionContext- Parameters:
nested- the nested Java value- Returns:
- plain data
- Throws:
ConversionException- when conversion fails
-
fromPlain
Description copied from interface:ConversionContextConverts a nested document value through the same registry.- Specified by:
fromPlainin interfaceConversionContext- Type Parameters:
V- the result type- Parameters:
nested- the nested document valuedeclared- the declared nested Java type- Returns:
- the converted nested value
- Throws:
ConversionException- when conversion fails
-
writeTyped
- Parameters:
value- nested Java valuedeclared- nested type- Returns:
- plain data
- Throws:
ConversionException- on failure
-
readTyped
- Type Parameters:
V- result type- Parameters:
value- nested plain valuedeclared- nested type- Returns:
- converted value
- Throws:
ConversionException- on failure
-
child
The nested context carries the file's value at the nested location: the entry undersegmentwhen the file value is a map, the element at that index when it is a list andsegmentis an index, else none.- Parameters:
segment- whole key or indexdeclared- nested type- Returns:
- nested context
-
fileValue
- Returns:
- the plain value the file holds at this context's location, or
nullwhen unknown; a probe and every read carry none
-
probe
Readsplainasdeclaredthrough the same registry path the loader uses, at this context's location, without recording anything in this conversion's failure list: a refusal, or any nested omission, goes to a throw-away list and makes the probe fail. Used to check that a map key's text reads back to the key it was written from, and to index the keys a file holds.- Parameters:
plain- document value to readdeclared- type to read it as- Returns:
- the read value, or a failed probe; never throws a conversion failure
-
record
- Parameters:
raw- refused inputcause- failure at its original nested location
-
failure
- Parameters:
reason- failure descriptioncause- underlying failure- Returns:
- checked located failure
-
fileEntry
The file's value undersegment: the entry whose key is exactly that text, else the first entry in map order whose key reads as that text, through the index built once per map. -
entriesByText
entriesby key text (String.valueOf), keeping the first entry in map order for each text.
-