Package de.Keyle.MyPet.api.gui
Record Class SectionType<S extends Section>
java.lang.Object
java.lang.Record
de.Keyle.MyPet.api.gui.SectionType<S>
- Type Parameters:
S- the section record this type describes- Record Components:
id- the type id as it appears in menu JSONsectionClass- the record class decoded instances haverenderer- draws the section and handles clicks on its slotscodec- reads and writes the section's JSON form
public record SectionType<S extends Section>(String id, Class<S extends Section> sectionClass, SectionRenderer<S extends Section> renderer, JsonCodec<S extends Section> codec)
extends Record
Pairs a section's type id with its concrete record class, renderer, and codec.
Built-in types are static fields on type-holder classes that call
register(java.lang.String, java.lang.Class<S>, de.Keyle.MyPet.api.gui.SectionRenderer<S>, de.Keyle.MyPet.api.gui.JsonCodec<S>) from a static initializer; the registry forces those classes
to load at plugin OnLoad.-
Constructor Summary
ConstructorsConstructorDescriptionSectionType(String id, Class<S> sectionClass, SectionRenderer<S> renderer, JsonCodec<S> codec) Creates an instance of aSectionTyperecord class. -
Method Summary
Modifier and TypeMethodDescriptioncodec()Returns the value of thecodecrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.static <S extends Section>
SectionType<S> register(String id, Class<S> sectionClass, SectionRenderer<S> renderer, JsonCodec<S> codec) Builds a section type and registers it in one step, so a type-holder class can assign the result straight to astatic finalfield.renderer()Returns the value of therendererrecord component.Returns the value of thesectionClassrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SectionType
public SectionType(String id, Class<S> sectionClass, SectionRenderer<S> renderer, JsonCodec<S> codec) Creates an instance of aSectionTyperecord class.- Parameters:
id- the value for theidrecord componentsectionClass- the value for thesectionClassrecord componentrenderer- the value for therendererrecord componentcodec- the value for thecodecrecord component
-
-
Method Details
-
register
public static <S extends Section> SectionType<S> register(String id, Class<S> sectionClass, SectionRenderer<S> renderer, JsonCodec<S> codec) Builds a section type and registers it in one step, so a type-holder class can assign the result straight to astatic finalfield.- Type Parameters:
S- the section record this type describes- Parameters:
id- the type id as it appears in menu JSONsectionClass- the record class decoded instances haverenderer- draws the section and handles clicks on its slotscodec- reads and writes the section's JSON form- Returns:
- the newly registered type
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
sectionClass
Returns the value of thesectionClassrecord component.- Returns:
- the value of the
sectionClassrecord component
-
renderer
Returns the value of therendererrecord component.- Returns:
- the value of the
rendererrecord component
-
codec
Returns the value of thecodecrecord component.- Returns:
- the value of the
codecrecord component
-