/** * Gets the number of modules held by the instance. * * @return the number of modules held by the instance. */ public final int size() { return this.getModules().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 Module[] mods = this.getModules(); for ( int i = mods.length - 1; i >= 0; i-- ) { buf.append( ", [" ).append( i ).append( "]=" ). append( mods[i] ); } buf.append( '}' ); return buf.toString(); }
/** * Gets a module for an index. * * @param index the index of the module to return. * * @return a reference to the module at {@code index}. * * @throws IndexOutOfBoundsException if {@code index} is negativ, * greater than or equal to {@code size()}. */ public final Module getModule( final int index ) { if ( index < 0 || index >= this.size() ) { throw new ArrayIndexOutOfBoundsException( index ); } return this.getModules()[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 Modules ) { final Modules that = (Modules) o; final Collection these = Arrays.asList( this.getModules() ); final Collection those = Arrays.asList( that.getModules() ); 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 Modules ret = (Modules) super.clone(); final Module[] mods = this.getModules(); final Module[] cloned = new Module[ mods.length ]; for ( int i = mods.length - 1; i >= 0; i-- ) { cloned[i] = (Module) mods[i].clone(); } ret.setModules( cloned ); return ret; } catch ( final CloneNotSupportedException e ) { throw new AssertionError( e ); } }
new Module[ this.modules.size() + 1 ]; System.arraycopy( this.modules.getModules(), 0, modulesWithPlatform, 0, this.modules.size() );