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 6511cd91e3b9d0d01270d41528c5db663c5c0768 Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed Sep 17 00:54:29 2025 +0200 Remove two classes which were not worth to have as separated classes. --- .../sis/referencing/datum/AbstractDatum.java | 27 +++++++- .../org/apache/sis/referencing/datum/SubTypes.java | 74 ---------------------- .../operation/AbstractCoordinateOperation.java | 43 ++++++++++--- .../apache/sis/referencing/operation/SubTypes.java | 74 ---------------------- 4 files changed, 61 insertions(+), 157 deletions(-) diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java index 93fa957ec0..0d0996d795 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java @@ -31,6 +31,10 @@ import org.opengis.util.InternationalString; import org.opengis.metadata.citation.Citation; import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.datum.Datum; +import org.opengis.referencing.datum.GeodeticDatum; +import org.opengis.referencing.datum.VerticalDatum; +import org.opengis.referencing.datum.TemporalDatum; +import org.opengis.referencing.datum.EngineeringDatum; import org.apache.sis.referencing.AbstractIdentifiedObject; import org.apache.sis.referencing.IdentifiedObjects; import org.apache.sis.referencing.privy.WKTKeywords; @@ -260,7 +264,28 @@ public class AbstractDatum extends AbstractIdentifiedObject implements Datum { * given object itself), or {@code null} if the argument was null. */ public static AbstractDatum castOrCopy(final Datum object) { - return SubTypes.castOrCopy(object); + if (object instanceof GeodeticDatum) { + return DefaultGeodeticDatum.castOrCopy((GeodeticDatum) object); + } + if (object instanceof VerticalDatum) { + return DefaultVerticalDatum.castOrCopy((VerticalDatum) object); + } + if (object instanceof TemporalDatum) { + return DefaultTemporalDatum.castOrCopy((TemporalDatum) object); + } + if (object instanceof EngineeringDatum) { + return DefaultEngineeringDatum.castOrCopy((EngineeringDatum) object); + } + /* + * Intentionally check for `AbstractDatum` after the interfaces because users may have defined their own + * subclass implementing the interfaces. If we were checking for `AbstractDatum` before the interfaces, + * the returned instance could have been a user subclass without the JAXB annotations required for XML + * marshalling. + */ + if (object == null || object instanceof AbstractDatum) { + return (AbstractDatum) object; + } + return new AbstractDatum(object); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/SubTypes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/SubTypes.java deleted file mode 100644 index dfb9e3bde8..0000000000 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/SubTypes.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.referencing.datum; - -import org.opengis.referencing.datum.Datum; -import org.opengis.referencing.datum.GeodeticDatum; -import org.opengis.referencing.datum.VerticalDatum; -import org.opengis.referencing.datum.TemporalDatum; -import org.opengis.referencing.datum.EngineeringDatum; - - -/** - * Implementation of {@link AbstractDatum} methods that require knowledge about subclasses. - * Those methods are defined in a separated static class for avoiding class loading of all - * datum implementations before necessary. - * - * <p>This class currently provides implementation for the following methods:</p> - * <ul> - * <li>{@link AbstractDatum#castOrCopy(Datum)}</li> - * </ul> - * - * @author Martin Desruisseaux (Geomatys) - */ -final class SubTypes { - /** - * Do not allow instantiation of this class. - */ - private SubTypes() { - } - - /** - * Returns a SIS implementation for the given datum. - * - * @see AbstractDatum#castOrCopy(Datum) - */ - static AbstractDatum castOrCopy(final Datum object) { - if (object instanceof GeodeticDatum) { - return DefaultGeodeticDatum.castOrCopy((GeodeticDatum) object); - } - if (object instanceof VerticalDatum) { - return DefaultVerticalDatum.castOrCopy((VerticalDatum) object); - } - if (object instanceof TemporalDatum) { - return DefaultTemporalDatum.castOrCopy((TemporalDatum) object); - } - if (object instanceof EngineeringDatum) { - return DefaultEngineeringDatum.castOrCopy((EngineeringDatum) object); - } - /* - * Intentionally check for AbstractDatum after the interfaces because user may have defined his own - * subclass implementing the interface. If we were checking for AbstractDatum before the interfaces, - * the returned instance could have been a user subclass without the JAXB annotations required for - * XML marshalling. - */ - if (object == null || object instanceof AbstractDatum) { - return (AbstractDatum) object; - } - return new AbstractDatum(object); - } -} diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java index d168be5067..831becdfb1 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java @@ -36,6 +36,9 @@ import org.opengis.metadata.quality.PositionalAccuracy; import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.Conversion; +import org.opengis.referencing.operation.Transformation; +import org.opengis.referencing.operation.SingleOperation; import org.opengis.referencing.operation.ConcatenatedOperation; import org.opengis.referencing.operation.CoordinateOperation; import org.opengis.referencing.operation.OperationMethod; @@ -458,7 +461,34 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1 * given object itself), or {@code null} if the argument was null. */ public static AbstractCoordinateOperation castOrCopy(final CoordinateOperation object) { - return SubTypes.castOrCopy(object); + if (object instanceof Transformation) { + return DefaultTransformation.castOrCopy((Transformation) object); + } + if (object instanceof Conversion) { + return DefaultConversion.castOrCopy((Conversion) object); + } + if (object instanceof PassThroughOperation) { + return DefaultPassThroughOperation.castOrCopy((PassThroughOperation) object); + } + if (object instanceof ConcatenatedOperation) { + return DefaultConcatenatedOperation.castOrCopy((ConcatenatedOperation) object); + } + if (object instanceof SingleOperation) { + if (object instanceof AbstractSingleOperation) { + return (AbstractSingleOperation) object; + } + return new AbstractSingleOperation((SingleOperation) object); + } + /* + * Intentionally check for `AbstractCoordinateOperation` after the interfaces because users may have defined + * their own subclass implementing the same interfaces. If we were checking for `AbstractCoordinateOperation` + * before the interfaces, the returned instance could have been a user subclass without the JAXB annotations + * required for XML marshalling. + */ + if (object == null || object instanceof AbstractCoordinateOperation) { + return (AbstractCoordinateOperation) object; + } + return new AbstractCoordinateOperation(object); } /** @@ -474,13 +504,10 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1 } /** - * Returns {@code true} if this coordinate operation is for the definition of a - * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS derived} or - * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS projected CRS}. - * The standard (ISO 19111) approach constructs <i>defining conversion</i> - * as an operation of type {@link org.opengis.referencing.operation.Conversion} - * with null {@linkplain #getSourceCRS() source} and {@linkplain #getTargetCRS() target CRS}. - * But SIS supports also defining conversions with non-null CRS provided that: + * Returns whether this coordinate operation is for the definition of a derived or projected <abbr>CRS</abbr>. + * The <abbr>ISO</abbr> 19111 approach constructs <dfn>defining conversion</dfn> as an operation of type + * {@link Conversion} with null {@linkplain #getSourceCRS() source} and {@linkplain #getTargetCRS() target CRS}. + * But <abbr>SIS</abbr> supports also defining conversions with non-null <abbr>CRS</abbrr> provided that: * * <ul> * <li>{@link DerivedCRS#getBaseCRS()} is the {@linkplain #getSourceCRS() source CRS} of this operation, and</li> diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubTypes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubTypes.java deleted file mode 100644 index d7e8ce8b8b..0000000000 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubTypes.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.referencing.operation; - -import org.opengis.referencing.operation.*; - - -/** - * Implementation of {@link AbstractCoordinateOperation} methods that require knowledge about subclasses. - * Those methods are defined in a separated static class for avoiding class loading of all implementations - * before necessary. - * - * <p>This class currently provides implementation for the following methods:</p> - * <ul> - * <li>{@link AbstractCoordinateOperation#castOrCopy(CoordinateOperation)}</li> - * </ul> - * - * @author Martin Desruisseaux (Geomatys) - */ -final class SubTypes { - /** - * Do not allow instantiation of this class. - */ - private SubTypes() { - } - - /** - * Returns a SIS implementation for the given coordinate operation. - * - * @see AbstractCoordinateOperation#castOrCopy(CoordinateOperation) - */ - static AbstractCoordinateOperation castOrCopy(final CoordinateOperation object) { - if (object instanceof Transformation) { - return DefaultTransformation.castOrCopy((Transformation) object); - } - if (object instanceof Conversion) { - return DefaultConversion.castOrCopy((Conversion) object); - } - if (object instanceof PassThroughOperation) { - return DefaultPassThroughOperation.castOrCopy((PassThroughOperation) object); - } - if (object instanceof ConcatenatedOperation) { - return DefaultConcatenatedOperation.castOrCopy((ConcatenatedOperation) object); - } - if (object instanceof SingleOperation) { - return (object instanceof AbstractSingleOperation) ? (AbstractSingleOperation) object - : new AbstractSingleOperation((SingleOperation) object); - } - /* - * Intentionally check for AbstractCoordinateOperation after the interfaces because user may have defined - * his own subclass implementing the same interface. If we were checking for AbstractCoordinateOperation - * before the interfaces, the returned instance could have been a user subclass without the JAXB annotations - * required for XML marshalling. - */ - if (object == null || object instanceof AbstractCoordinateOperation) { - return (AbstractCoordinateOperation) object; - } - return new AbstractCoordinateOperation(object); - } -}
