StringStringCodec(final StringTypeDefinition typeDef) { super(Optional.of(typeDef), String.class); lengthConstraint = typeDef.getLengthConstraint().orElse(null); }
StringStringCodec(final StringTypeDefinition typeDef) { super(Optional.of(typeDef), String.class); lengthConstraint = typeDef.getLengthConstraint().orElse(null); }
private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull StringTypeDefinition type) { final StringTypeDefinition base = type.getBaseType(); final List<PatternConstraint> patterns = type.getPatternConstraints(); final Optional<LengthConstraint> optLengths = type.getLengthConstraint(); if ((patterns.isEmpty() || patterns.equals(base.getPatternConstraints())) && (!optLengths.isPresent() || optLengths.equals(base.getLengthConstraint()))) { return base; } return type; }
private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull StringTypeDefinition type) { final StringTypeDefinition base = type.getBaseType(); final List<PatternConstraint> patterns = type.getPatternConstraints(); final Optional<LengthConstraint> optLengths = type.getLengthConstraint(); if ((patterns.isEmpty() || patterns.equals(base.getPatternConstraints())) && (!optLengths.isPresent() || optLengths.equals(base.getLengthConstraint()))) { return base; } return type; }
static boolean equals(final @NonNull StringTypeDefinition type, final @Nullable Object obj) { if (type == obj) { return true; } final StringTypeDefinition other = TypeDefinitions.castIfEquals(StringTypeDefinition.class, type, obj); return other != null && type.getLengthConstraint().equals(other.getLengthConstraint()) && type.getPatternConstraints().equals(other.getPatternConstraints()); }
static boolean equals(final @NonNull StringTypeDefinition type, final @Nullable Object obj) { if (type == obj) { return true; } final StringTypeDefinition other = TypeDefinitions.castIfEquals(StringTypeDefinition.class, type, obj); return other != null && type.getLengthConstraint().equals(other.getLengthConstraint()) && type.getPatternConstraints().equals(other.getPatternConstraints()); }
static String toString(final @NonNull StringTypeDefinition type) { return TypeDefinitions.toStringHelper(type).add("length", type.getLengthConstraint().orElse(null)) .add("patterns", type.getPatternConstraints()).toString(); } }
static String toString(final @NonNull StringTypeDefinition type) { return TypeDefinitions.toStringHelper(type).add("length", type.getLengthConstraint().orElse(null)) .add("patterns", type.getPatternConstraints()).toString(); } }
private void emitStringRestrictions(final StringTypeDefinition typeDef) { typeDef.getLengthConstraint().ifPresent(this::emitLength); for (final PatternConstraint pattern : typeDef.getPatternConstraints()) { emitPatternNode(pattern); } }
static int hashCode(final @NonNull StringTypeDefinition type) { return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getLengthConstraint().orElse(null), type.getPatternConstraints()); }
static int hashCode(final @NonNull StringTypeDefinition type) { return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getLengthConstraint().orElse(null), type.getPatternConstraints()); }
final StringTypeDefinition base = string.getBaseType(); if (base != null && base.getBaseType() != null) { length = currentOrEmpty(string.getLengthConstraint(), base.getLengthConstraint()); } else { length = string.getLengthConstraint();
final StringTypeDefinition base = string.getBaseType(); if (base != null && base.getBaseType() != null) { length = currentOrEmpty(string.getLengthConstraint(), base.getLengthConstraint()); } else { length = string.getLengthConstraint();