Skip to content

Commit

Permalink
Added Metapath item types for the date, date/time, and markup variant…
Browse files Browse the repository at this point in the history
…s. The removes a warning about multiple types sharing the same item class.
  • Loading branch information
david-waltermire committed Nov 21, 2024
1 parent d90b82f commit 2cec542
Show file tree
Hide file tree
Showing 30 changed files with 721 additions and 389 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* the Metapath item type associated with the adapter
*/
public abstract class AbstractCustomJavaDataTypeAdapter<
TYPE extends ICustomJavaDataType<
TYPE>,
TYPE extends ICustomJavaDataType<TYPE>,
ITEM_TYPE extends IAnyAtomicItem>
extends AbstractDataTypeAdapter<TYPE, ITEM_TYPE> {

Expand All @@ -32,7 +31,7 @@ public abstract class AbstractCustomJavaDataTypeAdapter<
* @param valueClass
* a data type class based on {@link ICustomJavaDataType}
* @param itemClass
* the Java type of the Matepath item this adapter supports
* the Java type of the Metapath item this adapter supports
*/
public AbstractCustomJavaDataTypeAdapter(
@NonNull Class<TYPE> valueClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class AbstractIntegerAdapter<ITEM_TYPE extends IIntegerItem>
* Construct a new integer-based adapter.
*
* @param itemClass
* the Java type of the Matepath item this adapter supports
* the Java type of the Metapath item this adapter supports
*/
protected AbstractIntegerAdapter(
@NonNull Class<ITEM_TYPE> itemClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import gov.nist.secauto.metaschema.core.datatype.AbstractCustomJavaDataTypeAdapter;
import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDate;
import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateWithoutTimeZoneItem;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -33,7 +33,7 @@
* data type.
*/
public class DateAdapter
extends AbstractCustomJavaDataTypeAdapter<AmbiguousDate, IDateItem> {
extends AbstractCustomJavaDataTypeAdapter<AmbiguousDate, IDateWithoutTimeZoneItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date")));
Expand All @@ -48,7 +48,7 @@ public class DateAdapter
+ "(Z|[+-][0-9]{2}:[0-9]{2})?$"));

DateAdapter() {
super(AmbiguousDate.class, IDateItem.class);
super(AmbiguousDate.class, IDateWithoutTimeZoneItem.class);
}

@Override
Expand Down Expand Up @@ -95,8 +95,8 @@ public String asString(Object obj) {
}

@Override
public IDateItem newItem(Object value) {
public IDateWithoutTimeZoneItem newItem(Object value) {
AmbiguousDate item = toValue(value);
return IDateItem.valueOf(item);
return IDateWithoutTimeZoneItem.valueOf(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import gov.nist.secauto.metaschema.core.datatype.AbstractCustomJavaDataTypeAdapter;
import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDateTime;
import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeWithoutTimeZoneItem;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -29,7 +29,7 @@
* data type.
*/
public class DateTimeAdapter
extends AbstractCustomJavaDataTypeAdapter<AmbiguousDateTime, IDateTimeItem> {
extends AbstractCustomJavaDataTypeAdapter<AmbiguousDateTime, IDateTimeWithoutTimeZoneItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
Expand All @@ -38,7 +38,7 @@ public class DateTimeAdapter
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "dateTime")));

DateTimeAdapter() {
super(AmbiguousDateTime.class, IDateTimeItem.class);
super(AmbiguousDateTime.class, IDateTimeWithoutTimeZoneItem.class);
}

@Override
Expand Down Expand Up @@ -92,8 +92,8 @@ public String asString(Object obj) {
}

@Override
public IDateTimeItem newItem(Object value) {
public IDateTimeWithoutTimeZoneItem newItem(Object value) {
AmbiguousDateTime item = toValue(value);
return IDateTimeItem.valueOf(item);
return IDateTimeWithoutTimeZoneItem.valueOf(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import gov.nist.secauto.metaschema.core.datatype.AbstractDataTypeAdapter;
import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeWithTimeZoneItem;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -27,7 +27,7 @@
* data type.
*/
public class DateTimeWithTZAdapter
extends AbstractDataTypeAdapter<ZonedDateTime, IDateTimeItem> {
extends AbstractDataTypeAdapter<ZonedDateTime, IDateTimeWithTimeZoneItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
Expand All @@ -36,7 +36,7 @@ public class DateTimeWithTZAdapter
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "dateTime-with-timezone")));

DateTimeWithTZAdapter() {
super(ZonedDateTime.class, IDateTimeItem.class);
super(ZonedDateTime.class, IDateTimeWithTimeZoneItem.class);
}

@Override
Expand Down Expand Up @@ -80,8 +80,8 @@ public ZonedDateTime copy(Object obj) {
}

@Override
public IDateTimeItem newItem(Object value) {
public IDateTimeWithTimeZoneItem newItem(Object value) {
ZonedDateTime item = toValue(value);
return IDateTimeItem.valueOf(item);
return IDateTimeWithTimeZoneItem.valueOf(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import gov.nist.secauto.metaschema.core.datatype.AbstractDataTypeAdapter;
import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateWithTimeZoneItem;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -29,7 +29,7 @@
* data type.
*/
public class DateWithTZAdapter
extends AbstractDataTypeAdapter<ZonedDateTime, IDateItem> {
extends AbstractDataTypeAdapter<ZonedDateTime, IDateWithTimeZoneItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date-with-timezone")));
Expand All @@ -42,7 +42,7 @@ public class DateWithTZAdapter
+ "(Z|[+-][0-9]{2}:[0-9]{2})$");

DateWithTZAdapter() {
super(ZonedDateTime.class, IDateItem.class);
super(ZonedDateTime.class, IDateWithTimeZoneItem.class);
}

@Override
Expand Down Expand Up @@ -91,8 +91,8 @@ public ZonedDateTime copy(Object obj) {
}

@Override
public IDateItem newItem(Object value) {
public IDateWithTimeZoneItem newItem(Object value) {
ZonedDateTime item = toValue(value);
return IDateItem.valueOf(item);
return IDateWithTimeZoneItem.valueOf(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import gov.nist.secauto.metaschema.core.datatype.AbstractDataTypeProvider;
import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDurationItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIPAddressItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem;
Expand Down Expand Up @@ -198,6 +200,16 @@ public final class MetaschemaDataTypeProvider // NOPMD - Used for service initia
IUntypedAtomicItem.class,
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "untyped-atomic"));
@NonNull
public static final IAtomicOrUnionType DATE_TYPE
= IAtomicOrUnionType.of(
IDateItem.class,
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date"));
@NonNull
public static final IAtomicOrUnionType DATE_TIME_TYPE
= IAtomicOrUnionType.of(
IDateTimeItem.class,
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date"));
@NonNull
public static final IAtomicOrUnionType DURATION_TYPE
= IAtomicOrUnionType.of(
IDurationItem.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@
* "https://pages.nist.gov/metaschema/specification/datatypes/#markup-data-types">markup</a>
* data types.
*/
abstract class AbstractMarkupAdapter<TYPE extends IMarkupString<TYPE>>
extends AbstractCustomJavaDataTypeAdapter<TYPE, IMarkupItem> {
abstract class AbstractMarkupAdapter<
TYPE extends IMarkupString<TYPE>,
ITEM_TYPE extends IMarkupItem>
extends AbstractCustomJavaDataTypeAdapter<TYPE, ITEM_TYPE> {

/**
* Construct a new adapter.
*
* @param valueClass
* the Java value object type this adapter supports
* @param itemClass
* the Java type of the Metapath item this adapter supports
*/
protected AbstractMarkupAdapter(
@NonNull Class<TYPE> valueClass) {
super(valueClass, IMarkupItem.class);
@NonNull Class<TYPE> valueClass,
@NonNull Class<ITEM_TYPE> itemClass) {
super(valueClass, itemClass);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.fasterxml.jackson.core.JsonParser;

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupLineItem;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -29,13 +29,13 @@
* data type.
*/
public class MarkupLineAdapter
extends AbstractMarkupAdapter<MarkupLine> {
extends AbstractMarkupAdapter<MarkupLine, IMarkupLineItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "markup-line")));

MarkupLineAdapter() {
super(MarkupLine.class);
super(MarkupLine.class, IMarkupLineItem.class);
}

@Override
Expand Down Expand Up @@ -76,8 +76,8 @@ public String getDefaultJsonValueKey() {
}

@Override
public IMarkupItem newItem(Object value) {
public IMarkupLineItem newItem(Object value) {
MarkupLine item = toValue(value);
return IMarkupItem.valueOf(item);
return IMarkupLineItem.valueOf(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.fasterxml.jackson.core.JsonParser;

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupMultilineItem;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -29,13 +29,13 @@
* data type.
*/
public class MarkupMultilineAdapter
extends AbstractMarkupAdapter<MarkupMultiline> {
extends AbstractMarkupAdapter<MarkupMultiline, IMarkupMultilineItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "markup-multiline")));

MarkupMultilineAdapter() {
super(MarkupMultiline.class);
super(MarkupMultiline.class, IMarkupMultilineItem.class);
}

@Override
Expand Down Expand Up @@ -86,8 +86,8 @@ public String getDefaultJsonValueKey() {
}

@Override
public IMarkupItem newItem(Object value) {
public IMarkupMultilineItem newItem(Object value) {
MarkupMultiline item = toValue(value);
return IMarkupItem.valueOf(item);
return IMarkupMultilineItem.valueOf(item);
}
}
Loading

0 comments on commit 2cec542

Please sign in to comment.