parent
0b9235f072
commit
b7e6a86c1e
@ -206,6 +206,32 @@ public final class MessageList<T> implements Iterable<T> {
|
||||
return elements[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first message in this list.
|
||||
*
|
||||
* @throws NoSuchElementException if this list is empty
|
||||
*/
|
||||
public T first() {
|
||||
if (size != 0) {
|
||||
return elements[0];
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last message in this list.
|
||||
*
|
||||
* @throws NoSuchElementException if this list is empty
|
||||
*/
|
||||
public T last() {
|
||||
if (size != 0) {
|
||||
return elements[size - 1];
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message on the given index.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user