[MDSAL-744] Map bits type to primitive boolean Created: 11/Apr/22  Updated: 10/Nov/22  Resolved: 10/Nov/22

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

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

Issue Links:
Blocks
blocks MDSAL-746 Improve BitsTypeObject storage Confirmed
Epic Link: Evolve bits mapping

 Description   

We are currently mapping individual 'bits' components to a Boolean:

public class Foo
 implements TypeObject, Serializable {
    private static final long serialVersionUID = -339486881606097888L;
    private final Boolean _one;
    private final Boolean _bar;

    // ...

    public Boolean getOne() {
        return _one;
    }

    public Boolean getBar() {
        return _bar;
    }

The storage requirements here are an object reference and the implied nullability, exposed to users, just does not make any sense. Fix the code generator to emit simple 'boolean' properties here:

public class Foo
 implements TypeObject, Serializable {
    private static final long serialVersionUID = -339486881606097888L;
    private final boolean _one;
    private final boolean _bar;

    // ...

    public boolean getOne() {
        return _one;
    }

    public boolean getBar() {
        return _bar;
    }

This will drop storage requirements by 4x (32bit/compressed oops JVM) or 8x (64bit JVM).

As part of this change, we also need to simplify the toString() method, so that it just lists those bits which are set and not all lists with their false/true values.


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