[MDSAL-743] Add BitsTypeObject Created: 11/Apr/22  Updated: 05/Dec/22  Resolved: 18/Nov/22

Status: Resolved
Project: mdsal
Component/s: Binding codegen, Binding Spec
Affects Version/s: None
Fix Version/s: 11.0.0

Type: Improvement Priority: Medium
Reporter: Robert Varga Assignee: Ivan Martiniak
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
blocks MDSAL-745 Fix bits mapping string/getDefaultIns... In Review
Relates
relates to MDSAL-797 Union's stringValue() does not handle... Resolved
Epic Link: Evolve bits mapping

 Description   

Similar to how we have ScalarTypeObject, we should have a BitsTypeObject. In general this mapping involves a property for each mentioned bit.

The major question is: what useful property (aside 'this is a bits type') can such interface expose.

RFC6020 does not allow any modification to which bits are valid. RFC7950 allows bits to be restricted (e.g. removed), but does not allow extension.

It therefore would be useful to expose a constant in the shape of:

public interface BitsTypeObject extends TypeObject {
   // Valid bit values, ordered by 'position' statement value, hence iteration order is significant
   ImmutableSet<String> validValues(); 
public class MyBits
 implements BitsTypeObject, Serializable {
   // ImmutableSet because of ordering
   public static final Set<String> VALID_BITS = ImmutableSet.of("one", "bar");

   @Override
   public ImmutableSet<String> validValues() {
     return VALID_BITS;
   }
}

Obviously we want to generate these two only for types which are restricted and defer to superclass if they are not.

The other method to be included is this:

   public boolean[] getValue() {
        return new boolean[]{
        _one,
        _bar
        };
   }

Generated at Wed Feb 07 20:10:49 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.