Skip to content

Commit d6aa272

Browse files
committed
Add getValue method to ArrayTag and implementations
1 parent 2bde9db commit d6aa272

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/main/java/org/glavo/nbt/tag/ArrayTag.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public final boolean isEmpty() {
3030

3131
/// Returns the size of the array.
3232
public abstract int size();
33+
34+
/// Returns the element at the given index.
35+
///
36+
/// @throws IndexOutOfBoundsException if the index is out of bounds.
37+
public abstract E getValue(int index) throws IndexOutOfBoundsException;
3338
}

src/main/java/org/glavo/nbt/tag/ByteArrayTag.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public byte get(int index) throws IndexOutOfBoundsException {
6464
return value[index];
6565
}
6666

67+
@Override
68+
public Byte getValue(int index) throws IndexOutOfBoundsException {
69+
return get(index);
70+
}
71+
6772
/// Sets the element at the given index.
6873
///
6974
/// @throws IndexOutOfBoundsException if the index is out of bounds.

src/main/java/org/glavo/nbt/tag/IntArrayTag.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public int get(int index) throws IndexOutOfBoundsException {
6464
return value[index];
6565
}
6666

67+
@Override
68+
public Integer getValue(int index) throws IndexOutOfBoundsException {
69+
return get(index);
70+
}
71+
6772
/// Sets the element at the given index.
6873
///
6974
/// @throws IndexOutOfBoundsException if the index is out of bounds.

src/main/java/org/glavo/nbt/tag/LongArrayTag.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public long get(int index) throws IndexOutOfBoundsException {
6565
return value[index];
6666
}
6767

68+
@Override
69+
public Long getValue(int index) throws IndexOutOfBoundsException {
70+
return get(index);
71+
}
72+
6873
/// Sets the element at the given index.
6974
///
7075
/// @throws IndexOutOfBoundsException if the index is out of bounds.

0 commit comments

Comments
 (0)