Class FFM.GroupBinderBuilder<T, L extends GroupLayout, M extends GroupBinder<L,T>, SELF extends FFM.GroupBinderBuilder<T,L,M,SELF>>

java.lang.Object
org.lwjgl.system.ffm.FFM.GroupBinderBuilder<T,L,M,SELF>
Direct Known Subclasses:
FFM.StructBinderBuilder, FFM.UnionBinderBuilder
Enclosing class:
FFM

public abstract static sealed class FFM.GroupBinderBuilder<T, L extends GroupLayout, M extends GroupBinder<L,T>, SELF extends FFM.GroupBinderBuilder<T,L,M,SELF>> extends Object permits FFM.StructBinderBuilder<T>, FFM.UnionBinderBuilder<T>
Base class for struct/union binder builders.
See Also:
  • Method Details

    • build

      public M build()
      Generates a class that implements the GroupBinder interface for the group type using the current builder state, then returns a new instance of that class.
      Returns:
      the GroupBinder implementation
    • automaticPadding

      public SELF automaticPadding(boolean enabled)
      Enables automatic padding calculation, based on the natural alignment of the group members.

      This option is enabled by default in new builder instances. It may be disabled for advanced use cases that require fine control of the group alignment.

      Parameters:
      enabled - whether to enable automatic padding
      Returns:
      this builder instance
    • checkPadding

      public SELF checkPadding(boolean enabled)
      Enables validation of the group size with respect to its alignment.

      This option is enabled by default in new builder instances. It may be disabled for advanced use cases that require fine control of the group size and alignment.

      Parameters:
      enabled - whether to enable size validation
      Returns:
      this builder instance
    • pack

      public SELF pack(long alignment)
      Configures the group pack alignment.

      By default there's no packing alignment. This option may be used to configure a pack alignment lesser than than the natural member alignment.

      Parameters:
      alignment - the new pack alignment
      Returns:
      this builder instance
    • alignas

      public SELF alignas(long alignment)
      Configures the group alignment.

      By default the group alignment is the maximum natural alignment of its members. This option may be used to configure an alignment greater than the natural alignment.

      Parameters:
      alignment - the new group alignment. Ignored is less than the natural alignment.
      Returns:
      this builder instance
    • m

      public SELF m(String name, GroupBinder<?,?> binder)
      Adds a nested group member to this group.
      Parameters:
      name - the member name
      binder - the member's binder
      Returns:
      this builder instance
    • m

      public SELF m(String name, MemoryLayout layout)
      Adds a new member to this group.
      Parameters:
      name - the member name
      layout - the member's memory layout
      Returns:
      this builder instance
    • padding

      public SELF padding(long padding)
      Adds padding before the next member of this group.
      Parameters:
      padding - the padding size in bytes
      Returns:
      this builder instance
    • withEquals

      public SELF withEquals(BiPredicate<T,Object> equals)
      Sets a custom Object.equals(Object) implementation for the group.

      By default, an equals method will be generated with the same semantics as Record.equals(Object), where getters take the place of components. This means that the default implementation will not consider padding members or members with no corresponding getters.

      Parameters:
      equals - the equals implementation
      Returns:
      this builder instance
    • withHashCode

      public SELF withHashCode(ToIntFunction<T> hashCode)
      Sets a custom Object.hashCode() implementation for the group.

      By default, a hashCode method will be generated with the same semantics as Record.hashCode(), where getters take the place of components. This means that the default implementation will not consider padding members or members with no corresponding getters.

      Parameters:
      hashCode - the hashCode implementation
      Returns:
      this builder instance
    • withToString

      public SELF withToString(Function<T,String> toString)
      Sets a custom Object.toString() implementation for the group.

      By default, a toString method will be generated with the same semantics as Record.toString(), where getters take the place of components. This means that the default implementation will not consider padding members or members with no corresponding getters.

      Parameters:
      toString - the toString implementation
      Returns:
      this builder instance