Interface Slot
- All Known Implementing Classes:
Slot.Indexed,Slot.XY
public interface Slot
A slot represents a position in some type of container. Implementors of this class represent slots in different ways.
- Since:
- 0.10.8
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA class representing a slot based on an index.static classA class representing a slot based on an (x, y) coordinate pair. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Slotdeserialize(@NotNull Element element) Deserializes the slot from an element.static @NotNull SlotfromIndex(int index) Creates a new slot based on an index.static @NotNull SlotfromXY(int x, int y) Creates a new slot based on an (x, y) coordinate pair.intgetX(int length) Gets the x coordinate of this slot.intgetY(int length) Gets the y coordinate of this slot.
-
Method Details
-
getX
@Contract(pure=true) int getX(int length) Gets the x coordinate of this slot.- Parameters:
length- the length of the parent container- Returns:
- the x coordinate of this slot
- Since:
- 0.10.8
-
getY
@Contract(pure=true) int getY(int length) Gets the y coordinate of this slot.- Parameters:
length- the length of the parent container- Returns:
- the y coordinate of this slot
- Since:
- 0.10.8
-
deserialize
@NotNull @Contract(value="_ -> new", pure=true) static @NotNull Slot deserialize(@NotNull @NotNull Element element) Deserializes the slot from an element. The slot may either be provided as an (x, y) coordinate pair via the "x" and "y" attributes; or as an index via the "index" attribute. If both forms are present, anXMLLoadExceptionwill be thrown. If only the "x" or the "y" attribute is present, but not both, anXMLLoadExceptionwill be thrown. If none of the aforementioned attributes appear, anXMLLoadExceptionwill be thrown. If any of these attributes contain a value that is not an integer, anXMLLoadExceptionwill be thrown. Otherwise, this will return a slot based on the present attributes.- Parameters:
element- the element from which to retrieve the attributes for the slot- Returns:
- the deserialized slot
- Throws:
XMLLoadException- if "x", "y", and "index" attributes are present; if only an "x" attribute is present; if only a "y" attribute is present; if no "x", "y", or "index" attribute is present; or if the "x", "y", or "index" attribute contain a value that is not an integer.
-
fromXY
Creates a new slot based on an (x, y) coordinate pair.- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the slot representing this position
- Since:
- 0.10.8
-
fromIndex
Creates a new slot based on an index. This index is relative to the parent container this slot will be used in.- Parameters:
index- the index- Returns:
- the slot representing this relative position
- Since:
- 0.10.8
-