/** * Returns a hash code value for this object. * * @return a hash code value for this object. */ public final int hashCode() { return this.getIdentifier().hashCode() + ( this.getVersion() == null ? 0 : this.getVersion().hashCode() ); }
private Object requestImplementation( final Class specClass, final Specification spec, final Object object ) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Object resolved = object; Method accessor = null; try { if ( !specClass.isAssignableFrom( object.getClass() ) ) { accessor = object.getClass().getDeclaredMethod( spec.getIdentifier().replace( '.', '_' ), EMPTY ); accessor.setAccessible( true ); resolved = accessor.invoke( object, EMPTY ); } return resolved; } finally { if ( accessor != null ) { accessor.setAccessible( false ); } } }
/** * Setter for property {@code specifications}. * * @param value the new specifications for the instance. * * @throws DuplicateSpecificationException if {@code value} contains * duplicate specifications. */ public void setSpecifications( final Specification[] value ) { this.identifiers.clear(); this.hashCode = 0; this.specifications = null; if ( value != null ) { for ( int i = value.length - 1; i >= 0; i-- ) { this.hashCode += value[i].hashCode(); if ( this.identifiers.put( value[i].getIdentifier(), value[i] ) != null ) { this.identifiers.clear(); this.hashCode = 0; throw new DuplicateSpecificationException( value[i].getIdentifier() ); } } this.specifications = value; } }
/** * Indicates whether some other object is equal to this one by comparing * properties {@code identifier} and {@code version}. * * @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 final boolean equals( final Object o ) { boolean equal = o == this; if ( !equal && o instanceof Specification ) { final Specification that = (Specification) o; equal = this.getIdentifier().equals( that.getIdentifier() ) && ( this.getVersion() == null ? that.getVersion() == null : this.getVersion().equals( that.getVersion() ) ); } return equal; }
/** * Creates a string representing the properties of the instance. * * @return a string representing the properties of the instance. */ private String internalString() { return new StringBuffer( 500 ).append( '{' ). append( this.internalString( this ) ). append( ", name=" ).append( this.name ). append( ", bound=" ).append( this.bound ). append( ", implementation=" ). append( this.implementation == null ? "null" : this.implementation.getIdentifier() + "@" + this.implementation.getVersion() ). append( ", specification=" ). append( this.specification == null ? "null" : this.specification.getIdentifier() + "@" + this.specification.getVersion() ). append( ", properties=" ).append( this.properties ). append( '}' ).toString(); }
append( s.getIdentifier() ).append( "@" ). append( s.getVersion() );
/** * Setter for property {@code multiplicity}. * * @param value the new implementation multiplicity of the specification. * * @throws IllegalArgumentException if {@code value} is not equal to one of * the constants {@code MULTIPLICITY_ONE} or {@code MULTIPLICITY_MANY}. * @throws MultiplicityConstraintException if {@code value} equals * {@code MULTIPLICITY_ONE} and the specification currently has more than * one implementation defined. * * @see #MULTIPLICITY_ONE * @see #MULTIPLICITY_MANY */ public void setMultiplicity( final int value ) { if ( value != MULTIPLICITY_ONE && value != MULTIPLICITY_MANY ) { throw new IllegalArgumentException( Integer.toString( value ) ); } if ( value == MULTIPLICITY_ONE && this.getImplementations().size() > 1 ) { throw new MultiplicityConstraintException( this.getIdentifier() ); } this.multiplicity = value; }
specs.getSpecification( i ); map.put( declaredSpecification.getIdentifier(), declaredSpecification ); superSpecifications.getSpecification( i ); if ( !map.containsKey( superSpecification.getIdentifier() ) ) map.put( superSpecification.getIdentifier(), superSpecification );
spec.getIdentifier(), spec ) != null ) spec.getIdentifier() );
if ( !declaredDependency.getSpecification().getIdentifier(). equals( superDependency.getSpecification(). getIdentifier() ) ) this.getIdentifier(), declaredDependency.getName(), declaredDependency.getSpecification(). getIdentifier(), superDependency.getSpecification(). getIdentifier() );
mod.getSpecifications().getSpecification( j ); if ( spec.getIdentifier().equals( identifier ) )
DefaultModelBundle.getInstance(). getUnsupportedScopeMessage( Locale.getDefault(), spec.getIdentifier(), scope ) );
specs.getSpecification( j ).getIdentifier() ); specs.getSpecification( j ).getIdentifier(), true ) ) getIdentifier() ); getIdentifier(), true ) )
Class.forName( specification.getIdentifier(), true, classLoader );
value.size() != 1 ) throw new MultiplicityConstraintException( this.getIdentifier() );
spec.getIdentifier(), true, classLoader ); spec.getIdentifier() );
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() ); } } } } }
Class.forName( dependency.getSpecification().getIdentifier(), true, classLoader ); getIdentifier() );
Class.forName( dependency.getSpecification().getIdentifier(), true, classLoader );