This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 56effd89cf482e79c1b5dce044766fb2588056b9 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Aug 8 10:48:20 2018 +0200 Update Maven plugins, void deprecated Proxy.getProxyClass method, documentation fixes. --- .../apache/sis/referencing/cs/AxesConvention.java | 7 ++--- .../sis/internal/converter/FractionConverter.java | 14 ++++++++-- .../apache/sis/internal/util/CollectionsExt.java | 2 ++ .../java/org/apache/sis/measure/DerivedScalar.java | 31 ++++++++-------------- .../org/apache/sis/measure/LinearConverter.java | 4 +-- .../java/org/apache/sis/measure/Quantities.java | 1 - .../org/apache/sis/measure/ScalarFallback.java | 26 +++++------------- .../org/apache/sis/util/collection/DerivedMap.java | 21 +++++++++++---- .../org/apache/sis/util/collection/DerivedSet.java | 2 +- pom.xml | 6 +++-- 10 files changed, 57 insertions(+), 57 deletions(-) diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java index 8eafaaf..1862631 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java @@ -268,10 +268,6 @@ public enum AxesConvention implements AxisFilter { * {@linkplain org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis#getMinimumValue() minimum value}) * are unchanged. * - * <p>Note that projecting geometry objects from the old to the new coordinate system may require - * a non-affine conversion. Some geometries may need to be separated in two parts, and others may - * need to be merged.</p> - * * <div class="section">Usage</div> * The most frequent usage of this enum is for shifting longitude values from the [-180 … +180]° range * to the [0 … 360]° range. However this enum could also be used with climatological calendars if their @@ -279,7 +275,8 @@ public enum AxesConvention implements AxisFilter { * * <p>Note that conversions from an coordinate system using the [-180 … +180]° range to a coordinate system * using the [0 … 360]° range may not be affine. For example the data in the West hemisphere ([-180 … 0]°) - * may need to move on the right side of the East hemisphere ([180 … 360]°).</p> + * may need to move on the right side of the East hemisphere ([180 … 360]°). + * Some geometries may need to be separated in two parts, and others may need to be merged.</p> * * @see org.opengis.referencing.cs.RangeMeaning#WRAPAROUND */ diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FractionConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FractionConverter.java index 1161fb0..3af23e9 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FractionConverter.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FractionConverter.java @@ -97,7 +97,7 @@ public final class FractionConverter extends SystemConverter<Fraction,Integer> { } /** - * The inverse of the {@link FractionConverter}. + * The inverse of {@link FractionConverter}. */ public static final class FromInteger extends SystemConverter<Integer,Fraction> { /** @@ -121,6 +121,16 @@ public final class FractionConverter extends SystemConverter<Fraction,Integer> { @Override public ObjectConverter<Integer,Fraction> unique() {return INSTANCE;} @Override public ObjectConverter<Fraction,Integer> inverse() {return FractionConverter.INSTANCE;} @Override public Set<FunctionProperty> properties() {return bijective();} - @Override public Fraction apply(Integer value) {return new Fraction(value, 1);} + + /** + * Creates a new fraction from the given integer. + * + * @param value the integer to convert. + * @return a fraction equals to the given integer. + */ + @Override + public Fraction apply(Integer value) { + return new Fraction(value, 1); + } } } diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java index 492a7cc..7e0ca8e 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java @@ -405,6 +405,8 @@ public final class CollectionsExt extends Static { * @return a unmodifiable version of the given map, or {@code null} if the given map was null. * * @see #compact(Map) + * + * @todo Replace by {@code Map.copyOf(Map)} on JDK10. */ public static <K,V> Map<K,V> unmodifiableOrCopy(Map<K,V> map) { if (map != null) { diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/DerivedScalar.java b/core/sis-utility/src/main/java/org/apache/sis/measure/DerivedScalar.java index 158be45..f4f313c 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/DerivedScalar.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/DerivedScalar.java @@ -21,7 +21,6 @@ import javax.measure.Quantity; import javax.measure.UnitConverter; import java.lang.reflect.Proxy; import java.lang.reflect.Method; -import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import org.apache.sis.util.ArgumentChecks; @@ -199,20 +198,20 @@ abstract class DerivedScalar<Q extends Quantity<Q>> extends Scalar<Q> { @SuppressWarnings("serial") static final class Fallback<Q extends Quantity<Q>> extends DerivedScalar<Q> implements InvocationHandler { /** - * The constructor for new proxy instances. + * The type implemented by proxy instances. * - * @see ScalarFallback#constructor + * @see ScalarFallback#type */ - private final Constructor<? extends Q> constructor; + private final Class<Q> type; /** * Constructor for {@link Quantities} factory only. */ private Fallback(final double value, final Unit<Q> unit, final Unit<Q> systemUnit, - final UnitConverter toSystem, final Constructor<? extends Q> constructor) + final UnitConverter toSystem, final Class<Q> type) { super(value, unit, systemUnit, toSystem); - this.constructor = constructor; + this.type = type; } /** @@ -220,7 +219,7 @@ abstract class DerivedScalar<Q extends Quantity<Q>> extends Scalar<Q> { */ private Fallback(final Fallback<Q> origin, final double value) { super(origin, value); - constructor = origin.constructor; + type = origin.type; } /** @@ -229,13 +228,11 @@ abstract class DerivedScalar<Q extends Quantity<Q>> extends Scalar<Q> { * @see ScalarFallback#create(double, Unit) */ @Override + @SuppressWarnings("unchecked") Quantity<Q> create(final double newValue, final Unit<Q> newUnit) { assert newUnit == getSystemUnit() : newUnit; - try { - return constructor.newInstance(new Fallback<>(this, newValue)); - } catch (ReflectiveOperationException e) { - throw new UnsupportedOperationException(e); // Should never happen. - } + final Fallback<Q> quantity = new Fallback<>(this, newValue); + return (Q) Proxy.newProxyInstance(Scalar.class.getClassLoader(), new Class<?>[] {type}, quantity); } /** @@ -247,14 +244,8 @@ abstract class DerivedScalar<Q extends Quantity<Q>> extends Scalar<Q> { static <Q extends Quantity<Q>> Q factory(final double value, final Unit<Q> unit, final Unit<Q> systemUnit, final UnitConverter toSystem, final Class<Q> type) { - final Class<?> pc = Proxy.getProxyClass(Scalar.class.getClassLoader(), new Class<?>[] {type}); - final Constructor<? extends Q> constructor; - try { - constructor = (Constructor<? extends Q>) pc.getConstructor(InvocationHandler.class); - return constructor.newInstance(new Fallback<>(value, unit, systemUnit, toSystem, constructor)); - } catch (ReflectiveOperationException e) { - throw new UnsupportedOperationException(e); // Should never happen. - } + final Fallback<Q> quantity = new Fallback<>(value, unit, systemUnit, toSystem, type); + return (Q) Proxy.newProxyInstance(Scalar.class.getClassLoader(), new Class<?>[] {type}, quantity); } /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java b/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java index 42fb5b0..e5b6863 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java @@ -105,13 +105,13 @@ final class LinearConverter extends AbstractConverter implements LenientComparab */ static LinearConverter create(final Number scale, final Number offset) { final double numerator, divisor; - double shift = (offset != null) ? offset.doubleValue() : 0; + double shift = (offset != null) ? doubleValue(offset) : 0; if (scale instanceof Fraction) { numerator = ((Fraction) scale).numerator; divisor = ((Fraction) scale).denominator; shift *= divisor; } else { - numerator = (scale != null) ? scale.doubleValue() : 1; + numerator = (scale != null) ? doubleValue(scale) : 1; divisor = 1; } final LinearConverter c = create(numerator, shift, divisor); diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/Quantities.java b/core/sis-utility/src/main/java/org/apache/sis/measure/Quantities.java index e534398..0519d4e 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/Quantities.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/Quantities.java @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.sis.measure; import javax.measure.Unit; diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/ScalarFallback.java b/core/sis-utility/src/main/java/org/apache/sis/measure/ScalarFallback.java index 3e3e236..abf9d3c 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/ScalarFallback.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/ScalarFallback.java @@ -16,7 +16,6 @@ */ package org.apache.sis.measure; -import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -35,17 +34,16 @@ import javax.measure.Unit; @SuppressWarnings("serial") final class ScalarFallback<Q extends Quantity<Q>> extends Scalar<Q> implements InvocationHandler { /** - * The constructor for new proxy instances. Stored for allowing {@link #create(double, Unit)} - * to be implemented more efficiently than invoking {@link Proxy#newProxyInstance}. + * The type implemented by proxy instances. */ - private final Constructor<? extends Q> constructor; + private final Class<Q> type; /** * Creates a new scalar for the given value and unit of measurement. */ - private ScalarFallback(final double value, final Unit<Q> unit, final Constructor<? extends Q> constructor) { + private ScalarFallback(final double value, final Unit<Q> unit, final Class<Q> type) { super(value, unit); - this.constructor = constructor; + this.type = type; } /** @@ -53,11 +51,7 @@ final class ScalarFallback<Q extends Quantity<Q>> extends Scalar<Q> implements I */ @Override Quantity<Q> create(final double newValue, final Unit<Q> newUnit) { - try { - return constructor.newInstance(new ScalarFallback<>(newValue, newUnit, constructor)); - } catch (ReflectiveOperationException e) { - throw new UnsupportedOperationException(e); // Should never happen. - } + return factory(newValue, newUnit, type); } /** @@ -65,14 +59,8 @@ final class ScalarFallback<Q extends Quantity<Q>> extends Scalar<Q> implements I */ @SuppressWarnings("unchecked") static <Q extends Quantity<Q>> Q factory(final double value, final Unit<Q> unit, final Class<Q> type) { - final Class<?> pc = Proxy.getProxyClass(Scalar.class.getClassLoader(), new Class<?>[] {type}); - final Constructor<? extends Q> constructor; - try { - constructor = (Constructor<? extends Q>) pc.getConstructor(InvocationHandler.class); - return constructor.newInstance(new ScalarFallback<>(value, unit, constructor)); - } catch (ReflectiveOperationException e) { - throw new UnsupportedOperationException(e); // Should never happen. - } + final ScalarFallback<Q> quantity = new ScalarFallback<>(value, unit, type); + return (Q) Proxy.newProxyInstance(Scalar.class.getClassLoader(), new Class<?>[] {type}, quantity); } /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java index cdd1cf8..532d73e 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java @@ -302,9 +302,11 @@ class DerivedMap<SK,SV,K,V> extends AbstractMap<K,V> implements /** * Returns a set view of the keys contained in this map. + * + * @return a view of the keys in this map. */ @Override - @SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because immutable. + @SuppressWarnings("ReturnOfCollectionOrArrayField") public final Set<K> keySet() { if (keySet == null) { keySet = DerivedSet.create(storage.keySet(), keyConverter); @@ -314,9 +316,11 @@ class DerivedMap<SK,SV,K,V> extends AbstractMap<K,V> implements /** * Returns a set view of the mappings contained in this map. + * + * @return a view of the entries in this map. */ @Override - @SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because immutable. + @SuppressWarnings("ReturnOfCollectionOrArrayField") public final Set<Map.Entry<K,V>> entrySet() { if (entrySet == null) { entrySet = DerivedSet.create(storage.entrySet(), this); @@ -361,12 +365,19 @@ class DerivedMap<SK,SV,K,V> extends AbstractMap<K,V> implements /** * Converts the given entry. + * + * @param entry an entry with the key and value from the storage. + * @return an entry with the key and value converted to types declared by this map, + * or {@code null} if the key is unconvertible. */ @Override public final Entry<K,V> apply(final Entry<SK,SV> entry) { - final K key = keyConverter.apply(entry.getKey()); - final V value = valueConverter.apply(entry.getValue()); - return (key != null) ? new SimpleEntry<>(key, value) : null; + final K key = keyConverter.apply(entry.getKey()); + if (key != null) { + final V value = valueConverter.apply(entry.getValue()); + return new SimpleImmutableEntry<>(key, value); + } + return null; } /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java index 1512eab..a048157 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java @@ -99,7 +99,7 @@ class DerivedSet<S,E> extends SetOfUnknownSize<E> implements CheckedContainer<E> * Creates a new derived set from the specified storage set. * * @param storage the set which actually store the elements. - * @param converter the type of elements in this derived set. + * @param converter the converter from the storage to the derived type. */ private DerivedSet(final Set<S> storage, final ObjectConverter<S,E> converter) { this.storage = storage; diff --git a/pom.xml b/pom.xml index 2d43438..39e09ac 100644 --- a/pom.xml +++ b/pom.xml @@ -458,7 +458,7 @@ <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> - <version>42.2.2</version> + <version>42.2.4</version> <scope>test</scope> </dependency> @@ -594,6 +594,7 @@ <!-- Compile --> <plugin> <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> <configuration> <source>${maven.compile.source}</source> <target>${maven.compile.target}</target> @@ -611,7 +612,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.21.0</version> + <version>2.22.0</version> <configuration> <includes> <include>**/*TestSuite.java</include> @@ -789,6 +790,7 @@ <!-- JavaDoc configuration. --> <plugin> <artifactId>maven-javadoc-plugin</artifactId> + <version>3.0.1</version> <configuration> <source>${maven.compile.source}</source> <!-- Enables javadoc to handle language constructs present in target JDK. --> <encoding>${project.build.sourceEncoding}</encoding> <!-- Encoding of Java source file. -->