Record Class TagType<T>
java.lang.Object
java.lang.Record
net.tangly.core.TagType<T>
- Type Parameters:
T- type of the tags- Record Components:
namespace- namespace of the tags defined through the tag typename- name of the tags defined through the tag typekind- kind of the tag specifying if a value exists and if it is mandatoryclazz- class for the type of values stored in the tagconvert- mapping function between a string to a Java object representation of the string value. if multiple values are supported, the mapping function shall return a list of Java objects.validate- validation function for the Java representation of the string tag value
public record TagType<T>(String namespace, @NotNull String name, @NotNull TagType.ValueKinds kind, @NotNull Class<T> clazz, Function<String,T> convert, BiPredicate<TagType<T>,T> validate)
extends Record
Implements the conceptual type for a set of related tags, all the same class. The tag type also provides support to convert the text format of a tag into a Java object and to
validate acceptable tag values.
A tag should be associated at most once with an entity. If multiple values are needed, the tag value should be a comma separated list of all values. The conversion method shall transform the comma separated string into a list of objects if needed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates if the tag requires no value, an optional value, or a mandatory one. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanclazz()Returns the value of theclazzrecord component.convert()Returns the value of theconvertrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull TagType.ValueKindskind()Returns the value of thekindrecord component.boolean@NotNull Stringname()Returns the value of thenamerecord component.Returns the value of thenamespacerecord component.static <T> TagType<T> of(String namespace, @NotNull String name, @NotNull TagType.ValueKinds kind, @NotNull Class<T> clazz, @NotNull Function<String, T> convert) static <T> TagType<T> of(String namespace, @NotNull String name, @NotNull TagType.ValueKinds kind, Class<T> clazz, Function<String, T> convert, BiPredicate<TagType<T>, T> validate) Creates a tag with the given value using the tag type configuration.static <T> TagType<T> ofMandatory(String namespace, @NotNull String name, Class<T> clazz, @NotNull Function<String, T> convert) static <T> TagType<T> ofMandatory(String namespace, @NotNull String name, Class<T> clazz, Function<String, T> convert, @NotNull BiPredicate<TagType<T>, T> validate) ofMandatoryString(String namespace, @NotNull String name) ofOptionalString(String namespace, @NotNull String name) ofString(String namespace, @NotNull String name, @NotNull TagType.ValueKinds kind) ofString(String namespace, @NotNull String name, @NotNull TagType.ValueKinds kind, @NotNull BiPredicate<TagType<String>, String> validate) ofWithNoValue(String namespace, @NotNull String name) final StringtoString()Returns a string representation of this record class.BiPredicate<TagType<T>, T> validate()Returns the value of thevalidaterecord component.booleanTransforms a tag string value into a Java object.
-
Constructor Details
-
TagType
public TagType(String namespace, @NotNull @NotNull String name, @NotNull @NotNull TagType.ValueKinds kind, @NotNull @NotNull Class<T> clazz, Function<String, T> convert, BiPredicate<TagType<T>, T> validate) Creates an instance of aTagTyperecord class.- Parameters:
namespace- the value for thenamespacerecord componentname- the value for thenamerecord componentkind- the value for thekindrecord componentclazz- the value for theclazzrecord componentconvert- the value for theconvertrecord componentvalidate- the value for thevalidaterecord component
-
-
Method Details
-
ofWithNoValue
-
ofMandatoryString
-
ofOptionalString
-
ofString
public static TagType<String> ofString(String namespace, @NotNull @NotNull String name, @NotNull @NotNull TagType.ValueKinds kind) -
ofString
public static TagType<String> ofString(String namespace, @NotNull @NotNull String name, @NotNull @NotNull TagType.ValueKinds kind, @NotNull @NotNull BiPredicate<TagType<String>, String> validate) -
ofMandatory
-
ofMandatory
-
of
-
of
public static <T> TagType<T> of(String namespace, @NotNull @NotNull String name, @NotNull @NotNull TagType.ValueKinds kind, Class<T> clazz, Function<String, T> convert, BiPredicate<TagType<T>, T> validate) -
canHaveValue
public boolean canHaveValue() -
mustHaveValue
public boolean mustHaveValue() -
value
-
of
-
of
-
validate
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
namespace
-
name
-
kind
-
clazz
-
convert
-
validate
-