Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -20,6 +20,7 @@ import java.util.List; import org.opengis.parameter.ParameterValue; import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.GeneralParameterValue; +import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.GeneralParameterDescriptor; import org.opengis.parameter.ParameterNotFoundException; @@ -32,8 +33,6 @@ import org.junit.Test; import static java.util.Collections.singletonMap; import static org.opengis.test.Validators.validate; -import static org.apache.sis.parameter.TensorParameters.WKT1; -import static org.apache.sis.parameter.TensorParametersTest.assertDescriptorEquals; import static org.apache.sis.test.MetadataAssert.*; @@ -42,10 +41,10 @@ import static org.apache.sis.test.Metada * * @author Martin Desruisseaux (Geomatys) * @since 0.4 - * @version 0.4 + * @version 0.6 * @module */ -@DependsOn(TensorParametersTest.class) +@DependsOn(MatrixParametersTest.class) public final strictfp class TensorValuesTest extends TestCase { /** * The name of the parameter group created in this test class. @@ -53,14 +52,33 @@ public final strictfp class TensorValues private static final String GROUP_NAME = "Group test"; /** - * Creates an instance for a matrix. + * Creates an instance for a matrix using the WKT 1 conventions. */ private static ParameterValueGroup create() { - return WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, GROUP_NAME)); + return TensorParameters.WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, GROUP_NAME)); + } + + /** + * Asserts that the given descriptor has the given name and default value. + * Aliases and identifiers are ignored - testing them is the purpose of {@link MatrixParametersTest}. + * + * @param name The expected parameter name. + * @param defaultValue The expected parameter default value. + * @param actual The actual parameter to verify. + */ + private static void assertDescriptorEquals(final String name, final Number defaultValue, + final GeneralParameterDescriptor actual) + { + assertEquals(name, actual.getName().getCode()); + assertEquals(name, defaultValue, ((ParameterDescriptor<?>) actual).getDefaultValue()); } /** * Asserts that the given parameter has the given name and value. + * + * @param name The expected parameter name. + * @param value The expected parameter value. + * @param actual The actual parameter to verify. */ private static void assertValueEquals(final String name, final Number value, final GeneralParameterValue actual) { assertEquals(name, actual.getDescriptor().getName().getCode()); @@ -72,30 +90,30 @@ public final strictfp class TensorValues */ @Test public void testDescriptors() { - final Double ZERO = 0.0; - final Double ONE = 1.0; - final Integer THREE = 3; + final Double N0 = 0.0; + final Double N1 = 1.0; + final Integer N3 = 3; final ParameterValueGroup group = create(); group.parameter("num_row").setValue(1); group.parameter("num_col").setValue(1); List<GeneralParameterDescriptor> descriptors = group.getDescriptor().descriptors(); - assertDescriptorEquals("num_row", THREE, descriptors.get(0)); - assertDescriptorEquals("num_col", THREE, descriptors.get(1)); - assertDescriptorEquals("elt_0_0", ONE, descriptors.get(2)); + assertDescriptorEquals("num_row", N3, descriptors.get(0)); + assertDescriptorEquals("num_col", N3, descriptors.get(1)); + assertDescriptorEquals("elt_0_0", N1, descriptors.get(2)); assertEquals("size", 3, descriptors.size()); group.parameter("num_row").setValue(2); group.parameter("num_col").setValue(3); descriptors = group.getDescriptor().descriptors(); - assertDescriptorEquals("num_row", THREE, descriptors.get(0)); - assertDescriptorEquals("num_col", THREE, descriptors.get(1)); - assertDescriptorEquals("elt_0_0", ONE, descriptors.get(2)); - assertDescriptorEquals("elt_0_1", ZERO, descriptors.get(3)); - assertDescriptorEquals("elt_0_2", ZERO, descriptors.get(4)); - assertDescriptorEquals("elt_1_0", ZERO, descriptors.get(5)); - assertDescriptorEquals("elt_1_1", ONE, descriptors.get(6)); - assertDescriptorEquals("elt_1_2", ZERO, descriptors.get(7)); + assertDescriptorEquals("num_row", N3, descriptors.get(0)); + assertDescriptorEquals("num_col", N3, descriptors.get(1)); + assertDescriptorEquals("elt_0_0", N1, descriptors.get(2)); + assertDescriptorEquals("elt_0_1", N0, descriptors.get(3)); + assertDescriptorEquals("elt_0_2", N0, descriptors.get(4)); + assertDescriptorEquals("elt_1_0", N0, descriptors.get(5)); + assertDescriptorEquals("elt_1_1", N1, descriptors.get(6)); + assertDescriptorEquals("elt_1_2", N0, descriptors.get(7)); assertEquals("size", 8, descriptors.size()); } @@ -112,7 +130,11 @@ public final strictfp class TensorValues assertValueEquals("num_row", 2, values.get(0)); assertValueEquals("num_col", 3, values.get(1)); assertEquals("size", 2, values.size()); - + /* + * Above list had no explicit parameters, since all of them had their default values. + * Now set some parameters to different values. Those parameters should now appear in + * the list. + */ group.parameter("elt_0_1").setValue(8); group.parameter("elt_1_1").setValue(7); group.parameter("elt_1_2").setValue(6); @@ -130,12 +152,34 @@ public final strictfp class TensorValues */ @Test public void testDescriptor() { + final Double N0 = 0.0; + final Double N1 = 1.0; + final Integer N3 = 3; final ParameterValueGroup group = create(); final ParameterDescriptorGroup d = group.getDescriptor(); - assertDescriptorEquals("num_row", 3, d.descriptor("num_row")); - assertDescriptorEquals("num_col", 3, d.descriptor("num_col")); - assertDescriptorEquals("elt_0_0", 1.0, d.descriptor("elt_0_0")); - assertDescriptorEquals("elt_2_2", 1.0, d.descriptor("elt_2_2")); + assertDescriptorEquals("num_row", N3, d.descriptor("num_row")); + assertDescriptorEquals("num_col", N3, d.descriptor("num_col")); + assertDescriptorEquals("elt_0_0", N1, d.descriptor("elt_0_0")); + assertDescriptorEquals("elt_0_1", N0, d.descriptor("elt_0_1")); + assertDescriptorEquals("elt_0_2", N0, d.descriptor("elt_0_2")); + assertDescriptorEquals("elt_1_0", N0, d.descriptor("elt_1_0")); + assertDescriptorEquals("elt_1_1", N1, d.descriptor("elt_1_1")); + assertDescriptorEquals("elt_1_2", N0, d.descriptor("elt_1_2")); + assertDescriptorEquals("elt_2_0", N0, d.descriptor("elt_2_0")); + assertDescriptorEquals("elt_2_1", N0, d.descriptor("elt_2_1")); + assertDescriptorEquals("elt_2_2", N1, d.descriptor("elt_2_2")); + /* + * Same test than above, but using the EPSG or pseudo-EPSG names. + */ + assertDescriptorEquals("elt_0_0", N1, d.descriptor("A0")); + assertDescriptorEquals("elt_0_1", N0, d.descriptor("A1")); + assertDescriptorEquals("elt_0_2", N0, d.descriptor("A2")); + assertDescriptorEquals("elt_1_0", N0, d.descriptor("B0")); + assertDescriptorEquals("elt_1_1", N1, d.descriptor("B1")); + assertDescriptorEquals("elt_1_2", N0, d.descriptor("B2")); + assertDescriptorEquals("elt_2_0", N0, d.descriptor("C0")); + assertDescriptorEquals("elt_2_1", N0, d.descriptor("C1")); + assertDescriptorEquals("elt_2_2", N1, d.descriptor("C2")); /* * If we reduce the matrix size, than it shall not be possible * anymore to get the descriptor in the row that we removed. @@ -156,16 +200,29 @@ public final strictfp class TensorValues */ @Test public void testParameter() { + final Double N0 = 0.0; + final Double N1 = 1.0; + final Integer N3 = 3; final ParameterValueGroup group = create(); - assertValueEquals("num_row", 3, group.parameter("num_row")); - assertValueEquals("num_col", 3, group.parameter("num_col")); - assertValueEquals("elt_0_0", 1.0, group.parameter("elt_0_0")); - assertValueEquals("elt_2_2", 1.0, group.parameter("elt_2_2")); - + assertValueEquals("num_row", N3, group.parameter("num_row")); + assertValueEquals("num_col", N3, group.parameter("num_col")); + assertValueEquals("elt_0_0", N1, group.parameter("elt_0_0")); + assertValueEquals("elt_0_1", N0, group.parameter("elt_0_1")); + assertValueEquals("elt_2_2", N1, group.parameter("elt_2_2")); + assertValueEquals("elt_0_0", N1, group.parameter("A0")); + assertValueEquals("elt_0_1", N0, group.parameter("A1")); + assertValueEquals("elt_2_2", N1, group.parameter("C2")); + /* + * Change some values and test again. + */ group.parameter("elt_2_2").setValue(8); group.parameter("elt_0_1").setValue(6); assertValueEquals("elt_2_2", 8.0, group.parameter("elt_2_2")); assertValueEquals("elt_0_1", 6.0, group.parameter("elt_0_1")); + assertValueEquals("elt_0_0", N1, group.parameter("elt_0_0")); + assertValueEquals("elt_2_2", 8.0, group.parameter("C2")); + assertValueEquals("elt_0_1", 6.0, group.parameter("A1")); + assertValueEquals("elt_0_0", N1, group.parameter("A0")); /* * If we reduce the matrix size, than it shall not be possible * anymore to get the descriptor in the row that we removed. @@ -218,7 +275,8 @@ public final strictfp class TensorValues matrix.setElement(0,2, 4); matrix.setElement(1,0, -2); matrix.setElement(2,3, 7); - final ParameterValueGroup group = WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, "Affine"), matrix); + final ParameterValueGroup group = TensorParameters.WKT1 + .createValueGroup(singletonMap(TensorValues.NAME_KEY, "Affine"), matrix); validate(group); assertWktEquals( "ParameterGroup[“Affine”,\n" + @@ -230,6 +288,27 @@ public final strictfp class TensorValues } /** + * Tests WKT formatting using EPSG parameter names. + */ + @Test + public void testWKT2() { + final Matrix matrix = Matrices.createIdentity(3); + matrix.setElement(0,2, 4); + matrix.setElement(1,0, -2); + matrix.setElement(2,1, 7); + final ParameterValueGroup group = TensorParameters.EPSG + .createValueGroup(singletonMap(TensorValues.NAME_KEY, "Affine"), matrix); + validate(group); + assertWktEquals( + "ParameterGroup[“Affine”,\n" + + " Parameter[“num_row”, 3],\n" + + " Parameter[“num_col”, 3],\n" + + " Parameter[“A2”, 4.0],\n" + + " Parameter[“B0”, -2.0],\n" + + " Parameter[“C1”, 7.0]]", group); + } + + /** * Tests serialization. */ @Test
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -60,7 +60,7 @@ public final strictfp class CopyTransfor public void testIdentity() throws TransformException { transform = new CopyTransform(3, 0, 1, 2); validate(); - verifyParameters(Affine.PARAMETERS, null); + verifyParameters(Affine.descriptor(3, 3), null); verifyIsIdentity(true); final double[] source = generateRandomCoordinates(); Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -129,6 +129,8 @@ public strictfp class ProjectiveTransfor assertTrue("The matrix declared by the MathTransform is not equal to the one given at creation time.", Matrices.equals(matrix, tm, tolerance, false)); - assertSame("ParameterDescriptor", Affine.PARAMETERS, ((Parameterized) transform).getParameterDescriptors()); + assertSame("ParameterDescriptor", + Affine.descriptor(transform.getSourceDimensions(), transform.getTargetDimensions()), + ((Parameterized) transform).getParameterDescriptors()); } } Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -16,21 +16,29 @@ */ package org.apache.sis.test; +import java.util.Collection; +import java.util.Set; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.awt.geom.AffineTransform; import javax.measure.unit.Unit; import org.opengis.geometry.Envelope; +import org.opengis.metadata.Identifier; import org.opengis.parameter.GeneralParameterValue; import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterValue; import org.opengis.parameter.ParameterValueGroup; +import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.cs.CoordinateSystemAxis; import org.opengis.referencing.cs.RangeMeaning; +import org.opengis.util.GenericName; import org.apache.sis.geometry.AbstractEnvelope; import org.apache.sis.geometry.GeneralDirectPosition; +import org.apache.sis.internal.referencing.HardCoded; +import org.apache.sis.referencing.IdentifiedObjects; +import org.apache.sis.util.iso.DefaultNameSpace; import static java.lang.StrictMath.*; @@ -41,7 +49,7 @@ import static java.lang.StrictMath.*; * * @author Martin Desruisseaux (Geomatys) * @since 0.3 - * @version 0.4 + * @version 0.6 * @module */ public strictfp class ReferencingAssert extends MetadataAssert { @@ -57,6 +65,40 @@ public strictfp class ReferencingAssert } /** + * Asserts that the string representation of the unique identifier of the given object is equals to the given + * EPSG code. As a special case if the given code is 0, then this method verifies that the given object has no + * identifier. + * + * @param code The expected EPSG code, or {@code 0} if we expect no EPSG code. + * @param object The object for which to test the EPSG code. + */ + public static void assertIdentifierEqualsEPSG(final int code, final IdentifiedObject object) { + final Set<Identifier> identifiers = object.getIdentifiers(); + if (code == 0) { + assertTrue("identifiers.isEmpty()", identifiers.isEmpty()); + } else { + assertEquals("identifier", HardCoded.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code, + IdentifiedObjects.toString(TestUtilities.getSingleton(identifiers))); + } + } + + /** + * Asserts that the tip of the unique alias of the given object is equals to the expected value. + * As a special case if the expected value is null, then this method verifies that the given object has no alias. + * + * @param expected The expected alias, or {@code null} if we expect no alias. + * @param object The object for which to test the alias. + */ + public static void assertAliasTipEquals(final String expected, final IdentifiedObject object) { + final Collection<GenericName> aliases = object.getAlias(); + if (expected == null) { + assertTrue("aliases.isEmpty()", aliases.isEmpty()); + } else { + assertEquals("alias", expected, TestUtilities.getSingleton(aliases).tip().toString()); + } + } + + /** * Compares the given coordinate system axis against the expected values. * * @param name The expected axis name code. Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -75,6 +75,7 @@ import org.junit.BeforeClass; org.apache.sis.parameter.ParameterBuilderTest.class, org.apache.sis.parameter.ParameterFormatTest.class, org.apache.sis.parameter.TensorParametersTest.class, + org.apache.sis.parameter.MatrixParametersTest.class, org.apache.sis.parameter.TensorValuesTest.class, org.apache.sis.referencing.operation.DefaultFormulaTest.class, @@ -82,6 +83,7 @@ import org.junit.BeforeClass; org.apache.sis.referencing.operation.transform.OperationMethodSetTest.class, org.apache.sis.referencing.operation.transform.DefaultMathTransformFactoryTest.class, org.apache.sis.internal.referencing.OperationMethodsTest.class, + org.apache.sis.internal.referencing.provider.AffineTest.class, org.apache.sis.referencing.datum.BursaWolfParametersTest.class, org.apache.sis.referencing.datum.TimeDependentBWPTest.class, Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -45,13 +45,18 @@ import java.util.Objects; * * @author Martin Desruisseaux (Geomatys) * @since 0.3 - * @version 0.5 + * @version 0.6 * @module */ public final class Citations extends Static { /** * The {@value} code space. */ + public static final String OGC = "OGC"; + + /** + * The {@value} code space. + */ public static final String EPSG = "EPSG"; /** Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -50,7 +50,7 @@ import java.util.function.Function; * * @author Martin Desruisseaux (IRD, Geomatys) * @since 0.3 - * @version 0.5 + * @version 0.6 * @module */ public final class CollectionsExt extends Static { @@ -61,6 +61,24 @@ public final class CollectionsExt extend } /** + * Returns the first element of the given iterable, or {@code null} if none. + * This method is null-safe. Note that the first element may be null. + * + * @param <T> The type of elements contained in the iterable. + * @param collection The iterable from which to get the first element, or {@code null}. + * @return The first element, or {@code null} if the given iterable is null or empty. + */ + public static <T> T first(final Iterable<T> collection) { + if (collection != null) { + final Iterator<T> it = collection.iterator(); + if (it != null && it.hasNext()) { // This check for null is paranoiac. + return it.next(); + } + } + return null; + } + + /** * Returns a {@linkplain Queue queue} which is always empty and accepts no element. * * @param <E> The type of elements in the empty collection. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -27,6 +27,7 @@ import org.opengis.util.TypeName; import org.opengis.util.NameSpace; import org.opengis.util.NameFactory; import org.opengis.util.InternationalString; +import org.apache.sis.internal.util.Citations; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.Numbers; @@ -53,17 +54,17 @@ final class TypeNames { private static final Map<String,Class<?>> MAPPING = new LinkedHashMap<>(16); static { final Map<String,Class<?>> m = MAPPING; - m.put("URI", URI.class); - m.put("DateTime", Date.class); - m.put("PT_Locale", Locale.class); - m.put("Boolean", Boolean.class); // Used as a sentinel value for stopping iteration. + m.put("URI", URI.class); + m.put("DateTime", Date.class); + m.put("PT_Locale", Locale.class); + m.put("Boolean", Boolean.class); // Used as a sentinel value for stopping iteration. // Entries below this point are handled in a special way. - m.put("FreeText", InternationalString.class); - m.put("CharacterString", String.class); - m.put("Real", Double.class); - m.put("Decimal", Double.class); - m.put("Integer", Integer.class); + m.put("FreeText", InternationalString.class); + m.put("CharacterString", String.class); + m.put("Real", Double.class); + m.put("Decimal", Double.class); + m.put("Integer", Integer.class); }; /** @@ -80,7 +81,7 @@ final class TypeNames { * Creates a new factory of type names. */ TypeNames(final NameFactory factory) { - ogcNS = factory.createNameSpace(factory.createLocalName(null, "OGC"), null); + ogcNS = factory.createNameSpace(factory.createLocalName(null, Citations.OGC), null); classNS = factory.createNameSpace(factory.createLocalName(null, "class"), null); } @@ -157,7 +158,7 @@ final class TypeNames { */ static Class<?> toClass(final String namespace, final String name) throws ClassNotFoundException { Class<?> c; - if (namespace == null || namespace.equalsIgnoreCase("OGC")) { + if (namespace == null || namespace.equalsIgnoreCase(Citations.OGC)) { c = MAPPING.get(name); if (c == null) { c = Types.forStandardName(name); Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1660664&r1=1660663&r2=1660664&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] Wed Feb 18 16:26:52 2015 @@ -26,7 +26,6 @@ import java.util.Map; import java.util.HashMap; import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; import java.io.IOException; import javax.measure.unit.Unit; import javax.measure.unit.SI; @@ -77,6 +76,7 @@ import ucar.nc2.constants.CF; import static java.util.Collections.singleton; import static org.apache.sis.storage.netcdf.AttributeNames.*; +import static org.apache.sis.internal.util.CollectionsExt.first; /** @@ -257,14 +257,6 @@ final class MetadataReader { } /** - * Returns the first element of the given collection. - */ - private static <T> T first(final Collection<T> collection) { - final Iterator<T> it = collection.iterator(); - return it.hasNext() ? it.next() : null; - } - - /** * Adds the given element in the given collection if the element is not already present in the collection. * We define this method because the metadata API uses collections while the SIS implementation uses lists. * The lists are usually very short (typically 0 or 1 element), so the call to {@link List#contains(Object)}
