diff options
| author | Rime <81419447+Emirlol@users.noreply.github.com> | 2024-07-27 12:00:30 +0300 |
|---|---|---|
| committer | Rime <81419447+Emirlol@users.noreply.github.com> | 2024-07-27 12:00:30 +0300 |
| commit | 036ede6ccf7c20226ae5f1f9e5b4950602e9e92d (patch) | |
| tree | d96a6fb77f1de69e4d22d51399142f5eca5d8743 /src/main/java | |
| parent | 44770abb621167802883abd18b34479e861326e5 (diff) | |
| download | Skyblocker-036ede6ccf7c20226ae5f1f9e5b4950602e9e92d.tar.gz Skyblocker-036ede6ccf7c20226ae5f1f9e5b4950602e9e92d.tar.bz2 Skyblocker-036ede6ccf7c20226ae5f1f9e5b4950602e9e92d.zip | |
Add more documentation to SlotText.java
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotText.java | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotText.java b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotText.java index 73224509..43960c9c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotText.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotText.java @@ -2,39 +2,59 @@ package de.hysky.skyblocker.skyblock.item.slottext; import it.unimi.dsi.fastutil.objects.ObjectLists; import net.minecraft.text.Text; +import org.jetbrains.annotations.NotNull; import java.util.List; -public record SlotText(Text text, TextPosition position) { - public static SlotText bottomLeft(Text text) { +public record SlotText(@NotNull Text text, @NotNull TextPosition position) { + public static SlotText bottomLeft(@NotNull Text text) { return new SlotText(text, TextPosition.BOTTOM_LEFT); } - public static SlotText bottomRight(Text text) { + public static SlotText bottomRight(@NotNull Text text) { return new SlotText(text, TextPosition.BOTTOM_RIGHT); } - public static SlotText topLeft(Text text) { + public static SlotText topLeft(@NotNull Text text) { return new SlotText(text, TextPosition.TOP_LEFT); } - public static SlotText topRight(Text text) { + public static SlotText topRight(@NotNull Text text) { return new SlotText(text, TextPosition.TOP_RIGHT); } - public static List<SlotText> topLeftList(Text text) { + // The methods below use ObjectLists.singleton rather than List.of because List.of + // has 1 more method call (a null check) and 1 more field set for no good reason. + + /** + * Convenience method for creating a singleton list containing this SlotText. Useful for returning a single SlotText from a method that returns a list. + * @return A singleton list containing a SlotText with the {@link TextPosition#TOP_LEFT top left} position and the given text. + */ + public static List<SlotText> topLeftList(@NotNull Text text) { return ObjectLists.singleton(topLeft(text)); } - public static List<SlotText> topRightList(Text text) { + /** + * Convenience method for creating a singleton list containing this SlotText. Useful for returning a single SlotText from a method that returns a list. + * @return A singleton list containing a SlotText with the {@link TextPosition#TOP_RIGHT top right} position and the given text. + */ + public static List<SlotText> topRightList(@NotNull Text text) { return ObjectLists.singleton(topRight(text)); } - public static List<SlotText> bottomLeftList(Text text) { + /** + * Convenience method for creating a singleton list containing this SlotText. Useful for returning a single SlotText from a method that returns a list. + * @return A singleton list containing a SlotText with the {@link TextPosition#BOTTOM_LEFT bottom left} position and the given text. + */ + public static List<SlotText> bottomLeftList(@NotNull Text text) { return ObjectLists.singleton(bottomLeft(text)); } - public static List<SlotText> bottomRightList(Text text) { + /** + * Convenience method for creating a singleton list containing this SlotText. Useful for returning a single SlotText from a method that returns a list. + * @return A singleton list containing a SlotText with the {@link TextPosition#BOTTOM_RIGHT bottom right} position and the given text. + */ + public static List<SlotText> bottomRightList(@NotNull Text text) { return ObjectLists.singleton(bottomRight(text)); } } |
