diff --git a/redisson/src/main/java/org/redisson/api/RList.java b/redisson/src/main/java/org/redisson/api/RList.java index 1133810dd..4b22d1b6f 100644 --- a/redisson/src/main/java/org/redisson/api/RList.java +++ b/redisson/src/main/java/org/redisson/api/RList.java @@ -99,6 +99,14 @@ public interface RList extends List, RExpirable, RListAsync, RSortable< */ void fastRemove(int index); - boolean remove(Object o, int count); + /** + * Removes up to count occurrences of element + * + * @param element - element to find + * @param count - amount occurrences + * @return {@code true} if at least one element removed; + * or {@code false} if element isn't found + */ + boolean remove(Object element, int count); } diff --git a/redisson/src/main/java/org/redisson/api/RListAsync.java b/redisson/src/main/java/org/redisson/api/RListAsync.java index 22f16211c..41b51981d 100644 --- a/redisson/src/main/java/org/redisson/api/RListAsync.java +++ b/redisson/src/main/java/org/redisson/api/RListAsync.java @@ -37,7 +37,7 @@ public interface RListAsync extends RCollectionAsync, RSortableAsync> getAsync(int...indexes); /** - * Add element after elementToFind + * Inserts element after elementToFind * * @param elementToFind - object to find * @param element - object to add @@ -46,7 +46,7 @@ public interface RListAsync extends RCollectionAsync, RSortableAsync addAfterAsync(V elementToFind, V element); /** - * Add element before elementToFind + * Inserts element before elementToFind * * @param elementToFind - object to find * @param element - object to add @@ -54,13 +54,44 @@ public interface RListAsync extends RCollectionAsync, RSortableAsync addBeforeAsync(V elementToFind, V element); + /** + * Inserts element at index. + * Subsequent elements are shifted. + * + * @param index - index number + * @param element - element to insert + * @return {@code true} if list was changed + */ RFuture addAsync(int index, V element); - RFuture addAllAsync(int index, Collection coll); + /** + * Inserts elements at index. + * Subsequent elements are shifted. + * + * @param index - index number + * @param elements - elements to insert + * @return {@code true} if list changed + * or {@code false} if element isn't found + */ + RFuture addAllAsync(int index, Collection elements); - RFuture lastIndexOfAsync(Object o); + /** + * Returns last index of element or + * -1 if element isn't found + * + * @param element to find + * @return index of -1 if element isn't found + */ + RFuture lastIndexOfAsync(Object element); - RFuture indexOfAsync(Object o); + /** + * Returns last index of element or + * -1 if element isn't found + * + * @param element to find + * @return index of -1 if element isn't found + */ + RFuture indexOfAsync(Object element); /** * Set element at index. @@ -73,8 +104,21 @@ public interface RListAsync extends RCollectionAsync, RSortableAsync fastSetAsync(int index, V element); + /** + * Set element at index and returns previous element. + * + * @param index - index of object + * @param element - object + * @return previous element or null if element wasn't set. + */ RFuture setAsync(int index, V element); + /** + * Get element at index + * + * @param index - index of object + * @return element + */ RFuture getAsync(int index); /** @@ -94,10 +138,32 @@ public interface RListAsync extends RCollectionAsync, RSortableAsync trimAsync(int fromIndex, int toIndex); + /** + * Removes element at index. + * Works faster than {@link #removeAsync(Object, int)} but + * doesn't return element. + * + * @param index - index of object + * @return void + */ RFuture fastRemoveAsync(int index); + /** + * Removes element at index. + * + * @param index - index of object + * @return element or null if element wasn't set. + */ RFuture removeAsync(int index); - RFuture removeAsync(Object o, int count); + /** + * Removes up to count occurrences of element + * + * @param element - element to find + * @param count - amount occurrences + * @return {@code true} if at least one element removed; + * or {@code false} if element isn't found + */ + RFuture removeAsync(Object element, int count); } diff --git a/redisson/src/main/java/org/redisson/api/RListReactive.java b/redisson/src/main/java/org/redisson/api/RListReactive.java index 60ebc6c25..25c105210 100644 --- a/redisson/src/main/java/org/redisson/api/RListReactive.java +++ b/redisson/src/main/java/org/redisson/api/RListReactive.java @@ -63,20 +63,79 @@ public interface RListReactive extends RCollectionReactive, RSortableReact Flux iterator(int startIndex); - Mono lastIndexOf(Object o); + /** + * Returns last index of element or + * -1 if element isn't found + * + * @param element to find + * @return index of -1 if element isn't found + */ + Mono lastIndexOf(Object element); - Mono indexOf(Object o); + /** + * Returns last index of element or + * -1 if element isn't found + * + * @param element to find + * @return index of -1 if element isn't found + */ + Mono indexOf(Object element); + /** + * Inserts element at index. + * Subsequent elements are shifted. + * + * @param index - index number + * @param element - element to insert + * @return {@code true} if list was changed + */ Mono add(int index, V element); - Mono addAll(int index, Collection coll); + /** + * Inserts elements at index. + * Subsequent elements are shifted. + * + * @param index - index number + * @param elements - elements to insert + * @return {@code true} if list changed + * or {@code false} if element isn't found + */ + Mono addAll(int index, Collection elements); + /** + * Set element at index. + * Works faster than {@link #set(int, Object)} but + * doesn't return previous element. + * + * @param index - index of object + * @param element - object + * @return void + */ Mono fastSet(int index, V element); + /** + * Set element at index and returns previous element. + * + * @param index - index of object + * @param element - object + * @return previous element or null if element wasn't set. + */ Mono set(int index, V element); + /** + * Get element at index + * + * @param index - index of object + * @return element + */ Mono get(int index); + /** + * Removes element at index. + * + * @param index - index of object + * @return element or null if element wasn't set. + */ Mono remove(int index); /** diff --git a/redisson/src/main/java/org/redisson/api/RListRx.java b/redisson/src/main/java/org/redisson/api/RListRx.java index 776f71ac5..93691c5ca 100644 --- a/redisson/src/main/java/org/redisson/api/RListRx.java +++ b/redisson/src/main/java/org/redisson/api/RListRx.java @@ -62,20 +62,79 @@ public interface RListRx extends RCollectionRx, RSortableRx> { Flowable iterator(int startIndex); - Flowable lastIndexOf(Object o); + /** + * Returns last index of element or + * -1 if element isn't found + * + * @param element to find + * @return index of -1 if element isn't found + */ + Flowable lastIndexOf(Object element); - Flowable indexOf(Object o); + /** + * Returns last index of element or + * -1 if element isn't found + * + * @param element to find + * @return index of -1 if element isn't found + */ + Flowable indexOf(Object element); + /** + * Inserts element at index. + * Subsequent elements are shifted. + * + * @param index - index number + * @param element - element to insert + * @return {@code true} if list was changed + */ Flowable add(int index, V element); - Flowable addAll(int index, Collection coll); + /** + * Inserts elements at index. + * Subsequent elements are shifted. + * + * @param index - index number + * @param elements - elements to insert + * @return {@code true} if list changed + * or {@code false} if element isn't found + */ + Flowable addAll(int index, Collection elements); + /** + * Set element at index. + * Works faster than {@link #set(int, Object)} but + * doesn't return previous element. + * + * @param index - index of object + * @param element - object + * @return void + */ Flowable fastSet(int index, V element); + /** + * Set element at index and returns previous element. + * + * @param index - index of object + * @param element - object + * @return previous element or null if element wasn't set. + */ Flowable set(int index, V element); + /** + * Get element at index + * + * @param index - index of object + * @return element + */ Flowable get(int index); + /** + * Removes element at index. + * + * @param index - index of object + * @return element or null if element wasn't set. + */ Flowable remove(int index); /**