Set<Type<?>> nullified = new HashSet<Type<?>>();
for ( int i = 1; i < bindings.length; i++ ) {
Binding<?> one = bindings[lastDistinctIndex];
Binding<?> other = bindings[i];
final boolean equalResource = one.resource.equalTo( other.resource );
DeclarationType oneType = one.source.getType();
DeclarationType otherType = other.source.getType();
if ( equalResource && oneType.clashesWith( otherType ) ) {
throw new IllegalStateException( "Duplicate binds:\n" + one + "\n" + other );
}
if ( other.source.getType() == DeclarationType.REQUIRED ) {
required.add( other.resource.getType() );
} else if ( equalResource && oneType.nullifiedBy( otherType ) ) {
if ( i - 1 == lastDistinctIndex ) {
uniques.remove( uniques.size() - 1 );
nullified.add( one.resource.getType() );
}
} else if ( !equalResource || !otherType.replacedBy( oneType ) ) {
uniques.add( other );
lastDistinctIndex = i;
}
}
if ( required.isEmpty() ) {