From b2d8e33bd9d8aa925aee5e48a9d3784e842f61de Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Fri, 3 Jul 2020 20:31:11 +0300 Subject: Add missing Nullable annotations and a getter to WButton --- .../github/cottonmc/cotton/gui/widget/WButton.java | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java index 77c76d1..18da1e4 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java @@ -13,6 +13,8 @@ import net.minecraft.text.StringRenderable; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment; +import javax.annotation.Nullable; + public class WButton extends WWidget { private StringRenderable label; protected int color = WLabel.DEFAULT_TEXT_COLOR; @@ -20,8 +22,8 @@ public class WButton extends WWidget { private boolean enabled = true; protected HorizontalAlignment alignment = HorizontalAlignment.CENTER; - private Runnable onClick; - private Icon icon = null; + @Nullable private Runnable onClick; + @Nullable private Icon icon = null; /** * Constructs a button with no label and no icon. @@ -132,8 +134,25 @@ public class WButton extends WWidget { } } - public WButton setOnClick(Runnable r) { - this.onClick = r; + /** + * Gets the click handler of this button. + * + * @return the click handler + * @since 2.2.0 + */ + @Nullable + public Runnable getOnClick() { + return onClick; + } + + /** + * Sets the click handler of this button. + * + * @param onClick the new click handler + * @return this button + */ + public WButton setOnClick(@Nullable Runnable onClick) { + this.onClick = onClick; return this; } @@ -170,6 +189,7 @@ public class WButton extends WWidget { * @return the icon * @since 2.2.0 */ + @Nullable public Icon getIcon() { return icon; } @@ -181,7 +201,7 @@ public class WButton extends WWidget { * @return this button * @since 2.2.0 */ - public WButton setIcon(Icon icon) { + public WButton setIcon(@Nullable Icon icon) { this.icon = icon; return this; } -- cgit