Class JsFixedBuilder

java.lang.Object
jsonvalues.spec.JsFixedBuilder

public final class JsFixedBuilder extends Object
Builder class for creating instances of JsFixedBinary, which represents a fixed-size binary type. Fixed binary types have a fixed size specified at the time of creation and are used in Avro schemas to represent fixed-size binary data.

Note: This builder is specifically designed for creating Avro schemas. If you are not working with Avro schemas and just need a fixed-size binary specification, consider using JsSpecs.fixedBinary(int).

  • Method Details

    • withName

      public static JsFixedBuilder withName(String name)
      Sets the name of the fixed binary specification. The name must follow the Avro naming conventions, adhering to the regex pattern: [A-Za-z_][A-Za-z0-9_]*.
      Parameters:
      name - The name of the enum.
      Returns:
      A new JsFixedBuilder instance.
      Throws:
      IllegalArgumentException - If the provided name does not follow the specified pattern.
    • withNamespace

      public JsFixedBuilder withNamespace(String nameSpace)
      Sets the namespace of the fixed binary specification. The namespace must follow the Avro naming conventions, adhering to the regex pattern: [A-Za-z_][A-Za-z0-9_.]+. It should start with a letter or an underscore, followed by letters, numbers, underscores, or dots.
      Parameters:
      nameSpace - The namespace of the enum specification.
      Returns:
      A reference to this JsFixedBuilder instance for method chaining.
      Throws:
      IllegalArgumentException - If the provided namespace does not follow the Avro naming conventions.
    • withDoc

      public JsFixedBuilder withDoc(String doc)
      Sets the documentation for the fixed binary.
      Parameters:
      doc - The documentation fixed binary.
      Returns:
      This JsFixedBuilder for method chaining.
    • withAliases

      public JsFixedBuilder withAliases(List<String> aliases)
      Sets aliases for the fixed binary. Must follow the avro naming conventions and, adhering to the regex pattern: [A-Za-z_][A-Za-z0-9_.]+

      Aliases provide alternative names for the fixed binary, and they can be used interchangeably when referring to the same specification.

      Parameters:
      aliases - A list of alternative names (aliases) for the fixed binary.
      Returns:
      This JsFixedBuilder for method chaining.
      Throws:
      IllegalArgumentException - If any of the provided aliases does not follow the naming pattern.
    • build

      public JsSpec build(int size)
      Builds and returns a JsFixedBinary specification with the specified size.
      Parameters:
      size - The size of the fixed binary.
      Returns:
      The constructed JsFixedBinary specification.
      Throws:
      IllegalArgumentException - If the size is less than or equal to 0.