Add javadocs
This commit is contained in:
parent
68c737f0c0
commit
d9806c8127
@ -36,10 +36,16 @@ public final class MessageList<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new empty {@link MessageList} instance
|
||||||
|
*/
|
||||||
public static <T> MessageList<T> newInstance() {
|
public static <T> MessageList<T> newInstance() {
|
||||||
return newInstance(DEFAULT_INITIAL_CAPACITY);
|
return newInstance(DEFAULT_INITIAL_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new empty {@link MessageList} instance with the given capacity.
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> MessageList<T> newInstance(int minCapacity) {
|
public static <T> MessageList<T> newInstance(int minCapacity) {
|
||||||
MessageList<T> ret = (MessageList<T>) RECYCLER.get();
|
MessageList<T> ret = (MessageList<T>) RECYCLER.get();
|
||||||
@ -47,12 +53,18 @@ public final class MessageList<T> {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link MessageList} instance which holds the given value
|
||||||
|
*/
|
||||||
public static <T> MessageList<T> newInstance(T value) {
|
public static <T> MessageList<T> newInstance(T value) {
|
||||||
MessageList<T> ret = newInstance(MIN_INITIAL_CAPACITY);
|
MessageList<T> ret = newInstance(MIN_INITIAL_CAPACITY);
|
||||||
ret.add(value);
|
ret.add(value);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call {@link ByteBufUtil#retain(Object)} on all messages in this {@link MessageList} and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> retainAll() {
|
public MessageList<T> retainAll() {
|
||||||
int size = this.size;
|
int size = this.size;
|
||||||
for (int i = 0; i < size; i ++) {
|
for (int i = 0; i < size; i ++) {
|
||||||
@ -61,6 +73,9 @@ public final class MessageList<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call {@link ByteBufUtil#retain(Object), int} on all messages in this {@link MessageList} and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> retainAll(int increment) {
|
public MessageList<T> retainAll(int increment) {
|
||||||
int size = this.size;
|
int size = this.size;
|
||||||
for (int i = 0; i < size; i ++) {
|
for (int i = 0; i < size; i ++) {
|
||||||
@ -69,6 +84,10 @@ public final class MessageList<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call {@link ByteBufUtil#release(Object)} on all messages in this {@link MessageList} and return {@code true}
|
||||||
|
* if all messages were released.
|
||||||
|
*/
|
||||||
public boolean releaseAll() {
|
public boolean releaseAll() {
|
||||||
boolean releasedAll = true;
|
boolean releasedAll = true;
|
||||||
int size = this.size;
|
int size = this.size;
|
||||||
@ -78,6 +97,10 @@ public final class MessageList<T> {
|
|||||||
return releasedAll;
|
return releasedAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call {@link ByteBufUtil#release(Object, int)} on all messages in this {@link MessageList} and return
|
||||||
|
* {@code true} if all messages were released.
|
||||||
|
*/
|
||||||
public boolean releaseAll(int decrement) {
|
public boolean releaseAll(int decrement) {
|
||||||
boolean releasedAll = true;
|
boolean releasedAll = true;
|
||||||
int size = this.size;
|
int size = this.size;
|
||||||
@ -87,14 +110,25 @@ public final class MessageList<T> {
|
|||||||
return releasedAll;
|
return releasedAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Short-cut for calling {@link #releaseAll()} and {@link #recycle()}. Returns {@code true} if both return
|
||||||
|
* {@code true}.
|
||||||
|
*/
|
||||||
public boolean releaseAllAndRecycle() {
|
public boolean releaseAllAndRecycle() {
|
||||||
return releaseAll() && recycle();
|
return releaseAll() && recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Short-cut for calling {@link #releaseAll(int)} and {@link #recycle()}. Returns {@code true} if both return
|
||||||
|
* {@code true}.
|
||||||
|
*/
|
||||||
public boolean releaseAllAndRecycle(int decrement) {
|
public boolean releaseAllAndRecycle(int decrement) {
|
||||||
return releaseAll(decrement) && recycle();
|
return releaseAll(decrement) && recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear and recycle this instance.
|
||||||
|
*/
|
||||||
public boolean recycle() {
|
public boolean recycle() {
|
||||||
clear();
|
clear();
|
||||||
return RECYCLER.recycle(this, handle);
|
return RECYCLER.recycle(this, handle);
|
||||||
@ -120,23 +154,32 @@ public final class MessageList<T> {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current size of this {@link MessageList} and so how many messages it holds.
|
||||||
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int capacity() {
|
/**
|
||||||
return elements.length;
|
* Return {@code true} if this {@link MessageList} is empty and so contains no messages.
|
||||||
}
|
*/
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return size == 0;
|
return size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the message on the given index. This method will throw an {@link IndexOutOfBoundsException} if there is
|
||||||
|
* no message stored in the given index.
|
||||||
|
*/
|
||||||
public T get(int index) {
|
public T get(int index) {
|
||||||
checkExclusive(index);
|
checkExclusive(index);
|
||||||
return elements[index];
|
return elements[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the message to this {@link MessageList} and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> add(T value) {
|
public MessageList<T> add(T value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException("value");
|
throw new NullPointerException("value");
|
||||||
@ -149,6 +192,9 @@ public final class MessageList<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the messages contained in the array to this {@link MessageList} and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> add(T[] src) {
|
public MessageList<T> add(T[] src) {
|
||||||
if (src == null) {
|
if (src == null) {
|
||||||
throw new NullPointerException("src");
|
throw new NullPointerException("src");
|
||||||
@ -156,6 +202,10 @@ public final class MessageList<T> {
|
|||||||
return add(src, 0, src.length);
|
return add(src, 0, src.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the messages contained in the array, using the given src index and src length, to this {@link MessageList}
|
||||||
|
* and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> add(T[] src, int srcIdx, int srcLen) {
|
public MessageList<T> add(T[] src, int srcIdx, int srcLen) {
|
||||||
checkElements(src, srcIdx, srcLen);
|
checkElements(src, srcIdx, srcLen);
|
||||||
|
|
||||||
@ -167,24 +217,41 @@ public final class MessageList<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the messages contained in the given {@link MessageList} to this {@link MessageList} and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> add(MessageList<T> src) {
|
public MessageList<T> add(MessageList<T> src) {
|
||||||
return add(src, 0, src.size());
|
return add(src, 0, src.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the messages contained in the given {@link MessageList}, using the given src index and src length, to this
|
||||||
|
* {@link MessageList} and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> add(MessageList<T> src, int srcIdx, int srcLen) {
|
public MessageList<T> add(MessageList<T> src, int srcIdx, int srcLen) {
|
||||||
return add(src.elements, srcIdx, srcLen);
|
return add(src.elements, srcIdx, srcLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all messages and return itself.
|
||||||
|
*/
|
||||||
public MessageList<T> clear() {
|
public MessageList<T> clear() {
|
||||||
Arrays.fill(elements, 0, size, null);
|
Arrays.fill(elements, 0, size, null);
|
||||||
size = 0;
|
size = 0;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new copy all messages of this {@link MessageList} and return it.
|
||||||
|
*/
|
||||||
public MessageList<T> copy() {
|
public MessageList<T> copy() {
|
||||||
return new MessageList<T>(handle, elements.clone(), size);
|
return new MessageList<T>(handle, elements.clone(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new copy all messages of this {@link MessageList}, starting at the given index and using the given len,
|
||||||
|
* and return it.
|
||||||
|
*/
|
||||||
public MessageList<T> copy(int index, int length) {
|
public MessageList<T> copy(int index, int length) {
|
||||||
checkRange(index, length);
|
checkRange(index, length);
|
||||||
MessageList<T> copy = new MessageList<T>(handle, length);
|
MessageList<T> copy = new MessageList<T>(handle, length);
|
||||||
|
Loading…
Reference in New Issue
Block a user