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 374dc41dd60c8c27e24a3e8f1e13fa4521ac6a75 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Oct 29 17:41:45 2023 +0100 Deprecate `DefaultRecordSchema` for removal. --- .../apache/sis/util/iso/DefaultRecordSchema.java | 5 +- .../org/apache/sis/util/iso/DefaultRecordType.java | 57 +++++++++++----------- .../main/org/apache/sis/util/iso/package-info.java | 2 +- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java index d79d09f6d4..014dcaaa27 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java @@ -72,13 +72,16 @@ import org.opengis.feature.AttributeType; * {@link java.io.Serializable} interface) returning a system-wide static constant for their schema. * * @author Martin Desruisseaux (Geomatys) - * @version 1.4 + * @version 1.5 * * @see DefaultRecordType * @see DefaultRecord * * @since 0.5 + * + * @deprecated The {@code RecordSchema} interface has been removed in the 2015 revision of the ISO 19103 standard. */ +@Deprecated(since = "1.5", forRemoval = true) public class DefaultRecordSchema implements RecordSchema { /** * The factory to use for creating names. diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java index 009deac054..0ce1f6f2dc 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java @@ -60,23 +60,6 @@ import org.opengis.util.NameFactory; * The set of fields in a {@code RecordType} can be though as equivalent to the set of fields in a class. * </div> * - * <h2>Instantiation</h2> - * The easiest way to create {@code DefaultRecordType} instances is to use the - * {@link DefaultRecordSchema#createRecordType(CharSequence, Map)} method. - * Example: - * - * {@snippet lang="java" : - * DefaultRecordSchema schema = new DefaultRecordSchema(null, null, "MySchema"); - * // The same instance can be reused for all records to create in that schema. - * - * Map<CharSequence,Class<?>> fields = new LinkedHashMap<>(); - * fields.put("city", String .class); - * fields.put("latitude", Double .class); - * fields.put("longitude", Double .class); - * fields.put("population", Integer.class); - * RecordType record = schema.createRecordType("MyRecordType", fields); - * } - * * <h2>Immutability and thread safety</h2> * This class is immutable and thus inherently thread-safe if the {@link TypeName}, the {@link RecordSchema} * and all ({@link MemberName}, {@link Type}) entries in the map given to the constructor are also immutable. @@ -89,10 +72,9 @@ import org.opengis.util.NameFactory; * so users wanting serialization may need to provide their own schema. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.4 + * @version 1.5 * * @see DefaultRecord - * @see DefaultRecordSchema * @see DefaultMemberName * * @since 0.3 @@ -113,7 +95,7 @@ public class DefaultRecordType extends RecordDefinition implements RecordType, S private final TypeName typeName; /** - * The schema that contains this record type. + * The schema that contains this record type, or {@code null} if none. * * @see #getContainer() */ @@ -139,6 +121,18 @@ public class DefaultRecordType extends RecordDefinition implements RecordType, S fieldTypes = computeTransientFields(other.getFieldTypes()); } + /** + * Creates a new record type. + * + * @param typeName the name that identifies this record type. + * @param fields the name and type of the fields to be included in this record type. + * + * @since 1.5 + */ + public DefaultRecordType(final TypeName typeName, final Map<? extends MemberName, ? extends Type> fields) { + this(typeName, null, fields); + } + /** * Creates a new record in the given schema. * It is caller responsibility to add the new {@code RecordType} in the container @@ -150,17 +144,19 @@ public class DefaultRecordType extends RecordDefinition implements RecordType, S * method provides an easier alternative.</p> * * @param typeName the name that identifies this record type. - * @param container the schema that contains this record type. + * @param container the schema that contains this record type, or {@code null} if none. * @param fields the name and type of the fields to be included in this record type. * * @see DefaultRecordSchema#createRecordType(CharSequence, Map) + * + * @deprecated The {@code RecordSchema} interface has been removed in the 2015 revision of the ISO 19103 standard. */ + @Deprecated(since = "1.5", forRemoval = true) public DefaultRecordType(final TypeName typeName, final RecordSchema container, final Map<? extends MemberName, ? extends Type> fields) { - ArgumentChecks.ensureNonNull("typeName", typeName); - ArgumentChecks.ensureNonNull("container", container); - ArgumentChecks.ensureNonNull("field", fields); + ArgumentChecks.ensureNonNull("typeName", typeName); + ArgumentChecks.ensureNonNull("field", fields); this.typeName = typeName; this.container = container; this.fieldTypes = computeTransientFields(fields); @@ -168,10 +164,12 @@ public class DefaultRecordType extends RecordDefinition implements RecordType, S * Ensure that the record namespace is equal to the schema name. For example if the schema * name is "MyNameSpace", then the record type name can be "MyNameSpace:MyRecordType". */ - final LocalName schemaName = container.getSchemaName(); final GenericName fullTypeName = typeName.toFullyQualifiedName(); - if (schemaName.compareTo(typeName.scope().name().tip()) != 0) { - throw new IllegalArgumentException(Errors.format(Errors.Keys.UnexpectedNamespace_2, schemaName, fullTypeName)); + if (container != null) { + final LocalName schemaName = container.getSchemaName(); + if (schemaName.compareTo(typeName.scope().name().tip()) != 0) { + throw new IllegalArgumentException(Errors.format(Errors.Keys.UnexpectedNamespace_2, schemaName, fullTypeName)); + } } final int size = size(); for (int i=0; i<size; i++) { @@ -195,7 +193,10 @@ public class DefaultRecordType extends RecordDefinition implements RecordType, S * @param container the schema that contains this record type. * @param fields the name of the fields to be included in this record type. * @param nameFactory the factory to use for instantiating {@link MemberName}. + * + * @deprecated To be removed after {@link DefaultRecordSchema} has been removed. */ + @Deprecated(since = "1.5", forRemoval = true) DefaultRecordType(final TypeName typeName, final RecordSchema container, final Map<? extends CharSequence, ? extends Type> fields, final NameFactory nameFactory) { @@ -313,7 +314,7 @@ public class DefaultRecordType extends RecordDefinition implements RecordType, S /** * Returns the schema that contains this record type. * - * @return the schema that contains this record type. + * @return the schema that contains this record type, or {@code null} if none. * * @deprecated The {@code RecordSchema} interface has been removed in the 2015 revision of ISO 19103 standard. */ diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/package-info.java index 25cf8596c9..e4cbeb8adb 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/package-info.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/package-info.java @@ -99,7 +99,7 @@ * </table> * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.4 + * @version 1.5 * @since 0.3 */ @XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GCO, xmlns = {