Skip to content

Commit 2b743f4

Browse files
committed
add annotations and excecptions
1 parent 1b8eb9a commit 2b743f4

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/main/java/minevalley/core/api/utils/Hologram.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import minevalley.core.api.modifiers.LocationModifier;
44
import minevalley.core.api.modifiers.VisibilityModifier;
55

6+
import javax.annotation.Nonnegative;
7+
import javax.annotation.Nonnull;
8+
69
@SuppressWarnings("unused")
710
public interface Hologram extends LocationModifier, VisibilityModifier {
811

@@ -11,24 +14,28 @@ public interface Hologram extends LocationModifier, VisibilityModifier {
1114
*
1215
* @return the lines of the hologram.
1316
*/
17+
@Nonnull
1418
String[] getLines();
1519

1620
/**
1721
* Returns the line at the specified index.
1822
*
1923
* @param line the index of the line.
2024
* @return the line at the specified index.
25+
* @throws IndexOutOfBoundsException if the line is out of bounds.
2126
*/
22-
default String getLine(int line) {
27+
default String getLine(@Nonnegative int line) throws IndexOutOfBoundsException {
2328
return getLines()[line];
2429
}
2530

2631
/**
2732
* Adds a line to the hologram.
2833
*
2934
* @param text the text of the line.
35+
* @throws IllegalArgumentException if the text is null.
3036
*/
31-
default void addLine(String text) {
37+
default void addLine(@Nonnull String text) throws IllegalArgumentException {
38+
if (text == null) throw new IllegalArgumentException("The text cannot be null.");
3239
addLineAfter(getLines().length - 1, text);
3340
}
3441

@@ -37,21 +44,26 @@ default void addLine(String text) {
3744
*
3845
* @param line the index of the line.
3946
* @param text the text of the line.
47+
* @throws IndexOutOfBoundsException if the line is out of bounds.
48+
* @throws IllegalArgumentException if the text is null.
4049
*/
41-
void addLineAfter(int line, String text);
50+
void addLineAfter(@Nonnegative int line, @Nonnull String text) throws IndexOutOfBoundsException, IllegalArgumentException;
4251

4352
/**
4453
* Changes the line at the specified index.
4554
*
4655
* @param line the index of the line.
4756
* @param text the new text of the line.
57+
* @throws IndexOutOfBoundsException if the line is out of bounds.
58+
* @throws IllegalArgumentException if the text is null.
4859
*/
49-
void changeLine(int line, String text);
60+
void changeLine(@Nonnegative int line, @Nonnull String text) throws IndexOutOfBoundsException, IllegalArgumentException;
5061

5162
/**
5263
* Removes the line at the specified index.
5364
*
5465
* @param line the index of the line.
66+
* @throws IndexOutOfBoundsException if the line is out of bounds.
5567
*/
56-
void removeLine(int line);
68+
void removeLine(@Nonnegative int line) throws IndexOutOfBoundsException;
5769
}

0 commit comments

Comments
 (0)