Skip to content

Commit c78d936

Browse files
[Validation] determine whether or not to allow empty tags based on a system property passed in to the codec generator
1 parent d465cbb commit c78d936

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

artio-codecs/src/main/java/uk/co/real_logic/artio/dictionary/generation/CodecConfiguration.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public final class CodecConfiguration
5454
public static final String WRAP_EMPTY_BUFFER = "fix.codecs.wrap_empty_buffer";
5555
public static final String PARENT_PACKAGE_PROPERTY = "fix.codecs.parent_package";
5656
public static final String FLYWEIGHTS_ENABLED_PROPERTY = "fix.codecs.flyweight";
57+
public static final String ALLOW_EMPTY_TAGS_PROPERTY = "fix.codecs.allow.empty.fix.tags";
5758
public static final String REJECT_UNKNOWN_ENUM_VALUE_PROPERTY = "reject.unknown.enum.value";
5859
public static final String FIX_TAGS_IN_JAVADOC = "fix.codecs.tags_in_javadoc";
5960

@@ -63,6 +64,7 @@ public final class CodecConfiguration
6364
private String parentPackage = System.getProperty(PARENT_PACKAGE_PROPERTY, DEFAULT_PARENT_PACKAGE);
6465
private boolean flyweightsEnabled = Boolean.getBoolean(FLYWEIGHTS_ENABLED_PROPERTY);
6566
private boolean wrapEmptyBuffer = Boolean.getBoolean(WRAP_EMPTY_BUFFER);
67+
private boolean allowEmptyTags = Boolean.getBoolean(ALLOW_EMPTY_TAGS_PROPERTY);
6668
private boolean fixTagsInJavadoc = Boolean.parseBoolean(System.getProperty(
6769
FIX_TAGS_IN_JAVADOC, DEFAULT_FIX_TAGS_IN_JAVADOC));
6870
private SharedCodecConfiguration sharedCodecConfiguration;
@@ -114,6 +116,12 @@ public CodecConfiguration flyweightsEnabled(final boolean flyweightsEnabled)
114116
return this;
115117
}
116118

119+
public CodecConfiguration allowEmptyTags(final boolean allowEmptyTags)
120+
{
121+
this.allowEmptyTags = allowEmptyTags;
122+
return this;
123+
}
124+
117125
/**
118126
* Suppresses checks for the presence of optional string fields (i.e. no exception is
119127
* thrown when unset, instead the AsciiSequenceView wraps an empty buffer).
@@ -248,6 +256,11 @@ boolean wrapEmptyBuffer()
248256
return wrapEmptyBuffer;
249257
}
250258

259+
boolean allowEmptyTags()
260+
{
261+
return allowEmptyTags;
262+
}
263+
251264
String codecRejectUnknownEnumValueEnabled()
252265
{
253266
return codecRejectUnknownEnumValueEnabled;

artio-codecs/src/main/java/uk/co/real_logic/artio/dictionary/generation/CodecGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static void generate(final CodecConfiguration configuration) throws Excep
4141

4242
final String outputPath = configuration.outputPath();
4343
final String codecRejectUnknownEnumValueEnabled = configuration.codecRejectUnknownEnumValueEnabled();
44+
final String codecRejectEmptyTagsEnabled = configuration.codecRejectUnknownEnumValueEnabled();
4445

4546
final boolean hasSharedCodecs = configuration.sharedCodecConfiguration() != null;
4647
if (hasSharedCodecs)
@@ -182,7 +183,7 @@ private static void generateDictionary(
182183
RejectUnknownEnumValue.class,
183184
false,
184185
configuration.wrapEmptyBuffer(),
185-
false,
186+
configuration.allowEmptyTags(),
186187
codecRejectUnknownEnumValueEnabled,
187188
configuration.fixTagsInJavadoc()).generate();
188189

@@ -205,7 +206,7 @@ private static void generateDictionary(
205206
RejectUnknownEnumValue.class,
206207
true,
207208
configuration.wrapEmptyBuffer(),
208-
false,
209+
configuration.allowEmptyTags(),
209210
codecRejectUnknownEnumValueEnabled,
210211
configuration.fixTagsInJavadoc()).generate();
211212
}

artio-codecs/src/main/java/uk/co/real_logic/artio/dictionary/generation/Generator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public abstract class Generator
5656
public static final String BODY_LENGTH = "BodyLength";
5757

5858
public static final String CODEC_VALIDATION_ENABLED = "CODEC_VALIDATION_ENABLED";
59-
public static final String CODEC_REJECT_EMPTY_TAG_ENABLED = "CODEC_REJECT_EMPTY_TAG_ENABLED";
6059
public static final String CODEC_REJECT_UNKNOWN_FIELD_ENABLED = "CODEC_REJECT_UNKNOWN_FIELD_ENABLED";
6160
public static final String RUNTIME_REJECT_UNKNOWN_ENUM_VALUE_PROPERTY = "CODEC_REJECT_UNKNOWN_ENUM_VALUE_ENABLED";
6261
public static final Pattern NEWLINE = Pattern.compile("^", MULTILINE);

0 commit comments

Comments
 (0)