Class FFM.GroupBinderBuilder<T, L extends GroupLayout, M extends GroupBinder<L,T> , SELF extends FFM.GroupBinderBuilder<T,L,M,SELF> >
- Direct Known Subclasses:
FFM.StructBinderBuilder, FFM.UnionBinderBuilder
- Enclosing class:
FFM
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionalignas(long alignment) Configures the group alignment.automaticPadding(boolean enabled) Enables automatic padding calculation, based on the natural alignment of the group members.build()Generates a class that implements theGroupBinderinterface for the group type using the current builder state, then returns a new instance of that class.checkPadding(boolean enabled) Enables validation of the group size with respect to its alignment.m(String name, MemoryLayout layout) Adds a new member to this group.m(String name, GroupBinder<?, ?> binder) Adds a nested group member to this group.pack(long alignment) Configures the group pack alignment.padding(long padding) Adds padding before the next member of this group.withEquals(BiPredicate<T, Object> equals) Sets a customObject.equals(Object)implementation for the group.withHashCode(ToIntFunction<T> hashCode) Sets a customObject.hashCode()implementation for the group.withToString(Function<T, String> toString) Sets a customObject.toString()implementation for the group.
-
Method Details
-
build
Generates a class that implements theGroupBinderinterface for the group type using the current builder state, then returns a new instance of that class.- Returns:
- the
GroupBinderimplementation
-
automaticPadding
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
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
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
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
Adds a nested group member to this group.- Parameters:
name- the member namebinder- the member's binder- Returns:
- this builder instance
-
m
Adds a new member to this group.- Parameters:
name- the member namelayout- the member's memory layout- Returns:
- this builder instance
-
padding
Adds padding before the next member of this group.- Parameters:
padding- the padding size in bytes- Returns:
- this builder instance
-
withEquals
Sets a customObject.equals(Object)implementation for the group.By default, an
equalsmethod will be generated with the same semantics asRecord.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- theequalsimplementation- Returns:
- this builder instance
-
withHashCode
Sets a customObject.hashCode()implementation for the group.By default, a
hashCodemethod will be generated with the same semantics asRecord.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- thehashCodeimplementation- Returns:
- this builder instance
-
withToString
Sets a customObject.toString()implementation for the group.By default, a
toStringmethod will be generated with the same semantics asRecord.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- thetoStringimplementation- Returns:
- this builder instance
-