/** * Gets the number of arguments held by the instance. * * @return the number of arguments held by the instance. */ public final int size() { return this.getArguments().length; }
/** * Creates a string representing the properties of the instance. * * @return a string representing the properties of the instance. */ private String internalString() { final StringBuffer buf = new StringBuffer( 200 ).append( '{' ); buf.append( this.internalString( this ) ); final Argument[] args = this.getArguments(); for ( int i = args.length - 1; i >= 0; i-- ) { buf.append( ", [" ).append( i ).append( "]=" ). append( args[i] ); } buf.append( '}' ); return buf.toString(); }
/** * Gets an argument for an index. * * @param index the index of the argument to return. * * @return a reference to the argument at {@code index}. * * @throws IndexOutOfBoundsException if {@code index} is negativ, * greater than or equal to {@code size()}. */ public final Argument getArgument( final int index ) { if ( index < 0 || index >= this.size() ) { throw new ArrayIndexOutOfBoundsException( index ); } return this.getArguments()[index]; }
/** * Indicates whether some other object is equal to this one by comparing * the values of all properties. * * @param o the reference object with which to compare. * * @return {@code true} if this object is the same as {@code o}; * {@code false} otherwise. */ public boolean equals( final Object o ) { boolean equal = this == o; if ( !equal && o instanceof Arguments ) { final Arguments that = (Arguments) o; final Collection these = Arrays.asList( this.getArguments() ); final Collection those = Arrays.asList( that.getArguments() ); equal = this.size() == that.size() && these.containsAll( those ); } return equal; }
/** * Creates and returns a deep copy of this object. * * @return a clone of this instance. */ public Object clone() { try { final Arguments ret = (Arguments) super.clone(); final Argument[] args = this.getArguments(); final Argument[] cloned = new Argument[ args.length ]; for ( int i = args.length - 1; i >= 0; i-- ) { cloned[i] = (Argument) args[i].clone(); } ret.setArguments( cloned ); return ret; } catch ( final CloneNotSupportedException e ) { throw new AssertionError( e ); } }