Source:
<code>public SpaceFillingCurveSettingsFactory( Config config ) { this.maxBits = config.get( SpatialIndexSettings.space_filling_curve_max_bits ); HashMap<CoordinateReferenceSystem,EnvelopeSettings> env = new HashMap<>(); for ( Map.Entry<String,ConfigValue> entry : config.getConfigValues().entrySet() ) { String key = entry.getKey(); String value = entry.getValue().toString(); if ( key.startsWith( SPATIAL_SETTING_PREFIX ) ) { String[] fields = key.replace( SPATIAL_SETTING_PREFIX, "" ).split( "\\." ); <START> if ( fields.length < 3 ) <END> { throw new IllegalArgumentException( "Invalid spatial config settings, expected three fields after '" + SPATIAL_SETTING_PREFIX + "': " + key ); } else { CoordinateReferenceSystem crs = CoordinateReferenceSystem.byName( fields[0] ); EnvelopeSettings envelopeSettings = env.computeIfAbsent( crs, EnvelopeSettings::new ); int index = "xyz".indexOf( fields[1].toLowerCase() ); if ( index < 0 ) { throw new IllegalArgumentException( "Invalid spatial coordinate key (should be one of 'x', 'y' or 'z'): " + fields[1] ); } switch ( fields[2].toLowerCase() ) { case "min": envelopeSettings.min[index] = Double.parseDouble( value ); break; case "max": envelopeSettings.max[index] = Double.parseDouble( value ); break; default: throw new IllegalArgumentException( "Invalid spatial coordinate range key (should be one of 'max' or 'min'): " + fields[2] ); } } } } for ( Map.Entry<CoordinateReferenceSystem,EnvelopeSettings> entry : env.entrySet() ) { CoordinateReferenceSystem crs = entry.getKey(); settings.put( crs, new SpaceFillingCurveSettings( crs.getDimension(), this.maxBits, entry.getValue().asEnvelope() ) ); } }</code><technical_language>fields longer 3? I check for exact throw error if fields is long</technical_language>

Target:
public SpaceFillingCurveSettingsFactory( Config config ) { this.maxBits = config.get( SpatialIndexSettings.space_filling_curve_max_bits ); HashMap<CoordinateReferenceSystem,EnvelopeSettings> env = new HashMap<>(); for ( Map.Entry<String,ConfigValue> entry : config.getConfigValues().entrySet() ) { String key = entry.getKey(); String value = entry.getValue().toString(); if ( key.startsWith( SPATIAL_SETTING_PREFIX ) ) { String[] fields = key.replace( SPATIAL_SETTING_PREFIX, "" ).split( "\\." ); if ( fields.length != 3 ) { throw new IllegalArgumentException( "Invalid spatial config settings, expected three fields after '" + SPATIAL_SETTING_PREFIX + "': " + key ); } else { CoordinateReferenceSystem crs = CoordinateReferenceSystem.byName( fields[0] ); EnvelopeSettings envelopeSettings = env.computeIfAbsent( crs, EnvelopeSettings::new ); int index = "xyz".indexOf( fields[1].toLowerCase() ); if ( index < 0 ) { throw new IllegalArgumentException( "Invalid spatial coordinate key (should be one of 'x', 'y' or 'z'): " + fields[1] ); } if ( index >= crs.getDimension() ) { throw new IllegalArgumentException( "Invalid spatial coordinate key for " + crs.getDimension() + "D: " + fields[1] ); } switch ( fields[2].toLowerCase() ) { case "min": envelopeSettings.min[index] = Double.parseDouble( value ); break; case "max": envelopeSettings.max[index] = Double.parseDouble( value ); break; default: throw new IllegalArgumentException( "Invalid spatial coordinate range key (should be one of 'max' or 'min'): " + fields[2] ); } } } } for ( Map.Entry<CoordinateReferenceSystem,EnvelopeSettings> entry : env.entrySet() ) { CoordinateReferenceSystem crs = entry.getKey(); settings.put( crs, new SpaceFillingCurveSettings( crs.getDimension(), this.maxBits, entry.getValue().asEnvelope() ) ); } }