sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1627164 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/test/suite/ sis-utility/src/main/java/org/apache/sis/intern...
Date Tue, 23 Sep 2014 21:56:04 GMT
Author: desruisseaux
Date: Tue Sep 23 21:56:03 2014
New Revision: 1627164

URL: http://svn.apache.org/r1627164
Log:
Better inferrence of accuracy to use in TemporalExtent and VerticalExtent WKT.

Added:
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
  (with props)
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1627164&r1=1627163&r2=1627164&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -40,6 +40,8 @@ import javax.measure.quantity.Quantity;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.VerticalExtent;
+import org.opengis.metadata.extent.TemporalExtent;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.referencing.IdentifiedObject;
@@ -63,6 +65,7 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.simple.SimpleExtent;
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.MeasurementRange;
@@ -85,8 +88,8 @@ import org.apache.sis.metadata.iso.exten
  * </ul>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @since   0.5 (derived from geotk-2.0)
- * @version 0.4
+ * @since   0.4 (derived from geotk-2.0)
+ * @version 0.5
  * @module
  */
 public class Formatter implements Localized {
@@ -100,7 +103,13 @@ public class Formatter implements Locali
      * Maximal accuracy of vertical extents, in number of fraction digits.
      * The value used here is arbitrary and may change in any future SIS version.
      */
-    private static final int VERTICAL_ACCURACY = 3;
+    private static final int VERTICAL_ACCURACY = 9;
+
+    /**
+     * The time span threshold for switching between the {@code "yyyy-MM-dd'T'HH:mm:ss.SX"}
+     * and {@code "yyyy-MM-dd"} date pattern when formatting a temporal extent.
+     */
+    private static final long TEMPORAL_THRESHOLD = 24 * 60 * 60 * 1000L;
 
     /**
      * The value of {@code X364.FOREGROUND_DEFAULT.sequence()}, hard-coded for avoiding
@@ -725,32 +734,8 @@ public class Formatter implements Locali
         if (area != null) {
             appendOnNewLine("Area", area.getDescription(), ElementKind.EXTENT);
             append(Extents.getGeographicBoundingBox(area), BBOX_ACCURACY);
-            final MeasurementRange<Double> range = Extents.getVerticalRange(area);
-            if (range != null) {
-                openElement(true, "VerticalExtent");
-                setColor(ElementKind.EXTENT);
-                numberFormat.setMinimumFractionDigits(0);
-                numberFormat.setMaximumFractionDigits(VERTICAL_ACCURACY);
-                numberFormat.setRoundingMode(RoundingMode.FLOOR);
-                appendPreset(range.getMinDouble());
-                numberFormat.setRoundingMode(RoundingMode.CEILING);
-                appendPreset(range.getMaxDouble());
-                final Unit<?> unit = range.unit();
-                if (!convention.isSimplified() || !SI.METRE.equals(unit)) {
-                    append(unit); // Unit are optional if they are metres.
-                }
-                resetColor();
-                closeElement(true);
-            }
-            final Range<Date> timeRange = Extents.getTimeRange(area);
-            if (timeRange != null) {
-                openElement(true, "TimeExtent");
-                setColor(ElementKind.EXTENT);
-                append(timeRange.getMinValue());
-                append(timeRange.getMaxValue());
-                resetColor();
-                closeElement(true);
-            }
+            appendVerticalExtent(Extents.getVerticalRange(area));
+            appendTemporalExtent(Extents.getTimeRange(area));
         }
     }
 
@@ -786,6 +771,82 @@ public class Formatter implements Locali
     }
 
     /**
+     * Appends the given vertical extent, if non-null.
+     * This method chooses an accuracy from the vertical span.
+     * Examples:
+     *
+     * <ul>
+     *   <li>“{@code VerticalExtent[102, 108, LengthUnit["m", 1]]}”       (Δz
=   6)</li>
+     *   <li>“{@code VerticalExtent[100.2, 100.8, LengthUnit["m", 1]]}”   (Δz
= 0.6)</li>
+     * </ul>
+     */
+    private void appendVerticalExtent(final MeasurementRange<Double> range) {
+        if (range != null) {
+            final double min = range.getMinDouble();
+            final double max = range.getMaxDouble();
+            int minimumFractionDigits = Math.max(0, DecimalFunctions.fractionDigitsForDelta(max
- min, false));
+            int maximumFractionDigits = minimumFractionDigits + 2; // Arbitrarily allow 2
more digits.
+            if (maximumFractionDigits > VERTICAL_ACCURACY) {
+                maximumFractionDigits = VERTICAL_ACCURACY;
+                minimumFractionDigits = 0;
+            }
+            openElement(true, "VerticalExtent");
+            setColor(ElementKind.EXTENT);
+            numberFormat.setMinimumFractionDigits(minimumFractionDigits);
+            numberFormat.setMaximumFractionDigits(maximumFractionDigits);
+            numberFormat.setRoundingMode(RoundingMode.FLOOR);   appendPreset(min);
+            numberFormat.setRoundingMode(RoundingMode.CEILING); appendPreset(max);
+            final Unit<?> unit = range.unit();
+            if (!convention.isSimplified() || !SI.METRE.equals(unit)) {
+                append(unit); // Unit are optional if they are metres.
+            }
+            resetColor();
+            closeElement(true);
+        }
+    }
+
+    /**
+     * Appends the given temporal extents, if non-null.
+     * This method uses a simplified format if the time span is large enough.
+     * Examples:
+     *
+     * <ul>
+     *   <li>“{@code TemporalExtent[1980-04-12, 1980-04-18]}” (Δt = 6 days)</li>
+     *   <li>“{@code TemporalExtent[1980-04-12T18:00:00.0Z, 1980-04-12T21:00:00.0Z]}”
(Δt = 3 hours)</li>
+     * </ul>
+     */
+    private void appendTemporalExtent(final Range<Date> range) {
+        if (range != null) {
+            final Date min = range.getMinValue();
+            final Date max = range.getMaxValue();
+            if (min != null && max != null) {
+                String pattern = null;
+                if (dateFormat instanceof SimpleDateFormat && (max.getTime() - min.getTime())
>= TEMPORAL_THRESHOLD) {
+                    final String p = ((SimpleDateFormat) dateFormat).toPattern();
+                    if (p.length() > WKTFormat.SHORT_DATE_PATTERN.length() &&
+                        p.startsWith(WKTFormat.SHORT_DATE_PATTERN))
+                    {
+                        pattern = p;
+                        ((SimpleDateFormat) dateFormat).applyPattern(WKTFormat.SHORT_DATE_PATTERN);
+                    }
+                }
+                openElement(true, "TimeExtent");
+                setColor(ElementKind.EXTENT);
+                try {
+                    append(min);
+                    append(max);
+                } finally {
+                    if (pattern != null) {
+                        ((SimpleDateFormat) dateFormat).applyPattern(pattern);
+                    }
+                }
+                resetColor();
+                closeElement(true);
+            }
+        }
+    }
+
+    /**
      * Appends the given math transform, typically (but not necessarily) in a {@code PARAM_MT[…]}
element.
      *
      * @param transform The transform object to append to the WKT, or {@code null} if none.
@@ -1167,11 +1228,17 @@ public class Formatter implements Locali
         } else if (value instanceof IdentifiedObject) {
             append(ReferencingServices.getInstance().toFormattableObject((IdentifiedObject)
value));
         }
-        else if (value instanceof GeographicBoundingBox) append((GeographicBoundingBox) value,
BBOX_ACCURACY);
         else if (value instanceof MathTransform)         append((MathTransform)         value);
         else if (value instanceof Matrix)                append((Matrix)                value);
         else if (value instanceof Unit<?>)               append((Unit<?>)   
           value);
-        else return false;
+        else if (value instanceof GeographicBoundingBox) append((GeographicBoundingBox) value,
BBOX_ACCURACY);
+        else if (value instanceof VerticalExtent) {
+            appendVerticalExtent(Extents.getVerticalRange(new SimpleExtent(null, (VerticalExtent)
value, null)));
+        } else if (value instanceof TemporalExtent) {
+            appendTemporalExtent(Extents.getTimeRange(new SimpleExtent(null, null, (TemporalExtent)
value)));
+        } else {
+            return false;
+        }
         return true;
     }
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1627164&r1=1627163&r2=1627164&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -106,6 +106,15 @@ public class WKTFormat extends CompoundF
     static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SX";
 
     /**
+     * Short version of {@link #DATE_PATTERN}, to be used when formatting temporal extents
+     * if the duration is at least {@link Formatter#TEMPORAL_THRESHOLD}. This pattern must
+     * be a prefix of {@link #DATE_PATTERN}, since we will use that condition for deciding
+     * if this pattern is really shorter (the user could have created his own date format
+     * with a different pattern).
+     */
+    static final String SHORT_DATE_PATTERN = "yyyy-MM-dd";
+
+    /**
      * The symbols to use for this formatter.
      * The same object is also referenced in the {@linkplain #parser} and {@linkplain #formatter}.
      * It appears here for serialization purpose.
@@ -389,9 +398,12 @@ public class WKTFormat extends CompoundF
     /**
      * Formats the specified object as a Well Know Text. The formatter accepts at least the
following types:
      * {@link FormattableObject}, {@link IdentifiedObject},
-     * {@link org.opengis.metadata.extent.GeographicBoundingBox},
      * {@link org.opengis.referencing.operation.MathTransform},
-     * {@link org.opengis.referencing.operation.Matrix} and {@link Unit}.
+     * {@link org.opengis.referencing.operation.Matrix}
+     * {@link org.opengis.metadata.extent.GeographicBoundingBox},
+     * {@link org.opengis.metadata.extent.VerticalExtent},
+     * {@link org.opengis.metadata.extent.TemporalExtent}
+     * and {@link Unit}.
      *
      * @param  object     The object to format.
      * @param  toAppendTo Where the text is to be appended.

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1627164&r1=1627163&r2=1627164&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -23,9 +23,11 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
 import org.apache.sis.measure.Units;
 import org.apache.sis.internal.util.X364;
 import org.apache.sis.test.mock.MatrixMock;
+import org.apache.sis.test.mock.VerticalCRSMock;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -38,7 +40,7 @@ import static org.apache.sis.test.Metada
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.5
  * @module
  */
 @DependsOn({ConventionTest.class, SymbolsTest.class, ColorsTest.class})
@@ -64,6 +66,19 @@ public final strictfp class FormatterTes
     }
 
     /**
+     * Tests (indirectly) formatting of a vertical extent.
+     */
+    @Test
+    public void testAppendVerticalExtent() {
+        final DefaultVerticalExtent extent = new DefaultVerticalExtent(102, 108, VerticalCRSMock.HEIGHT_ft);
+        assertWktEquals(Convention.WKT2, "VerticalExtent[102, 108, LengthUnit[“ft”, 0.3048]]",
extent);
+
+        extent.setMinimumValue(100.2);
+        extent.setMaximumValue(100.8);
+        assertWktEquals(Convention.WKT2, "VerticalExtent[100.2, 100.8, LengthUnit[“ft”,
0.3048]]", extent);
+    }
+
+    /**
      * Tests (indirectly) {@link Formatter#append(Matrix)}.
      */
     @Test

