/** * 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 Dependency ) { final Dependency that = (Dependency) o; equal = this.getName().equals( that.getName() ) && ( this.implementation == null ? that.implementation == null : this.implementation.equals( that.implementation ) ) && ( this.specification == null ? that.specification == null : this.specification.equals( that.specification ) ); } return equal; }
/** * Returns a hash code value for this object. * * @return a hash code value for this object. */ public int hashCode() { return this.getName().hashCode() + ( this.implementation == null ? 0 : this.implementation.hashCode() ) + ( this.specification == null ? 0 : this.specification.hashCode() ); }
/** * Setter for property {@code dependencies}. * * @param value the new dependencies for the collection. * * @throws DuplicateDependencyException if {@code value} contains duplicate * dependencies. */ public void setDependencies( final Dependency[] value ) { this.names.clear(); this.hashCode = 0; this.dependencies = null; if ( value != null ) { for ( int i = value.length - 1; i >= 0; i-- ) { this.hashCode += value[i].hashCode(); if ( this.names.put( value[i].getName(), value[i] ) != null ) { this.names.clear(); this.hashCode = 0; throw new DuplicateDependencyException( value[i].getName() ); } } this.dependencies = value; } }
private void linkDependencies() { for ( final Iterator it = this.implementations.values().iterator(); it.hasNext(); ) { final Implementation implementation = (Implementation) it.next(); for ( int i = implementation.getDeclaredDependencies().size() - 1; i >= 0; i-- ) { final Dependency d = implementation.getDeclaredDependencies(). getDependency( i ); final String key = implementation.getIdentifier() + '/' + d.getName(); final String name = (String) this.dependencies.get( key ); if ( name != null ) { d.setImplementation( d.getSpecification(). getImplementation( name ) ); } } } }