diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractCustomJavaDataTypeAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractCustomJavaDataTypeAdapter.java index e2fd9d3d4..fe3983f0f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractCustomJavaDataTypeAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractCustomJavaDataTypeAdapter.java @@ -20,8 +20,7 @@ * the Metapath item type associated with the adapter */ public abstract class AbstractCustomJavaDataTypeAdapter< - TYPE extends ICustomJavaDataType< - TYPE>, + TYPE extends ICustomJavaDataType, ITEM_TYPE extends IAnyAtomicItem> extends AbstractDataTypeAdapter { @@ -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 valueClass, diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/AbstractIntegerAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/AbstractIntegerAdapter.java index 1a12d75ec..f0aa3e78e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/AbstractIntegerAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/AbstractIntegerAdapter.java @@ -31,7 +31,7 @@ public abstract class AbstractIntegerAdapter * 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 itemClass) { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java index ecc6c6639..b2f7467f7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java @@ -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; @@ -33,7 +33,7 @@ * data type. */ public class DateAdapter - extends AbstractCustomJavaDataTypeAdapter { + extends AbstractCustomJavaDataTypeAdapter { @NonNull private static final List NAMES = ObjectUtils.notNull( List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date"))); @@ -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 @@ -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); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java index 7b412217e..007f22b59 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java @@ -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; @@ -29,7 +29,7 @@ * data type. */ public class DateTimeAdapter - extends AbstractCustomJavaDataTypeAdapter { + extends AbstractCustomJavaDataTypeAdapter { @NonNull private static final List NAMES = ObjectUtils.notNull( List.of( @@ -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 @@ -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); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeWithTZAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeWithTZAdapter.java index d34f2b8d1..0355cc3a2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeWithTZAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeWithTZAdapter.java @@ -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; @@ -27,7 +27,7 @@ * data type. */ public class DateTimeWithTZAdapter - extends AbstractDataTypeAdapter { + extends AbstractDataTypeAdapter { @NonNull private static final List NAMES = ObjectUtils.notNull( List.of( @@ -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 @@ -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); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateWithTZAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateWithTZAdapter.java index b1220c994..b81231e06 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateWithTZAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateWithTZAdapter.java @@ -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; @@ -29,7 +29,7 @@ * data type. */ public class DateWithTZAdapter - extends AbstractDataTypeAdapter { + extends AbstractDataTypeAdapter { @NonNull private static final List NAMES = ObjectUtils.notNull( List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date-with-timezone"))); @@ -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 @@ -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); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/MetaschemaDataTypeProvider.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/MetaschemaDataTypeProvider.java index 4554dd79f..227c74364 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/MetaschemaDataTypeProvider.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/MetaschemaDataTypeProvider.java @@ -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; @@ -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, diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/AbstractMarkupAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/AbstractMarkupAdapter.java index 0461d16f0..89c3f3d7a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/AbstractMarkupAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/AbstractMarkupAdapter.java @@ -29,18 +29,23 @@ * "https://pages.nist.gov/metaschema/specification/datatypes/#markup-data-types">markup * data types. */ -abstract class AbstractMarkupAdapter> - extends AbstractCustomJavaDataTypeAdapter { +abstract class AbstractMarkupAdapter< + TYPE extends IMarkupString, + ITEM_TYPE extends IMarkupItem> + extends AbstractCustomJavaDataTypeAdapter { /** * 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 valueClass) { - super(valueClass, IMarkupItem.class); + @NonNull Class valueClass, + @NonNull Class itemClass) { + super(valueClass, itemClass); } @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java index 23ba20892..3556d975a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java @@ -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; @@ -29,13 +29,13 @@ * data type. */ public class MarkupLineAdapter - extends AbstractMarkupAdapter { + extends AbstractMarkupAdapter { @NonNull private static final List NAMES = ObjectUtils.notNull( List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "markup-line"))); MarkupLineAdapter() { - super(MarkupLine.class); + super(MarkupLine.class, IMarkupLineItem.class); } @Override @@ -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); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java index 1e4c0e44c..f3145c657 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java @@ -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; @@ -29,13 +29,13 @@ * data type. */ public class MarkupMultilineAdapter - extends AbstractMarkupAdapter { + extends AbstractMarkupAdapter { @NonNull private static final List NAMES = ObjectUtils.notNull( List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "markup-multiline"))); MarkupMultilineAdapter() { - super(MarkupMultiline.class); + super(MarkupMultiline.class, IMarkupMultilineItem.class); } @Override @@ -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); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java index 03bff5be4..3f9145e98 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java @@ -10,6 +10,8 @@ import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; 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.IDateTimeWithTimeZoneItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateWithTimeZoneItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDurationItem; @@ -82,7 +84,7 @@ private static IDateItem addDurationToDate(@NonNull ZonedDateTime dateTime, @Non throw new ArithmeticFunctionException(ArithmeticFunctionException.OVERFLOW_UNDERFLOW_ERROR, ex); } assert result != null; - return IDateItem.valueOf(result); + return IDateWithTimeZoneItem.valueOf(result); } /** @@ -160,7 +162,7 @@ public static IDateTimeItem opAddYearMonthDurationToDateTime( throw new ArithmeticFunctionException(ArithmeticFunctionException.OVERFLOW_UNDERFLOW_ERROR, ex); } assert result != null; - return IDateTimeItem.valueOf(result); + return IDateTimeWithTimeZoneItem.valueOf(result); } /** @@ -184,7 +186,7 @@ public static IDateTimeItem opAddDayTimeDurationToDateTime( throw new ArithmeticFunctionException(ArithmeticFunctionException.OVERFLOW_UNDERFLOW_ERROR, ex); } assert result != null; - return IDateTimeItem.valueOf(result); + return IDateTimeWithTimeZoneItem.valueOf(result); } /** @@ -240,10 +242,8 @@ public static IDateItem opSubtractDayTimeDurationFromDate( private static IDateItem subtractDurationFromDate( @NonNull ZonedDateTime dateTime, @NonNull TemporalAmount duration) { - @SuppressWarnings("null") - @NonNull - ZonedDateTime result = dateTime.minus(duration); - return IDateItem.valueOf(result); + return IDateWithTimeZoneItem.valueOf( + ObjectUtils.notNull(dateTime.minus(duration))); } /** @@ -263,10 +263,8 @@ public static IYearMonthDurationItem opSubtractYearMonthDurations( Period duration1 = arg1.asPeriod(); Period duration2 = arg2.asPeriod(); - @SuppressWarnings("null") - @NonNull - Period duration = duration1.minus(duration2); - return IYearMonthDurationItem.valueOf(duration); + return IYearMonthDurationItem.valueOf( + ObjectUtils.notNull(duration1.minus(duration2))); } /** @@ -286,10 +284,8 @@ public static IDayTimeDurationItem opSubtractDayTimeDurations( Duration duration1 = arg1.asDuration(); Duration duration2 = arg2.asDuration(); - @SuppressWarnings("null") - @NonNull - Duration duration = duration1.minus(duration2); - return IDayTimeDurationItem.valueOf(duration); + return IDayTimeDurationItem.valueOf( + ObjectUtils.notNull(duration1.minus(duration2))); } /** @@ -319,10 +315,8 @@ public static IDayTimeDurationItem opSubtractDateTimes(@NonNull IDateTimeItem ti */ @NonNull private static IDayTimeDurationItem between(@NonNull ZonedDateTime time1, @NonNull ZonedDateTime time2) { - @SuppressWarnings("null") - @NonNull - Duration between = Duration.between(time1, time2); - return IDayTimeDurationItem.valueOf(between); + return IDayTimeDurationItem.valueOf( + ObjectUtils.notNull(Duration.between(time1, time2))); } /** @@ -339,10 +333,8 @@ private static IDayTimeDurationItem between(@NonNull ZonedDateTime time1, @NonNu public static IDateTimeItem opSubtractYearMonthDurationFromDateTime( @NonNull IDateTimeItem moment, @NonNull IYearMonthDurationItem duration) { - @SuppressWarnings("null") - @NonNull - ZonedDateTime dateTime = moment.asZonedDateTime().minus(duration.asPeriod()); - return IDateTimeItem.valueOf(dateTime); + return IDateTimeWithTimeZoneItem.valueOf( + ObjectUtils.notNull(moment.asZonedDateTime().minus(duration.asPeriod()))); } /** @@ -359,11 +351,8 @@ public static IDateTimeItem opSubtractYearMonthDurationFromDateTime( public static IDateTimeItem opSubtractDayTimeDurationFromDateTime( @NonNull IDateTimeItem moment, @NonNull IDayTimeDurationItem duration) { - - @SuppressWarnings("null") - @NonNull - ZonedDateTime dateTime = moment.asZonedDateTime().plus(duration.asDuration()); - return IDateTimeItem.valueOf(dateTime); + return IDateTimeWithTimeZoneItem.valueOf( + ObjectUtils.notNull(moment.asZonedDateTime().plus(duration.asDuration()))); } /** @@ -388,10 +377,8 @@ public static IYearMonthDurationItem opMultiplyYearMonthDuration( throw new ArithmeticFunctionException(ArithmeticFunctionException.OVERFLOW_UNDERFLOW_ERROR, ex); } - @SuppressWarnings("null") - @NonNull - Period period = arg1.asPeriod().multipliedBy(arg2Int); - return IYearMonthDurationItem.valueOf(period); + return IYearMonthDurationItem.valueOf( + ObjectUtils.notNull(arg1.asPeriod().multipliedBy(arg2Int))); } /** @@ -414,11 +401,8 @@ public static IDayTimeDurationItem opMultiplyDayTimeDuration( } catch (ArithmeticException ex) { throw new ArithmeticFunctionException(ArithmeticFunctionException.OVERFLOW_UNDERFLOW_ERROR, ex); } - - @SuppressWarnings("null") - @NonNull - Duration duration = arg1.asDuration().multipliedBy(arg2Long); - return IDayTimeDurationItem.valueOf(duration); + return IDayTimeDurationItem.valueOf( + ObjectUtils.notNull(arg1.asDuration().multipliedBy(arg2Long))); } /** @@ -464,10 +448,8 @@ public static IDayTimeDurationItem opDivideDayTimeDuration( @NonNull IDayTimeDurationItem arg1, @NonNull INumericItem arg2) { try { - @SuppressWarnings("null") - @NonNull - Duration duration = arg1.asDuration().dividedBy(FunctionUtils.asLong(arg2.round())); - return IDayTimeDurationItem.valueOf(duration); + return IDayTimeDurationItem.valueOf( + ObjectUtils.notNull(arg1.asDuration().dividedBy(FunctionUtils.asLong(arg2.round())))); } catch (ArithmeticException ex) { throw new ArithmeticFunctionException(ArithmeticFunctionException.DIVISION_BY_ZERO, "Division by zero", ex); } @@ -758,20 +740,14 @@ public static INumericItem opNumericAdd(@NonNull INumericItem left, @NonNull INu // create an integer result BigInteger integerLeft = left.asInteger(); BigInteger integerRight = right.asInteger(); - - @SuppressWarnings("null") - @NonNull - BigInteger result = integerLeft.add(integerRight); - retval = IIntegerItem.valueOf(result); + retval = IIntegerItem.valueOf( + ObjectUtils.notNull(integerLeft.add(integerRight))); } else { // create a decimal result BigDecimal decimalLeft = left.asDecimal(); BigDecimal decimalRight = right.asDecimal(); - - @SuppressWarnings("null") - @NonNull - BigDecimal result = decimalLeft.add(decimalRight, FunctionUtils.MATH_CONTEXT); - retval = IDecimalItem.valueOf(result); + retval = IDecimalItem.valueOf( + ObjectUtils.notNull(decimalLeft.add(decimalRight, FunctionUtils.MATH_CONTEXT))); } return retval; } @@ -793,20 +769,14 @@ public static INumericItem opNumericSubtract(@NonNull INumericItem left, @NonNul // create an integer result BigInteger integerLeft = left.asInteger(); BigInteger integerRight = right.asInteger(); - - @SuppressWarnings("null") - @NonNull - BigInteger result = integerLeft.subtract(integerRight); - retval = IIntegerItem.valueOf(result); + retval = IIntegerItem.valueOf( + ObjectUtils.notNull(integerLeft.subtract(integerRight))); } else { // create a decimal result BigDecimal decimalLeft = left.asDecimal(); BigDecimal decimalRight = right.asDecimal(); - - @SuppressWarnings("null") - @NonNull - BigDecimal result = decimalLeft.subtract(decimalRight, FunctionUtils.MATH_CONTEXT); - retval = IDecimalItem.valueOf(result); + retval = IDecimalItem.valueOf( + ObjectUtils.notNull(decimalLeft.subtract(decimalRight, FunctionUtils.MATH_CONTEXT))); } return retval; } @@ -826,19 +796,14 @@ public static INumericItem opNumericMultiply(@NonNull INumericItem left, @NonNul INumericItem retval; if (left instanceof IIntegerItem || right instanceof IIntegerItem) { // create an integer result - @SuppressWarnings("null") - @NonNull - BigInteger result = left.asInteger().multiply(right.asInteger()); - retval = IIntegerItem.valueOf(result); + retval = IIntegerItem.valueOf( + ObjectUtils.notNull(left.asInteger().multiply(right.asInteger()))); } else { // create a decimal result BigDecimal decimalLeft = left.asDecimal(); BigDecimal decimalRight = right.asDecimal(); - - @SuppressWarnings("null") - @NonNull - BigDecimal result = decimalLeft.multiply(decimalRight, FunctionUtils.MATH_CONTEXT); - retval = IDecimalItem.valueOf(result); + retval = IDecimalItem.valueOf( + ObjectUtils.notNull(decimalLeft.multiply(decimalRight, FunctionUtils.MATH_CONTEXT))); } return retval; } @@ -864,11 +829,8 @@ public static IDecimalItem opNumericDivide(@NonNull INumericItem dividend, @NonN } BigDecimal decimalDividend = dividend.asDecimal(); - - @SuppressWarnings("null") - @NonNull - BigDecimal result = decimalDividend.divide(decimalDivisor, FunctionUtils.MATH_CONTEXT); - return IDecimalItem.valueOf(result); + return IDecimalItem.valueOf( + ObjectUtils.notNull(decimalDividend.divide(decimalDivisor, FunctionUtils.MATH_CONTEXT))); } /** @@ -892,11 +854,8 @@ public static IIntegerItem opNumericIntegerDivide(@NonNull INumericItem dividend throw new ArithmeticFunctionException(ArithmeticFunctionException.DIVISION_BY_ZERO, ArithmeticFunctionException.DIVISION_BY_ZERO_MESSAGE); } - - @SuppressWarnings("null") - @NonNull - BigInteger result = dividend.asInteger().divide(integerDivisor); - retval = IIntegerItem.valueOf(result); + retval = IIntegerItem.valueOf( + ObjectUtils.notNull(dividend.asInteger().divide(integerDivisor))); } else { // create a decimal result BigDecimal decimalDivisor = divisor.asDecimal(); @@ -907,12 +866,9 @@ public static IIntegerItem opNumericIntegerDivide(@NonNull INumericItem dividend } BigDecimal decimalDividend = dividend.asDecimal(); - - @SuppressWarnings("null") - @NonNull - BigInteger result - = decimalDividend.divideToIntegralValue(decimalDivisor, FunctionUtils.MATH_CONTEXT).toBigInteger(); - retval = IIntegerItem.valueOf(result); + retval = IIntegerItem.valueOf( + ObjectUtils.notNull(decimalDividend + .divideToIntegralValue(decimalDivisor, FunctionUtils.MATH_CONTEXT).toBigInteger())); } return retval; } @@ -942,10 +898,8 @@ public static INumericItem opNumericMod(@NonNull INumericItem dividend, @NonNull if (BigDecimal.ZERO.equals(decimalDividend)) { retval = dividend; } else { - @SuppressWarnings("null") - @NonNull - BigDecimal result = decimalDividend.remainder(decimalDivisor, FunctionUtils.MATH_CONTEXT); - retval = IDecimalItem.valueOf(result); + retval = IDecimalItem.valueOf( + ObjectUtils.notNull(decimalDividend.remainder(decimalDivisor, FunctionUtils.MATH_CONTEXT))); } return retval; } @@ -964,19 +918,13 @@ public static INumericItem opNumericUnaryMinus(@NonNull INumericItem item) { if (item instanceof IIntegerItem) { // create a decimal result BigInteger integer = item.asInteger(); - - @SuppressWarnings("null") - @NonNull - BigInteger result = integer.negate(); - retval = IIntegerItem.valueOf(result); + retval = IIntegerItem.valueOf( + ObjectUtils.notNull(integer.negate())); } else if (item instanceof IDecimalItem) { // create a decimal result BigDecimal decimal = item.asDecimal(); - - @SuppressWarnings("null") - @NonNull - BigDecimal result = decimal.negate(FunctionUtils.MATH_CONTEXT); - retval = IDecimalItem.valueOf(result); + retval = IDecimalItem.valueOf( + ObjectUtils.notNull(decimal.negate(FunctionUtils.MATH_CONTEXT))); } else { throw new InvalidTypeMetapathException(item); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java index d2504d59e..b6d56525a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java @@ -11,6 +11,7 @@ import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeWithTimeZoneItem; import java.util.List; @@ -57,6 +58,6 @@ private static ISequence execute(@NonNull IFunction function, */ @NonNull public static IDateTimeItem fnCurrentDateTime(@NonNull DynamicContext dynamicContext) { - return IDateTimeItem.valueOf(dynamicContext.getCurrentDateTime()); + return IDateTimeWithTimeZoneItem.valueOf(dynamicContext.getCurrentDateTime()); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateItem.java index b0b29d1df..515e22781 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateItem.java @@ -6,19 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.item.atomic; import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; -import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDate; -import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDateTime; import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateWithTimeZoneItemImpl; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateWithoutTimeZoneItemImpl; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; -import gov.nist.secauto.metaschema.core.util.ObjectUtils; -import java.time.LocalDate; -import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.temporal.ChronoUnit; import edu.umd.cs.findbugs.annotations.NonNull; @@ -26,96 +18,9 @@ * An atomic Metapath item containing a date data value. */ public interface IDateItem extends ITemporalItem { - @NonNull static IAtomicOrUnionType type() { - return MetaschemaDataTypeProvider.DATE.getItemType(); - } - - /** - * Construct a new date item using the provided string {@code value}. - * - * @param value - * a string representing a date - * @return the new item - */ - @NonNull - static IDateItem valueOf(@NonNull String value) { - try { - return valueOf(MetaschemaDataTypeProvider.DATE.parse(value)); - } catch (IllegalArgumentException ex) { - throw new InvalidTypeMetapathException( - null, - String.format("Invalid date value '%s'. %s", - value, - ex.getLocalizedMessage()), - ex); - } - } - - /** - * Construct a new date item using the provided {@code value}. - *

- * This method handles recording that the timezone is implicit. - * - * @param value - * a date, without time zone information - * @return the new item - * @see AmbiguousDateTime for more details on timezone handling - */ - @NonNull - static IDateItem valueOf(@NonNull LocalDate value) { - return valueOf(ObjectUtils.notNull(value.atStartOfDay(ZoneOffset.UTC)), false); - } - - /** - * Construct a new date item using the provided {@code value}. - *

- * This method handles recording if an explicit timezone was provided using the - * {@code hasTimeZone} parameter. The {@link AmbiguousDate#hasTimeZone()} method - * can be called to determine if timezone information is present. - * - * @param value - * a date, without time zone information - * @param hasTimeZone - * {@code true} if the date/time is intended to have an associated time - * zone or {@code false} otherwise - * @return the new item - * @see AmbiguousDateTime for more details on timezone handling - */ - @NonNull - static IDateItem valueOf(@NonNull ZonedDateTime value, boolean hasTimeZone) { - return hasTimeZone - ? valueOf(value) - : valueOf(new AmbiguousDate(value, false)); - } - - /** - * Construct a new date item using the provided {@code value}. - * - * @param value - * an ambiguous date with time zone information already identified - * @return the new item - */ - @NonNull - static IDateItem valueOf(@NonNull AmbiguousDate value) { - return value.hasTimeZone() - ? valueOf(value.getValue()) - : new DateWithoutTimeZoneItemImpl(value); - } - - /** - * Construct a new date item using the provided {@code value}. - * - * @param value - * a date, with time zone information - * @return the new item - */ - @NonNull - static IDateItem valueOf(@NonNull ZonedDateTime value) { - return new DateWithTimeZoneItemImpl( - // ignore time - ObjectUtils.notNull(value.truncatedTo(ChronoUnit.DAYS))); + return MetaschemaDataTypeProvider.DATE_TYPE; } /** @@ -135,10 +40,10 @@ static IDateItem cast(@NonNull IAnyAtomicItem item) { retval = (IDateItem) item; } else if (item instanceof IDateTimeItem) { ZonedDateTime value = ((IDateTimeItem) item).asZonedDateTime(); - retval = valueOf(value); + retval = IDateWithTimeZoneItem.valueOf(value); } else if (item instanceof IStringItem || item instanceof IUntypedAtomicItem) { try { - retval = valueOf(item.asString()); + retval = IDateWithoutTimeZoneItem.valueOf(item.asString()); } catch (IllegalStateException | InvalidTypeMetapathException ex) { // asString can throw IllegalStateException exception throw new InvalidValueForCastFunctionException(ex); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeItem.java index 13b5af857..7af4c05a3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeItem.java @@ -8,13 +8,9 @@ import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDateTime; import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateTimeWithTimeZoneItemImpl; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateTimeWithoutTimeZoneItemImpl; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; -import java.time.ZonedDateTime; - import edu.umd.cs.findbugs.annotations.NonNull; /** @@ -29,85 +25,7 @@ public interface IDateTimeItem extends ITemporalItem { @NonNull static IAtomicOrUnionType type() { - return MetaschemaDataTypeProvider.DATE_TIME.getItemType(); - } - - /** - * Construct a new date/time item using the provided string {@code value}. - * - * @param value - * a string representing a date/time - * @return the new item - */ - @NonNull - static IDateTimeItem valueOf(@NonNull String value) { - try { - return valueOf(MetaschemaDataTypeProvider.DATE_TIME.parse(value)); - } catch (IllegalArgumentException ex) { - throw new InvalidTypeMetapathException( - null, - String.format("Invalid date/time value '%s'. %s", - value, - ex.getLocalizedMessage()), - ex); - } - } - - /** - * Construct a new date/time item using the provided {@code value}. - *

- * This method handles recording if an explicit timezone was provided using the - * {@code hasTimeZone} parameter. The {@link AmbiguousDateTime#hasTimeZone()} - * method can be called to determine if timezone information is present. - * - * @param value - * a date/time, without time zone information - * @param hasTimeZone - * {@code true} if the date/time is intended to have an associated time - * zone or {@code false} otherwise - * @return the new item - * @see AmbiguousDateTime for more details on timezone handling - */ - @NonNull - static IDateTimeItem valueOf(@NonNull ZonedDateTime value, boolean hasTimeZone) { - return hasTimeZone - ? valueOf(value) - : valueOf(new AmbiguousDateTime(value, false)); - } - - /** - * Construct a new date/time item using the provided {@code value}. - *

- * This method handles recording if an explicit timezone was provided using the - * {@link AmbiguousDateTime}. The {@link AmbiguousDateTime#hasTimeZone()} method - * can be called to determine if timezone information is present. - * - * @param value - * a date/time, without time zone information - * @return the new item - * @see AmbiguousDateTime for more details on timezone handling - */ - @NonNull - static IDateTimeItem valueOf(@NonNull AmbiguousDateTime value) { - return value.hasTimeZone() - ? valueOf(value.getValue()) - : new DateTimeWithoutTimeZoneItemImpl(value); - } - - /** - * Construct a new date/time item using the provided {@code value}. - *

- * This method handles dates with explicit timezone information using - * ZonedDateTime. The timezone is preserved as specified in the input and is - * significant for date/time operations and comparisons. - * - * @param value - * a date/time, with time zone information - * @return the new item - */ - @NonNull - static IDateTimeItem valueOf(@NonNull ZonedDateTime value) { - return new DateTimeWithTimeZoneItemImpl(value); + return MetaschemaDataTypeProvider.DATE_TIME_TYPE; } /** @@ -127,7 +45,7 @@ static IDateTimeItem cast(@NonNull IAnyAtomicItem item) { retval = (IDateTimeItem) item; } else { try { - retval = valueOf(item.asString()); + retval = IDateTimeWithoutTimeZoneItem.valueOf(item.asString()); } catch (IllegalStateException | InvalidTypeMetapathException ex) { // asString can throw IllegalStateException exception throw new InvalidValueForCastFunctionException( diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeWithTimeZoneItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeWithTimeZoneItem.java new file mode 100644 index 000000000..ec06bcd1d --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeWithTimeZoneItem.java @@ -0,0 +1,96 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.item.atomic; + +import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; +import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateTimeWithTimeZoneItemImpl; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; + +import java.time.ZonedDateTime; + +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * An atomic Metapath item representing a date/time value in the Metapath system + * with an explicit time zone. + *

+ * This interface provides functionality for handling date/time values with time + * zone information, supporting parsing, casting, and comparison operations. It + * works in conjunction with {@link ZonedDateTime} to eliminate time zone + * ambiguity. + */ +public interface IDateTimeWithTimeZoneItem extends IDateTimeItem { + @NonNull + static IAtomicOrUnionType type() { + return MetaschemaDataTypeProvider.DATE_TIME_WITH_TZ.getItemType(); + } + + /** + * Construct a new date/time item using the provided string {@code value}. + * + * @param value + * a string representing a date/time + * @return the new item + */ + @NonNull + static IDateTimeWithTimeZoneItem valueOf(@NonNull String value) { + try { + return valueOf(MetaschemaDataTypeProvider.DATE_TIME_WITH_TZ.parse(value)); + } catch (IllegalArgumentException ex) { + throw new InvalidTypeMetapathException( + null, + String.format("Invalid date/time value '%s'. %s", + value, + ex.getLocalizedMessage()), + ex); + } + } + + /** + * Construct a new date/time item using the provided {@code value}. + *

+ * This method handles dates with explicit timezone information using + * ZonedDateTime. The timezone is preserved as specified in the input and is + * significant for date/time operations and comparisons. + * + * @param value + * a date/time, with time zone information + * @return the new item + */ + @NonNull + static IDateTimeWithTimeZoneItem valueOf(@NonNull ZonedDateTime value) { + return new DateTimeWithTimeZoneItemImpl(value); + } + + /** + * Cast the provided type to this item type. + * + * @param item + * the item to cast + * @return the original item if it is already this type, otherwise a new item + * cast to this type + * @throws InvalidValueForCastFunctionException + * if the provided {@code item} cannot be cast to this type + */ + @NonNull + static IDateTimeWithTimeZoneItem cast(@NonNull IAnyAtomicItem item) { + try { + return item instanceof IDateTimeWithTimeZoneItem + ? (IDateTimeWithTimeZoneItem) item + : valueOf(item.asString()); + } catch (IllegalStateException | InvalidTypeMetapathException ex) { + // asString can throw IllegalStateException exception + throw new InvalidValueForCastFunctionException(ex); + } + } + + @Override + default IDateTimeWithTimeZoneItem castAsType(IAnyAtomicItem item) { + return cast(item); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeWithoutTimeZoneItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeWithoutTimeZoneItem.java new file mode 100644 index 000000000..72028a879 --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeWithoutTimeZoneItem.java @@ -0,0 +1,120 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.item.atomic; + +import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; +import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDateTime; +import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateTimeWithoutTimeZoneItemImpl; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; + +import java.time.ZonedDateTime; + +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * An atomic Metapath item representing a date/time value in the Metapath system + * with an ambiguous time zone. + *

+ * This interface provides functionality for handling date/time values without + * time zone information, supporting parsing, casting, and comparison + * operations. It works in conjunction with {@link AmbiguousDateTime} to + * properly handle time zone ambiguity. + */ +public interface IDateTimeWithoutTimeZoneItem extends IDateTimeItem { + @NonNull + static IAtomicOrUnionType type() { + return MetaschemaDataTypeProvider.DATE_TIME.getItemType(); + } + + /** + * Construct a new date/time item using the provided string {@code value}. + * + * @param value + * a string representing a date/time + * @return the new item + */ + @NonNull + static IDateTimeWithoutTimeZoneItem valueOf(@NonNull String value) { + try { + return valueOf(MetaschemaDataTypeProvider.DATE_TIME.parse(value)); + } catch (IllegalArgumentException ex) { + throw new InvalidTypeMetapathException( + null, + String.format("Invalid date/time value '%s'. %s", + value, + ex.getLocalizedMessage()), + ex); + } + } + + /** + * Construct a new date/time item using the provided {@code value}. + *

+ * This method handles recording if an explicit timezone was provided using the + * {@code hasTimeZone} parameter. The {@link AmbiguousDateTime#hasTimeZone()} + * method can be called to determine if timezone information is present. + * + * @param value + * a date/time, without time zone information + * @param hasTimeZone + * {@code true} if the date/time is intended to have an associated time + * zone or {@code false} otherwise + * @return the new item + * @see AmbiguousDateTime for more details on timezone handling + */ + @NonNull + static IDateTimeItem valueOf(@NonNull ZonedDateTime value, boolean hasTimeZone) { + return hasTimeZone + ? IDateTimeWithTimeZoneItem.valueOf(value) + : valueOf(new AmbiguousDateTime(value, false)); + } + + /** + * Construct a new date/time item using the provided {@code value}. + *

+ * This method handles recording if an explicit timezone was provided using the + * {@link AmbiguousDateTime}. The {@link AmbiguousDateTime#hasTimeZone()} method + * can be called to determine if timezone information is present. + * + * @param value + * a date/time, without time zone information + * @return the new item + * @see AmbiguousDateTime for more details on timezone handling + */ + @NonNull + static IDateTimeWithoutTimeZoneItem valueOf(@NonNull AmbiguousDateTime value) { + return new DateTimeWithoutTimeZoneItemImpl(value); + } + + /** + * Cast the provided type to this item type. + * + * @param item + * the item to cast + * @return the original item if it is already this type, otherwise a new item + * cast to this type + * @throws InvalidValueForCastFunctionException + * if the provided {@code item} cannot be cast to this type + */ + @NonNull + static IDateTimeWithoutTimeZoneItem cast(@NonNull IAnyAtomicItem item) { + try { + return item instanceof IDateTimeWithoutTimeZoneItem + ? (IDateTimeWithoutTimeZoneItem) item + : valueOf(item.asString()); + } catch (IllegalStateException | InvalidTypeMetapathException ex) { + // asString can throw IllegalStateException exception + throw new InvalidValueForCastFunctionException(ex); + } + } + + @Override + default IDateTimeWithoutTimeZoneItem castAsType(IAnyAtomicItem item) { + return cast(item); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateWithTimeZoneItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateWithTimeZoneItem.java new file mode 100644 index 000000000..1c2a1017c --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateWithTimeZoneItem.java @@ -0,0 +1,92 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.item.atomic; + +import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; +import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateWithTimeZoneItemImpl; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import java.time.ZonedDateTime; +import java.time.temporal.ChronoUnit; + +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * An atomic Metapath item containing a date data value that has an explicit + * timezone. + */ +public interface IDateWithTimeZoneItem extends IDateItem { + + @NonNull + static IAtomicOrUnionType type() { + return MetaschemaDataTypeProvider.DATE_WITH_TZ.getItemType(); + } + + /** + * Construct a new date item using the provided string {@code value}. + * + * @param value + * a string representing a date + * @return the new item + */ + @NonNull + static IDateWithTimeZoneItem valueOf(@NonNull String value) { + try { + return valueOf(MetaschemaDataTypeProvider.DATE_WITH_TZ.parse(value)); + } catch (IllegalArgumentException ex) { + throw new InvalidTypeMetapathException( + null, + String.format("Invalid date value '%s'. %s", + value, + ex.getLocalizedMessage()), + ex); + } + } + + /** + * Construct a new date item using the provided {@code value}. + * + * @param value + * a date, with time zone information + * @return the new item + */ + @NonNull + static IDateWithTimeZoneItem valueOf(@NonNull ZonedDateTime value) { + return new DateWithTimeZoneItemImpl( + // ignore time + ObjectUtils.notNull(value.truncatedTo(ChronoUnit.DAYS))); + } + + /** + * Cast the provided type to this item type. + * + * @param item + * the item to cast + * @return the original item if it is already this type, otherwise a new item + * cast to this type + * @throws InvalidValueForCastFunctionException + * if the provided {@code item} cannot be cast to this type + */ + @NonNull + static IDateWithTimeZoneItem cast(@NonNull IAnyAtomicItem item) { + try { + return item instanceof IDateWithTimeZoneItem + ? (IDateWithTimeZoneItem) item + : valueOf(item.asString()); + } catch (IllegalStateException | InvalidTypeMetapathException ex) { + // asString can throw IllegalStateException exception + throw new InvalidValueForCastFunctionException(ex); + } + } + + @Override + default IDateWithTimeZoneItem castAsType(IAnyAtomicItem item) { + return cast(item); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateWithoutTimeZoneItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateWithoutTimeZoneItem.java new file mode 100644 index 000000000..cb14914ec --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateWithoutTimeZoneItem.java @@ -0,0 +1,130 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.item.atomic; + +import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; +import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDate; +import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDateTime; +import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.DateWithoutTimeZoneItemImpl; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; + +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * An atomic Metapath item containing a date data value that may have an + * ambiguous timezone. + */ +public interface IDateWithoutTimeZoneItem extends IDateItem { + + @NonNull + static IAtomicOrUnionType type() { + return MetaschemaDataTypeProvider.DATE.getItemType(); + } + + /** + * Construct a new date item using the provided string {@code value}. + * + * @param value + * a string representing a date + * @return the new item + */ + @NonNull + static IDateWithoutTimeZoneItem valueOf(@NonNull String value) { + try { + return valueOf(MetaschemaDataTypeProvider.DATE.parse(value)); + } catch (IllegalArgumentException ex) { + throw new InvalidTypeMetapathException( + null, + String.format("Invalid date value '%s'. %s", + value, + ex.getLocalizedMessage()), + ex); + } + } + + /** + * Construct a new date item using the provided {@code value}. + *

+ * This method handles recording if an explicit timezone was provided using the + * {@code hasTimeZone} parameter. The {@link AmbiguousDate#hasTimeZone()} method + * can be called to determine if timezone information is present. + * + * @param value + * a date, without time zone information + * @param hasTimeZone + * {@code true} if the date/time is intended to have an associated time + * zone or {@code false} otherwise + * @return the new item + * @see AmbiguousDateTime for more details on timezone handling + */ + @NonNull + static IDateItem valueOf(@NonNull ZonedDateTime value, boolean hasTimeZone) { + return hasTimeZone + ? IDateWithTimeZoneItem.valueOf(value) + : valueOf(new AmbiguousDate(value, false)); + } + + /** + * Construct a new date item using the provided {@code value}. + *

+ * This method handles recording that the timezone is implicit. + * + * @param value + * a date, without time zone information + * @return the new item + * @see AmbiguousDateTime for more details on timezone handling + */ + @NonNull + static IDateItem valueOf(@NonNull LocalDate value) { + return valueOf(ObjectUtils.notNull(value.atStartOfDay(ZoneOffset.UTC)), false); + } + + /** + * Construct a new date item using the provided {@code value}. + * + * @param value + * an ambiguous date with time zone information already identified + * @return the new item + */ + @NonNull + static IDateWithoutTimeZoneItem valueOf(@NonNull AmbiguousDate value) { + return new DateWithoutTimeZoneItemImpl(value); + } + + /** + * Cast the provided type to this item type. + * + * @param item + * the item to cast + * @return the original item if it is already this type, otherwise a new item + * cast to this type + * @throws InvalidValueForCastFunctionException + * if the provided {@code item} cannot be cast to this type + */ + @NonNull + static IDateWithoutTimeZoneItem cast(@NonNull IAnyAtomicItem item) { + try { + return item instanceof IDateWithoutTimeZoneItem + ? (IDateWithoutTimeZoneItem) item + : valueOf(item.asString()); + } catch (IllegalStateException | InvalidTypeMetapathException ex) { + // asString can throw IllegalStateException exception + throw new InvalidValueForCastFunctionException(ex); + } + } + + @Override + default IDateWithoutTimeZoneItem castAsType(IAnyAtomicItem item) { + return cast(item); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupItem.java index d1dd4cb3c..d43b77b99 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupItem.java @@ -7,11 +7,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.IMarkupString; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupDataTypeProvider; -import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; -import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.MarkupLineItemImpl; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.MarkupMultiLineItemImpl; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; @@ -26,47 +22,6 @@ static IAtomicOrUnionType type() { return MarkupDataTypeProvider.MARKUP_TYPE; } - /** - * Construct a new item using the provided {@code value}. - * - * @param value - * a line of markup - * @return the new item - */ - @SuppressWarnings("PMD.AvoidCatchingGenericException") - @NonNull - static IMarkupItem valueOf(@NonNull String value) { - try { - return valueOf(MarkupDataTypeProvider.MARKUP_LINE.parse(value)); - } catch (IllegalArgumentException ex) { - throw new InvalidValueForCastFunctionException(ex); - } - } - - /** - * Construct a new item using the provided {@code value}. - * - * @param value - * a line of markup - * @return the new item - */ - @NonNull - static IMarkupItem valueOf(@NonNull MarkupLine value) { - return new MarkupLineItemImpl(value); - } - - /** - * Construct a new item using the provided {@code value}. - * - * @param value - * multiple lines of markup - * @return the new item - */ - @NonNull - static IMarkupItem valueOf(@NonNull MarkupMultiline value) { - return new MarkupMultiLineItemImpl(value); - } - /** * Cast the provided type to this item type. * @@ -82,7 +37,7 @@ static IMarkupItem cast(@NonNull IAnyAtomicItem item) { try { return item instanceof IMarkupItem ? (IMarkupItem) item - : valueOf(item.asString()); + : IMarkupMultilineItem.valueOf(item.asString()); } catch (IllegalStateException | InvalidTypeMetapathException ex) { // asString can throw IllegalStateException exception throw new InvalidValueForCastFunctionException(ex); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupLineItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupLineItem.java new file mode 100644 index 000000000..f811d8ada --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupLineItem.java @@ -0,0 +1,78 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.item.atomic; + +import gov.nist.secauto.metaschema.core.datatype.markup.MarkupDataTypeProvider; +import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; +import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.MarkupLineItemImpl; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; + +import edu.umd.cs.findbugs.annotations.NonNull; + +public interface IMarkupLineItem extends IMarkupItem { + @NonNull + static IAtomicOrUnionType type() { + return MarkupDataTypeProvider.MARKUP_LINE.getItemType(); + } + + /** + * Construct a new item using the provided {@code value}. + * + * @param value + * a line of markup + * @return the new item + */ + @SuppressWarnings("PMD.AvoidCatchingGenericException") + @NonNull + static IMarkupLineItem valueOf(@NonNull String value) { + try { + return valueOf(MarkupDataTypeProvider.MARKUP_LINE.parse(value)); + } catch (IllegalArgumentException ex) { + throw new InvalidValueForCastFunctionException(ex); + } + } + + /** + * Construct a new item using the provided {@code value}. + * + * @param value + * a line of markup + * @return the new item + */ + @NonNull + static IMarkupLineItem valueOf(@NonNull MarkupLine value) { + return new MarkupLineItemImpl(value); + } + + /** + * Cast the provided type to this item type. + * + * @param item + * the item to cast + * @return the original item if it is already this type, otherwise a new item + * cast to this type + * @throws InvalidValueForCastFunctionException + * if the provided {@code item} cannot be cast to this type + */ + @NonNull + static IMarkupLineItem cast(@NonNull IAnyAtomicItem item) { + try { + return item instanceof IMarkupLineItem + ? (IMarkupLineItem) item + : valueOf(item.asString()); + } catch (IllegalStateException | InvalidTypeMetapathException ex) { + // asString can throw IllegalStateException exception + throw new InvalidValueForCastFunctionException(ex); + } + } + + @Override + default IMarkupLineItem castAsType(IAnyAtomicItem item) { + return cast(item); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupMultilineItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupMultilineItem.java new file mode 100644 index 000000000..65255b7e0 --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupMultilineItem.java @@ -0,0 +1,78 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.item.atomic; + +import gov.nist.secauto.metaschema.core.datatype.markup.MarkupDataTypeProvider; +import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; +import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.impl.MarkupMultiLineItemImpl; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; + +import edu.umd.cs.findbugs.annotations.NonNull; + +public interface IMarkupMultilineItem extends IMarkupItem { + @NonNull + static IAtomicOrUnionType type() { + return MarkupDataTypeProvider.MARKUP_MULTILINE.getItemType(); + } + + /** + * Construct a new item using the provided {@code value}. + * + * @param value + * a line of markup + * @return the new item + */ + @SuppressWarnings("PMD.AvoidCatchingGenericException") + @NonNull + static IMarkupMultilineItem valueOf(@NonNull String value) { + try { + return valueOf(MarkupDataTypeProvider.MARKUP_MULTILINE.parse(value)); + } catch (IllegalArgumentException ex) { + throw new InvalidValueForCastFunctionException(ex); + } + } + + /** + * Construct a new item using the provided {@code value}. + * + * @param value + * multiple lines of markup + * @return the new item + */ + @NonNull + static IMarkupMultilineItem valueOf(@NonNull MarkupMultiline value) { + return new MarkupMultiLineItemImpl(value); + } + + /** + * Cast the provided type to this item type. + * + * @param item + * the item to cast + * @return the original item if it is already this type, otherwise a new item + * cast to this type + * @throws InvalidValueForCastFunctionException + * if the provided {@code item} cannot be cast to this type + */ + @NonNull + static IMarkupMultilineItem cast(@NonNull IAnyAtomicItem item) { + try { + return item instanceof IMarkupMultilineItem + ? (IMarkupMultilineItem) item + : valueOf(item.asString()); + } catch (IllegalStateException | InvalidTypeMetapathException ex) { + // asString can throw IllegalStateException exception + throw new InvalidValueForCastFunctionException(ex); + } + } + + @Override + default IMarkupMultilineItem castAsType(IAnyAtomicItem item) { + return cast(item); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateItem.java index 839c1b9c7..b4d5a3e8b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateItem.java @@ -5,7 +5,6 @@ package gov.nist.secauto.metaschema.core.metapath.item.atomic.impl; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem; import edu.umd.cs.findbugs.annotations.NonNull; @@ -35,11 +34,6 @@ public boolean hasTimezone() { return true; } - @Override - public IDateItem castAsType(IAnyAtomicItem item) { - return IDateItem.cast(item); - } - @Override public int hashCode() { return asZonedDateTime().hashCode(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateTimeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateTimeItem.java index ea66ba041..a7a327080 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateTimeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateTimeItem.java @@ -5,7 +5,6 @@ package gov.nist.secauto.metaschema.core.metapath.item.atomic.impl; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem; import edu.umd.cs.findbugs.annotations.NonNull; @@ -35,11 +34,6 @@ public boolean hasTimezone() { return true; } - @Override - public IDateTimeItem castAsType(IAnyAtomicItem item) { - return IDateTimeItem.cast(item); - } - @Override public int hashCode() { return asZonedDateTime().hashCode(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithTimeZoneItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithTimeZoneItemImpl.java index af12a8eae..67ffc0e96 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithTimeZoneItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithTimeZoneItemImpl.java @@ -7,6 +7,7 @@ import gov.nist.secauto.metaschema.core.datatype.adapter.DateTimeWithTZAdapter; import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeWithTimeZoneItem; import java.time.ZonedDateTime; @@ -17,7 +18,8 @@ * that has a required timezone. */ public class DateTimeWithTimeZoneItemImpl - extends AbstractDateTimeItem { + extends AbstractDateTimeItem + implements IDateTimeWithTimeZoneItem { /** * Construct a new item with the provided {@code value}. diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithoutTimeZoneItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithoutTimeZoneItemImpl.java index 4885c1e31..46726ce20 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithoutTimeZoneItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithoutTimeZoneItemImpl.java @@ -8,6 +8,7 @@ import gov.nist.secauto.metaschema.core.datatype.adapter.DateTimeAdapter; import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDateTime; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeWithoutTimeZoneItem; import java.time.ZonedDateTime; @@ -22,7 +23,8 @@ * "2024-01-01+05:00". */ public class DateTimeWithoutTimeZoneItemImpl - extends AbstractDateTimeItem { + extends AbstractDateTimeItem + implements IDateTimeWithoutTimeZoneItem { /** * Construct a new item with the provided {@code value}. @@ -43,5 +45,4 @@ public ZonedDateTime asZonedDateTime() { public DateTimeAdapter getJavaTypeAdapter() { return MetaschemaDataTypeProvider.DATE_TIME; } - } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithTimeZoneItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithTimeZoneItemImpl.java index 59de345b8..5185048d3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithTimeZoneItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithTimeZoneItemImpl.java @@ -7,6 +7,7 @@ import gov.nist.secauto.metaschema.core.datatype.adapter.DateWithTZAdapter; import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateWithTimeZoneItem; import java.time.ZonedDateTime; @@ -17,7 +18,8 @@ * has a required timezone. */ public class DateWithTimeZoneItemImpl - extends AbstractDateItem { + extends AbstractDateItem + implements IDateWithTimeZoneItem { /** * Construct a new item with the provided {@code value}. diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithoutTimeZoneItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithoutTimeZoneItemImpl.java index 86f79a4c0..7b8c4e4a8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithoutTimeZoneItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithoutTimeZoneItemImpl.java @@ -8,6 +8,7 @@ import gov.nist.secauto.metaschema.core.datatype.adapter.DateAdapter; import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDate; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateWithoutTimeZoneItem; import java.time.ZonedDateTime; @@ -18,7 +19,8 @@ * may not have an explicit timezone. */ public class DateWithoutTimeZoneItemImpl - extends AbstractDateItem { + extends AbstractDateItem + implements IDateWithoutTimeZoneItem { /** * Construct a new item with the provided {@code value}. @@ -39,5 +41,4 @@ public ZonedDateTime asZonedDateTime() { public DateAdapter getJavaTypeAdapter() { return MetaschemaDataTypeProvider.DATE; } - } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupLineItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupLineItemImpl.java index ef6e1e912..b57f17158 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupLineItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupLineItemImpl.java @@ -9,7 +9,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter; import gov.nist.secauto.metaschema.core.metapath.item.atomic.AbstractUntypedAtomicItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupLineItem; import edu.umd.cs.findbugs.annotations.NonNull; @@ -19,7 +19,7 @@ */ public class MarkupLineItemImpl extends AbstractUntypedAtomicItem - implements IMarkupItem { + implements IMarkupLineItem { /** * Construct a new item with the provided {@code value}. diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupMultiLineItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupMultiLineItemImpl.java index 167d75ab5..3533772fc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupMultiLineItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupMultiLineItemImpl.java @@ -9,7 +9,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter; import gov.nist.secauto.metaschema.core.metapath.item.atomic.AbstractUntypedAtomicItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IMarkupMultilineItem; import edu.umd.cs.findbugs.annotations.NonNull; @@ -19,7 +19,7 @@ */ public class MarkupMultiLineItemImpl extends AbstractUntypedAtomicItem - implements IMarkupItem { + implements IMarkupMultilineItem { /** * Construct a new item with the provided {@code value}. diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/AbstractModuleLoaderStrategy.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/AbstractModuleLoaderStrategy.java index cc7baafae..fb22713a9 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/AbstractModuleLoaderStrategy.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/AbstractModuleLoaderStrategy.java @@ -157,6 +157,7 @@ protected IBindingMatcher registerBindingMatcher(@NonNull IBoundDefinitionModelA // always replace the existing matcher to ensure the last loaded module wins IBindingMatcher old = bindingMatchers.put(qname, retval); if (old != null && !(definition.getContainingModule() instanceof MetaschemaModelModule)) { + // FIXME: find existing causes of this in unit tests LOGGER.atWarn().log("Replacing matcher for QName: {}", qname); }