ch.panter.li.bi.util
Interface ReadOnlyCollection<T>

All Superinterfaces:
Iterable<T>
All Known Subinterfaces:
ReadOnlyStack<T>
All Known Implementing Classes:
ShieldableArrayList, ShieldableStack

public interface ReadOnlyCollection<T>
extends Iterable<T>

A contract for a collection that allows only read-only access to its contents. This has the advantage over java.util.Collections#unmodifiableCollection() that the compiler already complains if an invalid operation is attempted on such an instance (as the modifying methods are not present on this interface) instead of throwing an exception at runtime.


Method Summary
 T get(int pos)
          Positional access to an item in this collection.
 boolean isEmpty()
          Determines whether this collection is empty.
 T[] itemsAsArray(T[] array)
          Returns an array containing all items of this instance according to the contract defined in java.util.Collection#toArray(T[] a).
 int size()
          Determines the number of items in this instance.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

isEmpty

boolean isEmpty()
Determines whether this collection is empty.

Returns:
true if this instance has no items in it, false otherwise.

size

int size()
Determines the number of items in this instance.

Returns:
the number of items in this instance

get

T get(int pos)
Positional access to an item in this collection.

Parameters:
pos - the position of the item to get
Returns:
the item at the given position

itemsAsArray

T[] itemsAsArray(T[] array)
Returns an array containing all items of this instance according to the contract defined in java.util.Collection#toArray(T[] a).

Parameters:
array - the target array
Returns:
an array containing all items of this instance


Copyright 2007-2007 SourceForge. All Rights Reserved.