/** * 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; }
/** * Gets a collection of all implementations of all modules held by the * instance. * * @return a reference to all implementations of all modules held by the * instance. */ public Implementations getImplementations() { if ( this.implementations == null ) { this.implementations = new Implementations(); } final Collection col = new ArrayList( this.implementations.size() ); for ( int i = this.size() - 1; i >= 0; i-- ) { final Module mod = this.getModule( i ); for ( int j = mod.getImplementations().size() - 1; j >= 0; j-- ) { col.add( mod.getImplementations().getImplementation( j ) ); } } this.implementations.setImplementations( (Implementation[]) col.toArray( new Implementation[ col.size() ] ) ); return this.implementations; }
/** * Gets a collection of all specifications of all modules. * * @return a reference to all specifications of all modules held by the * instance. */ public Specifications getSpecifications() { if ( this.specifications == null ) { this.specifications = new Specifications(); } final Collection col = new ArrayList( this.specifications.size() ); for ( int i = this.size() - 1; i >= 0; i-- ) { final Module mod = this.getModule( i ); for ( int j = mod.getSpecifications().size() - 1; j >= 0; j-- ) { col.add( mod.getSpecifications().getSpecification( j ) ); } } this.specifications.setSpecifications( (Specification[]) col.toArray( new Specification[ col.size() ] ) ); return this.specifications; }
for ( int i = this.size() - 1; i >= 0 && ret == null; i-- )
for ( int i = this.size() - 1; i >= 0 && ret == null; i-- )
private void updateSpecificationReferences() { for ( int m = this.modules.size() - 1; m >= 0; m-- ) { final Module module = this.modules.getModule( m ); for ( int s = module.getSpecifications().size() - 1; s >= 0; s-- ) { final Specification spec = module.getSpecifications(). getSpecification( s ); final Collection references = (Collection) this.specifications.get( spec.getIdentifier() ); assert references != null : "Expected specification meta-data."; for ( final Iterator it = references.iterator(); it.hasNext(); ) { final Specification reference = (Specification) it.next(); reference.setModuleName( module.getName() ); if ( !reference.equals( spec ) ) { reference.setDocumentation( spec.getDocumentation() ); reference.setMultiplicity( spec.getMultiplicity() ); reference.setProperties( spec.getProperties() ); reference.setScope( spec.getScope() ); reference.setStateless( spec.isStateless() ); reference.setVendor( spec.getVendor() ); reference.setModelVersion( spec.getModelVersion() ); } } } } }