DefaultNameFactory changes for revisions 13841:13842

The condition and the loop have been rewritten in a way which works both for Object[] arrays and Collection instances. The condition in the committed code is totally different. The loop in the committed code is as below:

for (int i=0; i<values.length; i++) {
    value = values[i];
    name = createFromObject(value);
    if (name == null) {
        throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_2,
                "value[" + i + ']', value.getClass()));
    }
    names[i] = name;
}

While this looks like similar, there is few alternatives in the way to write such loop.

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r13841:13842 https://svn.osgeo.org/geotools/trunk/modules/library/metadata/src/main/java/org/geotools/util/NameFactory.java
Revision 13841Revision 13842
import java.util.List;
import java.util.Locale;

import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import java.util.List;
import java.util.Locale;

import org.opengis.metadata.Identifier;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
            return names;
        } else if (value instanceof GenericName) {
            return new GenericName[] {(GenericName) value};
        } else {
            return (GenericName[]) value;
        }
    }
}
            return names;
        } else if (value instanceof GenericName) {
            return new GenericName[] {(GenericName) value};
        }
        else if( value instanceof Identifier[]){
            final Identifier[] values = (Identifier[]) value;
            final GenericName[] names = new GenericName[ values.length ];
            for( int i=0; i<values.length; i++){
                names[i] = create( values[i].getCode() );
            }
            return names;
        }
        else if( value instanceof GenericName[]){
            return (GenericName[]) value;
        }
        else {
            throw new ClassCastException("Cannot convert "+value.toString()+ " to GenericName[]" );
    }
}
}