Added: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java?rev=1627164&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
(added)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.io.wkt;
+
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link WKTFormat}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+public final strictfp class WKTFormatTest extends TestCase {
+    /**
+     * Verifies the condition documented in {@link WKTFormat#SHORT_DATE_PATTERN} javadoc.
+     */
+    @Test
+    public void testDatePatterns() {
+        assertTrue(WKTFormat.DATE_PATTERN.startsWith(WKTFormat.SHORT_DATE_PATTERN));
+    }
+}

Propchange: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1627164&r1=1627163&r2=1627164&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -89,7 +89,8 @@ import org.junit.BeforeClass;
     org.apache.sis.io.wkt.ConventionTest.class,
     org.apache.sis.io.wkt.SymbolsTest.class,
     org.apache.sis.io.wkt.ColorsTest.class,
-    org.apache.sis.io.wkt.FormatterTest.class
+    org.apache.sis.io.wkt.FormatterTest.class,
+    org.apache.sis.io.wkt.WKTFormatTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
     /**

Added: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java?rev=1627164&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java
(added)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.simple;
+
+import java.util.Collection;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.GeographicExtent;
+import org.opengis.metadata.extent.TemporalExtent;
+import org.opengis.metadata.extent.VerticalExtent;
+import org.opengis.util.InternationalString;
+
+import static org.apache.sis.internal.util.CollectionsExt.singletonOrEmpty;
+
+
+/**
+ * A trivial implementation of {@link Extent} containing only geographic, vertical and temporal
extent.
+ * This class may be used only as adapter for API expecting the full {@code Extent} object
when only a
+ * component is available.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+public final class SimpleExtent implements Extent {
+    /**
+     * Provides geographic component of the extent of the referring object.
+     */
+    private final GeographicExtent geographicElements;
+
+    /**
+     * Provides vertical component of the extent of the referring object.
+     */
+    private final VerticalExtent verticalElements;
+
+    /**
+     * Provides temporal component of the extent of the referring object.
+     */
+    private final TemporalExtent temporalElements;
+
+    /**
+     * Creates a new extent with the given elements.
+     *
+     * @param geographicElements Geographic components of the extent, or {@code null}.
+     * @param verticalElements   Vertical   components of the extent, or {@code null}.
+     * @param temporalElements   Temporal   components of the extent, or {@code null}.
+     */
+    public SimpleExtent(final GeographicExtent geographicElements,
+                        final VerticalExtent   verticalElements,
+                        final TemporalExtent   temporalElements)
+    {
+        this.geographicElements = geographicElements;
+        this.verticalElements   = verticalElements;
+        this.temporalElements   = temporalElements;
+    }
+
+    @Override public InternationalString          getDescription()        {return null;}
+    @Override public Collection<GeographicExtent> getGeographicElements() {return singletonOrEmpty(geographicElements);}
+    @Override public Collection<VerticalExtent>   getVerticalElements()   {return singletonOrEmpty(verticalElements);}
+    @Override public Collection<TemporalExtent>   getTemporalElements()   {return singletonOrEmpty(temporalElements);}
+}

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

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=1627164&r1=1627163&r2=1627164&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] Tue Sep 23 21:56:03 2014
@@ -76,6 +76,17 @@ public final class CollectionsExt extend
     }
 
     /**
+     * Returns the given value as a singleton if non-null, or returns an empty set otherwise.
+     *
+     * @param  <E> The element type.
+     * @param  element The element to returns in a collection if non-null.
+     * @return A collection containing the given element if non-null, or an empty collection
otherwise.
+     */
+    public static <E> Set<E> singletonOrEmpty(final E element) {
+        return (element != null) ? Collections.singleton(element) : Collections.emptySet();
+    }
+
+    /**
      * Returns the given array if non-empty, or {@code null} if the given array is null or
empty.
      * This method is generally not recommended, since public API should prefer empty array
instead of null.
      * However this method is occasionally useful for managing private fields.

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java?rev=1627164&r1=1627163&r2=1627164&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] Tue Sep 23 21:56:03 2014
@@ -19,7 +19,6 @@ package org.apache.sis.test.mock;
 import java.util.Arrays;
 import java.util.Set;
 import java.util.Collection;
-import java.util.Collections;
 import java.io.Serializable;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -29,6 +28,7 @@ import org.opengis.util.InternationalStr
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.jaxb.gco.GO_GenericName;
 
 
@@ -151,7 +151,7 @@ public strictfp class IdentifiedObjectMo
      */
     @Override
     public final Collection<GenericName> getAlias() {
-        return (alias != null) ? Collections.singleton(alias) : Collections.<GenericName>emptySet();
+        return CollectionsExt.singletonOrEmpty(alias);
     }
 
     /**



Mime
View raw message