001 package org.nakedobjects.applib.events;
002
003 import org.nakedobjects.applib.Identifier;
004
005
006 /**
007 * Represents an interaction with a collection object itself.
008 *
009 */
010 public class CollectionMethodEvent extends AccessEvent {
011
012 private static final long serialVersionUID = 1L;
013 private final Object domainObject;
014 private final String methodName;
015 private final Object[] args;
016 private final Object returnValue;
017
018 public CollectionMethodEvent(
019 final Object source,
020 final Identifier collectionIdentifier,
021 final Object domainObject,
022 final String methodName,
023 final Object[] args,
024 final Object returnValue) {
025 super(source, collectionIdentifier);
026 this.domainObject = domainObject;
027 this.methodName = methodName;
028 this.args = args;
029 this.returnValue = returnValue;
030 }
031
032 /**
033 * The collection object (an instance of a <tt>List</tt> or a <tt>Set</tt> etc) that is the originator
034 * of this event.
035 *
036 * <p>
037 * The owning domain object is available using {@link #getDomainObject()}.
038 *
039 * @see #getDomainObject()
040 */
041 @Override
042 public Object getSource() {
043 return super.getSource();
044 }
045
046 /**
047 * The owner of the collection (an instance of <tt>Customer/tt> or <tt>Order</tt>, say).
048 *
049 * @see #getSource()
050 */
051 public Object getDomainObject() {
052 return domainObject;
053 }
054
055 /**
056 * The name of the method invoked on this collection, for example <tt>isEmpty</tt>.
057 *
058 * @return
059 */
060 public String getMethodName() {
061 return methodName;
062 }
063
064 /**
065 * The arguments with which the collection's {@link #getMethodName() method} was invoked.
066 */
067 public Object[] getArgs() {
068 return args;
069 }
070
071 /**
072 * The return value from the {@link #getMethodName() method} invocation.
073 */
074 public Object getReturnValue() {
075 return returnValue;
076 }
077
078 }