001    package org.nakedobjects.applib.events;
002    
003    import org.nakedobjects.applib.Identifier;
004    
005    
006    /**
007     * Represents a check as to whether a particular argument for an action is valid or not.
008     * 
009     * <p>
010     * If {@link #getReason()} is not <tt>null</tt> then provides the reason why the argument is invalid;
011     * otherwise the argument is valid.
012     * 
013     * <p>
014     * Called once per argument, and before {@link ActionInvocationEvent}.
015     */
016    public class ActionArgumentEvent extends ValidityEvent implements ProposedHolderEvent {
017    
018        private static final long serialVersionUID = 1L;
019    
020        private final Object[] args;
021        private final int position;
022        private final Object proposed;
023    
024        public ActionArgumentEvent(final Object source, final Identifier actionIdentifier, final Object[] args, final int position) {
025            super(source, actionIdentifier);
026            this.args = args;
027            this.position = position;
028            this.proposed = args[position];
029        }
030    
031        public Object[] getArgs() {
032            return args;
033        }
034    
035        /**
036         * The position (0-based) of the invalid argument.
037         * 
038         * @return
039         */
040        public int getPosition() {
041            return position;
042        }
043    
044        public Object getProposed() {
045            return proposed;
046        }
047    
048    }