1616package org .glavo .nbt .tag ;
1717
1818import org .glavo .nbt .internal .ArrayAccessor ;
19+ import org .intellij .lang .annotations .Flow ;
1920import org .jetbrains .annotations .Contract ;
2021import org .jetbrains .annotations .MustBeInvokedByOverriders ;
2122import org .jetbrains .annotations .Nullable ;
@@ -160,6 +161,8 @@ public final A getArray() {
160161 }
161162
162163 @ Override
164+ @ Contract (pure = true )
165+ @ Flow (sourceIsContainer = true )
163166 public T getTag (int index ) throws IndexOutOfBoundsException {
164167 Objects .checkIndex (index , size );
165168
@@ -187,6 +190,7 @@ public T getTag(int index) throws IndexOutOfBoundsException {
187190 /// @see IntArrayTag#get(int)
188191 /// @see LongArrayTag#get(int)
189192 @ Contract (pure = true )
193+ @ Flow (sourceIsContainer = true )
190194 public final E getValue (int index ) throws IndexOutOfBoundsException {
191195 Objects .checkIndex (index , size );
192196 return accessor ().get (values , index );
@@ -198,6 +202,7 @@ public final E getValue(int index) throws IndexOutOfBoundsException {
198202 ///
199203 /// Each call returns a new buffer, but the underlying implementation may share the same array.
200204 @ Contract (value = "-> new" , pure = true )
205+ @ Flow (sourceIsContainer = true , targetIsContainer = true )
201206 public final B getBuffer () {
202207 return accessor ().getReadOnlyView (values , 0 , size );
203208 }
@@ -217,7 +222,7 @@ final void setArrayWithoutClone(A array, int size) {
217222 ///
218223 /// @throws IndexOutOfBoundsException if the index is out of bounds.
219224 @ Contract (mutates = "this" )
220- public abstract void set (int index , E value ) throws IndexOutOfBoundsException ;
225+ public abstract void set (int index , @ Flow ( targetIsContainer = true ) E value ) throws IndexOutOfBoundsException ;
221226
222227 /// Sets all values of the tag from an array.
223228 ///
@@ -226,7 +231,8 @@ final void setArrayWithoutClone(A array, int size) {
226231 /// Calling this method will clear the current array, all subtags will be removed.
227232 @ Contract (mutates = "this" )
228233 @ MustBeInvokedByOverriders
229- public void setAll (A array ) {
234+ public void setAll (@ Flow (sourceIsContainer = true , targetIsContainer = true )
235+ A array ) {
230236 clear ();
231237
232238 int newSize = accessor ().getLength (array );
@@ -243,7 +249,8 @@ public void setAll(A array) {
243249 ///
244250 /// Calling this method will clear the current array, all subtags will be removed.
245251 @ Contract (mutates = "this,param1" )
246- public final void setAll (B buffer ) {
252+ public final void setAll (@ Flow (sourceIsContainer = true , targetIsContainer = true )
253+ B buffer ) {
247254 clear ();
248255
249256 if (buffer .hasRemaining ()) {
@@ -254,11 +261,13 @@ public final void setAll(B buffer) {
254261
255262 /// Appends the specified value to the end of this array.
256263 @ Contract (mutates = "this" )
257- public abstract void add (E value );
264+ public abstract void add (@ Flow (targetIsContainer = true )
265+ E value );
258266
259267 @ Override
260268 @ Contract (mutates = "this,param1" )
261- public final void addTag (T tag ) throws IllegalArgumentException {
269+ public final void addTag (@ Flow (targetIsContainer = true )
270+ T tag ) throws IllegalArgumentException {
262271 if (tag .getParentTag () != null ) {
263272 if (tag .getParentTag () == this ) {
264273 int index = tag .getIndex ();
0 commit comments