Skip to content

Commit

Permalink
More javadocs and some light refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Nov 25, 2024
1 parent d78cc5f commit 6c4fa7d
Show file tree
Hide file tree
Showing 117 changed files with 1,102 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType;
import gov.nist.secauto.metaschema.core.metapath.type.IItemType;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.CustomCollectors;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand All @@ -28,10 +28,9 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;

import javax.xml.namespace.QName;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import nl.talsmasoftware.lazy4j.Lazy;

/**
Expand Down Expand Up @@ -167,10 +166,13 @@ private DataTypeService() {
* @return the data type or {@code null} if the data type is unknown to the type
* system
*/
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "false positive")
@Nullable
public IAtomicOrUnionType<?> getAtomicTypeByQName(@NonNull QName qname) {
IEnhancedQName result = QNameCache.instance().get(qname);
return result == null ? null : getAtomicTypeByQNameIndex(result.getIndexPosition());
public IAtomicOrUnionType<?> getAtomicTypeByQName(@NonNull IEnhancedQName qname) {
return EQNameFactory.instance()
.get(qname.getIndexPosition())
.map(name -> getAtomicTypeByQNameIndex(name.getIndexPosition()))
.orElse(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.IBase64BinaryItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.nio.ByteBuffer;
Expand All @@ -30,9 +30,9 @@ public class Base64Adapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "base64"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "base64"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "base64Binary")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "base64Binary")));

Base64Adapter() {
super(ByteBuffer.class, IBase64BinaryItem.class, IBase64BinaryItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
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.IBooleanItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.io.IOException;
Expand All @@ -31,7 +31,8 @@ public class BooleanAdapter
extends AbstractDataTypeAdapter<Boolean, IBooleanItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "boolean")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "boolean")));

BooleanAdapter() {
super(Boolean.class, IBooleanItem.class, IBooleanItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
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.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.time.LocalDate;
Expand All @@ -36,7 +36,8 @@ public class DateAdapter
extends AbstractCustomJavaDataTypeAdapter<AmbiguousDate, IDateItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "date")));
@NonNull
private static final Pattern DATE_TIMEZONE = ObjectUtils.notNull(
Pattern.compile("^("
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
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.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.time.LocalDateTime;
Expand All @@ -33,9 +33,9 @@ public class DateTimeAdapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date-time"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "date-time"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "dateTime")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "dateTime")));

DateTimeAdapter() {
super(AmbiguousDateTime.class, IDateTimeItem.class, IDateTimeItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.IDateTimeWithTimeZoneItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.time.DateTimeException;
Expand All @@ -31,9 +31,9 @@ public class DateTimeWithTZAdapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date-time-with-timezone"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "date-time-with-timezone"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "dateTime-with-timezone")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "dateTime-with-timezone")));

DateTimeWithTZAdapter() {
super(ZonedDateTime.class, IDateTimeWithTimeZoneItem.class, IDateTimeWithTimeZoneItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.IDateWithTimeZoneItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.time.DateTimeException;
Expand All @@ -32,7 +32,8 @@ public class DateWithTZAdapter
extends AbstractDataTypeAdapter<ZonedDateTime, IDateWithTimeZoneItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "date-with-timezone")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "date-with-timezone")));
private static final Pattern DATE_TIMEZONE = Pattern.compile("^("
+ "^(?:(?:2000|2400|2800|(?:19|2[0-9](?:0[48]|[2468][048]|[13579][26])))-02-29)"
+ "|(?:(?:(?:19|2[0-9])[0-9]{2})-02-(?:0[1-9]|1[0-9]|2[0-8]))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.IDayTimeDurationItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.time.Duration;
Expand All @@ -29,7 +29,8 @@ public class DayTimeAdapter
extends AbstractDataTypeAdapter<Duration, IDayTimeDurationItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "day-time-duration")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "day-time-duration")));

DayTimeAdapter() {
super(Duration.class, IDayTimeDurationItem.class, IDayTimeDurationItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
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.IDecimalItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.io.IOException;
Expand All @@ -32,7 +32,8 @@ public class DecimalAdapter
private static final MathContext MATH_CONTEXT = MathContext.DECIMAL64;
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "decimal")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "decimal")));

DecimalAdapter() {
super(BigDecimal.class, IDecimalItem.class, IDecimalItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IEmailAddressItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.util.List;
Expand All @@ -25,9 +25,9 @@ public class EmailAddressAdapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "email-address"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "email-address"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "email")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "email")));

EmailAddressAdapter() {
super(IEmailAddressItem.class, IEmailAddressItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IHostnameItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.util.List;
Expand All @@ -24,7 +24,8 @@ public class HostnameAdapter
extends AbstractStringAdapter<IHostnameItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "hostname")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "hostname")));

HostnameAdapter() {
super(IHostnameItem.class, IHostnameItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.IIPv4AddressItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.util.List;
Expand All @@ -32,7 +32,8 @@ public class IPv4AddressAdapter
extends AbstractDataTypeAdapter<IPv4Address, IIPv4AddressItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "ip-v4-address")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "ip-v4-address")));
private static final IPAddressStringParameters IP_V_4;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.IIPv6AddressItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.util.List;
Expand All @@ -32,7 +32,8 @@ public class IPv6AddressAdapter
extends AbstractDataTypeAdapter<IPv6Address, IIPv6AddressItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "ip-v6-address")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "ip-v6-address")));
private static final IPAddressStringParameters IP_V_6;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.math.BigInteger;
Expand All @@ -25,7 +25,8 @@ public class IntegerAdapter
extends AbstractIntegerAdapter<IIntegerItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "integer")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "integer")));

IntegerAdapter() {
super(IIntegerItem.class, IIntegerItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.INcNameItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.util.List;
Expand All @@ -27,9 +27,9 @@ public class NcNameAdapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "ncname"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "ncname"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "NCName")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "NCName")));
private static final Pattern NCNAME = Pattern.compile(String.format("^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$"));

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.INonNegativeIntegerItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.math.BigInteger;
Expand All @@ -26,9 +26,9 @@ public class NonNegativeIntegerAdapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "non-negative-integer"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "non-negative-integer"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "nonNegativeInteger")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "nonNegativeInteger")));

NonNegativeIntegerAdapter() {
super(INonNegativeIntegerItem.class, INonNegativeIntegerItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IPositiveIntegerItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.math.BigInteger;
Expand All @@ -26,9 +26,9 @@ public class PositiveIntegerAdapter
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "positive-integer"),
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "positive-integer"),
// for backwards compatibility with original type name
QNameCache.instance().of(MetapathConstants.NS_METAPATH, "positiveInteger")));
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "positiveInteger")));

PositiveIntegerAdapter() {
super(IPositiveIntegerItem.class, IPositiveIntegerItem::cast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import gov.nist.secauto.metaschema.core.metapath.MetapathConstants;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem;
import gov.nist.secauto.metaschema.core.qname.EQNameFactory;
import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
import gov.nist.secauto.metaschema.core.qname.QNameCache;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import java.util.List;
Expand All @@ -24,7 +24,8 @@ public class StringAdapter
extends AbstractStringAdapter<IStringItem> {
@NonNull
private static final List<IEnhancedQName> NAMES = ObjectUtils.notNull(
List.of(QNameCache.instance().of(MetapathConstants.NS_METAPATH, "string")));
List.of(
EQNameFactory.instance().newQName(MetapathConstants.NS_METAPATH, "string")));

StringAdapter() {
super(IStringItem.class, IStringItem::cast);
Expand Down
Loading

0 comments on commit 6c4fa7d

Please sign in to comment.