org.perfectjpattern.core.structural.composite
Class Composite<C>
java.lang.Object
   java.util.AbstractCollection<E>
java.util.AbstractCollection<E>
       java.util.AbstractList<E>
java.util.AbstractList<E>
           java.util.ArrayList<C>
java.util.ArrayList<C>
               org.perfectjpattern.core.structural.composite.Composite<C>
org.perfectjpattern.core.structural.composite.Composite<C>
- Type Parameters:
- C- Component element type.
- All Implemented Interfaces: 
- Serializable, Cloneable, Iterable<C>, InvocationHandler, Collection<C>, List<C>, RandomAccess, IComposite<C>, ISurrogate<C>
- public final class Composite<C> 
- extends ArrayList<C>- implements IComposite<C>, InvocationHandler
Componentized implementation of IComposite interface. Creates
 composition of strongly type interfaces giving the user the dual view of this
 instance:
 
 - IComposite<E>where the user may manipulate the 
 composition e.g. add, remove, sort- Componentelements, etc.
- <E>type view of this composite- getComponent()so all- Componentoperations will be 
 transparently applied to the entire composition
 Composite type also provides an overridable method aggregate(Method, 
 Object[]) that defines how to aggregate multiple result for a function 
 call i.e. it defines how to aggregate the results providuced from a function
 call for the complete composition.
 
- Version:
- $Revision: 1.0 $ $Date: Nov 18, 2007 10:01:11 PM $
- Author:
- Giovanni Azua
- See Also:
- IComposite, 
Serialized Form
-  
- 
 
 
| Constructor Summary | 
| Composite(Class<C> anInterface)Creates a Composite<E> from the Component type interface.
 | 
 
| Method Summary | 
|  boolean | addAll(C... anElements)Appends all of the elements in the specified array to the end of
 this list, in the order that they are returned by the specified
 collection's iterator (optional operation).
 | 
| protected  Object | aggregate(Method aMethod,
          Object[] aResults)Returns aggregation of all results returned by each of the Component in 
 this composition.
 | 
|  C | getComponent()Returns the
 Componentinterface view<C>of thisISurrogate
 Client code calls this method to receive an instance of type
 <C>making accessible the Component business methods 
 while the underlying implementation is wrapped by this surrogate. | 
|  Object | invoke(Object aProxy,
       Method aMethod,
       Object[] anArguments)
 | 
 
| Methods inherited from class java.util.ArrayList | 
| add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize | 
 
 
 
 
| Methods inherited from interface java.util.List | 
| add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray | 
 
Composite
public Composite(Class<C> anInterface)
          throws IllegalArgumentException
- Creates a Composite<E> from the Component type interface.
 
- Parameters:
- anInterface- The Component interface to create Composite types of.
- Throws:
- IllegalArgumentException- 'anInterface' must not be null.
- IllegalArgumentException- 'anInterface' must be an interface type.
 
invoke
public Object invoke(Object aProxy,
                     Method aMethod,
                     Object[] anArguments)
              throws Throwable
- 
- Specified by:
- invokein interface- InvocationHandler
 
- 
- Throws:
- Throwable
 
getComponent
public C getComponent()
- Returns the Componentinterface view<C>of thisISurrogate
 
 Client code calls this method to receive an instance of type<C>making accessible the Component business methods 
 while the underlying implementation is wrapped by this surrogate.
 
- 
- Specified by:
- getComponentin interface- ISurrogate<C>
 
- 
- Returns:
- Componentinterface view- <C>of this- ISurrogatetype
 
addAll
public boolean addAll(C... anElements)
               throws IllegalArgumentException
- Appends all of the elements in the specified array to the end of
 this list, in the order that they are returned by the specified
 collection's iterator (optional operation).  The behavior of this
 operation is undefined if the specified collection is modified while
 the operation is in progress.  (Note that this will occur if the
 specified collection is this list, and it's nonempty.)
 
- 
- Specified by:
- addAllin interface- IComposite<C>
 
- 
- Parameters:
- anElements- Array containing elements to be added to this list
- Returns:
- true if this list changed as a result of the call
- Throws:
- IllegalArgumentException- if the specified collection contains one
         or more null elements, or if the specified collection is null
- See Also:
- List.add(Object)
 
aggregate
protected Object aggregate(Method aMethod,
                           Object[] aResults)
- Returns aggregation of all results returned by each of the Component in 
 this composition. Default implementation just returns null but provides
 a means to define specialized ways to aggregate results.
 
- 
 
- 
- Parameters:
- aMethod- Method that was called, relevant to discern and aggregate
        differently for different methods.
- aResults- Array of all results produced by all Components.
- Returns:
- aggregation of all results returned by each of the Component in 
         this composition.
 
Copyright © 2007-2009. All Rights Reserved.