Package de.Keyle.MyPet.api.gui
Record Class CodecContext
java.lang.Object
java.lang.Record
de.Keyle.MyPet.api.gui.CodecContext
- Record Components:
- the menu being decoded, used in error messagesrows- the menu's height, for bounds checkssiblingSectionIds- ids of the other sections in the same menu
Information a
JsonCodec needs at decode time to validate section data
against its surrounding menu (bounds, sibling presence, etc.).-
Constructor Summary
ConstructorsConstructorDescriptionCodecContext(String menuId, int rows, Set<String> siblingSectionIds) Creates an instance of aCodecContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.menuId()Returns the value of themenuIdrecord component.voidrequireInBounds(String fieldName, int col, int row) Checks that a single slot lies inside the menu.voidrequireRegionInBounds(String fieldName, int col, int row, int width, int height) Checks that a rectangular region fits inside the menu.voidrequireSibling(String fieldName, String siblingId) Checks that a section this one refers to actually exists in the same menu.introws()Returns the value of therowsrecord component.Returns the value of thesiblingSectionIdsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CodecContext
Creates an instance of aCodecContextrecord class.- Parameters:
menuId- the value for themenuIdrecord componentrows- the value for therowsrecord componentsiblingSectionIds- the value for thesiblingSectionIdsrecord component
-
-
Method Details
-
requireInBounds
Checks that a single slot lies inside the menu.- Parameters:
fieldName- name of the JSON field being validated, used in the error messagecol- column, which must be in[0, 9)row- row, which must be in[0, rows)- Throws:
ValidationException- if the slot falls outside the menu
-
requireRegionInBounds
Checks that a rectangular region fits inside the menu.- Parameters:
fieldName- name of the JSON field being validated, used in the error messagecol- left-hand column of the regionrow- top row of the regionwidth- region width, which must be positiveheight- region height, which must be positive- Throws:
ValidationException- if any part of the region falls outside the menu
-
requireSibling
Checks that a section this one refers to actually exists in the same menu.- Parameters:
fieldName- name of the JSON field holding the referencesiblingId- id the field points at- Throws:
ValidationException- if no section in this menu has that id
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
rows
public int rows()Returns the value of therowsrecord component.- Returns:
- the value of the
rowsrecord component
-
siblingSectionIds
Returns the value of thesiblingSectionIdsrecord component.- Returns:
- the value of the
siblingSectionIdsrecord component
-