parsingdata / metal

A Java library for parsing binary data formats, using declarative descriptions.
Apache License 2.0
18 stars 9 forks source link

#392 RefAny implementation by allowing varargs for the Ref class. #393

Closed mvanaken closed 1 year ago

mvanaken commented 1 year ago

This PR gives Ref a varargument, so multiple values with different names can be selected with a single expression. For more info check issue #392.

The main changes are in Ref.

The following decisions were made:

  1. A copy constructor and method are added to Ref, to allow for an easy shorthands for last(ref()). Else we would either need to convert an immutable list to an array to use the existing constructor with vararg. With the method withLimit it is more clear that the same token is created, but only the limit is different.
  2. There are two Shorthands that are the same. ref(name, limit) vs ref(limit, name, name...). The first is the shorthand that already existed, the second is the vararg variant. To avoid confusion which one to use when, decided to deprecate the first and to let users know to always use the vararg variant. Used the second variant in tests and only used the deprecated variant in ReferenceValueExpressionSemanticsTest for 100% test coverage.
  3. Added an explanatory error message when a mapping of a constructor type is missing in AutoEqualityTest.
  4. Changed RefEdgeCaseTest from JUnit4 to JUnit5.
codecov[bot] commented 1 year ago

Codecov Report

Merging #393 (c642a7d) into master (a5129bf) will not change coverage. The diff coverage is 100.00%.

@@             Coverage Diff             @@
##              master      #393   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity      1120      1127    +7     
===========================================
  Files             97        97           
  Lines           1474      1490   +16     
  Branches         153       154    +1     
===========================================
+ Hits            1474      1490   +16     
Files Changed Coverage Δ
.../src/main/java/io/parsingdata/metal/Shorthand.java 100.00% <100.00%> (ø)
.../java/io/parsingdata/metal/data/ImmutableList.java 100.00% <100.00%> (ø)
.../java/io/parsingdata/metal/data/ImmutablePair.java 100.00% <100.00%> (ø)
...ain/java/io/parsingdata/metal/data/ParseValue.java 100.00% <100.00%> (ø)
...singdata/metal/expression/value/reference/Ref.java 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more