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

All Superinterfaces:
Iterable<T>
All Known Implementing Classes:
ShieldableSet

public interface ReadOnlySet<T>
extends Iterable<T>

A contract for a set that allows only read-only access to its contents. This has the advantage over java.util.Collections#unmodifiableSet() 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
 boolean contains(Object obj)
          Returns true if this set contains the specified element.
 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).
 Iterator<T> iterator()
          Returns an iterator over the elements in this set.
 int size()
          Determines the number of items in this instance.
 

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

contains

boolean contains(Object obj)
Returns true if this set contains the specified element.

Parameters:
obj - element whose presence in this set is to be tested
Returns:
true if this set contains the specified element

iterator

Iterator<T> iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Specified by:
iterator in interface Iterable<T>
Returns:
an iterator over the elements in this set

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.