Skip to content

Commit

Permalink
fix: include field 'deprecated' in ir encoding and decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
klittlepage committed Feb 3, 2025
1 parent 0da03ae commit 174620a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
32 changes: 31 additions & 1 deletion sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/Encoding.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum Presence
}

private Presence presence;
private final PrimitiveValue deprecated;
private final PrimitiveType primitiveType;
private final ByteOrder byteOrder;
private final PrimitiveValue minValue;
Expand All @@ -62,6 +63,7 @@ public enum Presence
Encoding()
{
presence = Presence.REQUIRED;
deprecated = null;
primitiveType = null;
byteOrder = ByteOrder.LITTLE_ENDIAN;
minValue = null;
Expand All @@ -76,6 +78,7 @@ public enum Presence

Encoding(
final Presence presence,
final PrimitiveValue deprecated,
final PrimitiveType primitiveType,
final ByteOrder byteOrder,
final PrimitiveValue minValue,
Expand All @@ -91,6 +94,7 @@ public enum Presence
Verify.notNull(byteOrder, "byteOrder");

this.primitiveType = primitiveType;
this.deprecated = deprecated;
this.presence = presence;
this.byteOrder = byteOrder;
this.minValue = minValue;
Expand Down Expand Up @@ -183,6 +187,16 @@ public void presence(final Presence presence)
this.presence = presence;
}

/**
* The version at which a field was deprecated.
*
* @return the version at which a field was deprecated.
*/
public PrimitiveValue deprecated()
{
return this.deprecated;
}

/**
* The most applicable null value for the encoded type.
*
Expand Down Expand Up @@ -276,6 +290,7 @@ public String toString()
return
"Encoding{" +
"presence=" + presence +
", deprecated=" + deprecated +
", primitiveType=" + primitiveType +
", byteOrder=" + byteOrder +
", minValue=" + minValue +
Expand All @@ -296,6 +311,7 @@ public static class Builder
{
private PrimitiveType primitiveType = null;
private Presence presence = Presence.REQUIRED;
private PrimitiveValue deprecated = null;
private ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
private PrimitiveValue minValue = null;
private PrimitiveValue maxValue = null;
Expand Down Expand Up @@ -330,6 +346,18 @@ public Builder presence(final Presence presence)
return this;
}

/**
* Deprecated for the Encoding.
*
* @param deprecated for the Encoding.
* @return this for a fluent API.
*/
public Builder deprecated(final PrimitiveValue deprecated)
{
this.deprecated = deprecated;
return this;
}

/**
* ByteOrder for the Encoding.
*
Expand Down Expand Up @@ -446,7 +474,9 @@ public Builder semanticType(final String semanticType)
public Encoding build()
{
return new Encoding(
presence, primitiveType,
presence,
deprecated,
primitiveType,
byteOrder,
minValue,
maxValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ private int encodeToken(final Token token)
.signal(mapSignal(token.signal()))
.primitiveType(mapPrimitiveType(type))
.byteOrder(mapByteOrder(encoding.byteOrder()))
.presence(mapPresence(encoding.presence()));
.presence(mapPresence(encoding.presence()))
.deprecated(token.deprecated());

try
{
Expand Down

0 comments on commit 174620a

Please sign in to comment.