TypedContainer
| Kind of class: | public interface |
|---|---|
| Package: | com.bourre.collection |
| Inherits from: | none |
| Implemented by: | |
| Author: | Cédric Néhémie |
| Classpath: | com.bourre.collection.TypedContainer |
| File last modified: | Thursday, 10 January 2008, 15:16:50 |
A
to provide runtime type checking over their elements.
TypedContainer allow collections and data structures to provide runtime type checking over their elements.
A typed container does not define how elements are inserted into
the container, but provides convenient methods to check type
of these elements and to know if the container is typed and which
type the container support.
By convention, the constructor of an implementation of the TypedContainer interface will define an optional argumenttype such type : Class = null which let
the user of the class define if the container is typed and which
type the container support.
When dealing with typed and untyped container, the following rules apply :
- Two typed container, which have the same type, can collaborate each other.
- Two untyped container can collaborate each other.
- An untyped container can add, remove, retain or contains any typed container
of any type without throwing errors. - A typed container will always fail when attempting to add, remove, retain
or contains an untyped container.
Summary
Instance methods
getType
public function getType (
) : Class
Return the class type of elements in this container.
An untyped container returns null, as the
wildcard type (*) is not a Classand Object class doesn't fit for primitive types.
Returns:
-
Classtype of the container's elements
isTyped
public function isTyped (
) : Boolean
Returns
of the type of elements.
true if this container perform a verificationof the type of elements.
Returns:
-
trueif this container perform a verification
of the type of elements.
matchType
public function matchType (
o:*) : Boolean
Verify that the passed-in object type match the current
container element's type.
container element's type.
Returns:
-
trueif the object is elligible for this
container, eitherfalse.