BuilderAttributeDescriptor
Package: com.hypixel.hytale.server.npc.asset.builder
public class BuilderAttributeDescriptorDescribes a single attribute within a BuilderDescriptor. Each attribute has a name, type string, lifecycle state, descriptions, and optional metadata such as requirement level, default value, domain constraints, array length bounds, and a Validator. Uses a fluent API for configuration.
Inner Types
Section titled “Inner Types”RequirementType (enum)
Section titled “RequirementType (enum)”private static enum RequirementType| Constant | Description |
|---|---|
REQUIRED | The attribute must be present. |
OPTIONAL | The attribute may be omitted; a default value applies. |
REQUIRED_IF_NOT_OVERRIDDEN | Required unless a parent builder provides it. |
Constructor
Section titled “Constructor”public BuilderAttributeDescriptor(String name, String type, BuilderDescriptorState state, String shortDescription, String longDescription)Creates an attribute descriptor. Defaults to OPTIONAL requirement, not computable, no default value, no domain, no validator, and no size constraints.
Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
name | String | Attribute name as it appears in JSON. |
type | String | Type description string (e.g., “double”, “string”, “enum”). |
required | RequirementType | Whether the attribute is required. |
computable | boolean | Whether the value can be an expression. |
state | BuilderDescriptorState | Lifecycle state of the attribute. |
shortDescription | String | Brief description of the attribute. |
longDescription | String | Detailed description of the attribute. |
defaultValue | String | String representation of the default value, if any. |
domain | String | Constraint domain string (e.g., enum values). |
minSize / maxSize | int | Array length bounds. -1 means unconstrained. |
validator | Validator | Optional validator for the attribute’s value. |
flagDescriptions | Map<String, String> | Enum flag names mapped to descriptions. |
Fluent Configuration Methods
Section titled “Fluent Configuration Methods”@Nonnullpublic BuilderAttributeDescriptor required()Marks the attribute as required and clears any default value.
@Nonnullpublic BuilderAttributeDescriptor requiredIfNotOverridden()Marks the attribute as required unless overridden by a parent builder.
@Nonnullpublic BuilderAttributeDescriptor optional(String defaultValue)Marks the attribute as optional with the given default value. Overloaded for double[], int[], String[], and boolean[].
@Nonnullpublic BuilderAttributeDescriptor computable()Marks the attribute as supporting expression evaluation.
@Nonnullpublic <E extends Enum<E>> BuilderAttributeDescriptor setBasicEnum(@Nonnull Class<E> clazz)Sets the domain from enum constants. Uses toString() for both name and description.
@Nonnullpublic <E extends Enum<E> & Supplier<String>> BuilderAttributeDescriptor setEnum(@Nonnull Class<E> clazz)Sets the domain from enum constants. Uses toString() for the name and get() for the description.
@Nonnullpublic BuilderAttributeDescriptor domain(String domain)Sets an explicit domain constraint string.
@Nonnullpublic BuilderAttributeDescriptor validator(Validator validator)Attaches a validator to this attribute.
@Nonnullpublic BuilderAttributeDescriptor length(int size)Sets both min and max array length to the given size.
@Nonnullpublic BuilderAttributeDescriptor length(int minSize, int maxSize)Sets the minimum and maximum array length bounds.
Related Types
Section titled “Related Types”- BuilderDescriptor — contains a list of these attribute descriptors
- BuilderDescriptorState — lifecycle state enum
- BuilderBase — uses attribute descriptors during schema generation