Skip to content

Commit 9d893a3

Browse files
committed
[Java] Generate only required cases in switches for meta attributes and don't default timeunit and epoch for var data.
1 parent ab9099b commit 9d893a3

File tree

7 files changed

+26
-178
lines changed

7 files changed

+26
-178
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616
package uk.co.real_logic.sbe.generation.java;
1717

18-
import org.agrona.DirectBuffer;
19-
import org.agrona.MutableDirectBuffer;
20-
import org.agrona.Verify;
18+
import org.agrona.*;
2119
import org.agrona.generation.OutputManager;
2220
import uk.co.real_logic.sbe.PrimitiveType;
2321
import uk.co.real_logic.sbe.generation.CodeGenerator;
@@ -2704,10 +2702,22 @@ private static void generateFieldMetaAttributeMethod(final StringBuilder sb, fin
27042702
.append(propertyName).append("MetaAttribute(final MetaAttribute metaAttribute)\n")
27052703
.append(indent).append(" {\n")
27062704
.append(indent).append(" switch (metaAttribute)\n")
2707-
.append(indent).append(" {\n")
2708-
.append(indent).append(" case EPOCH: return \"").append(epoch).append("\";\n")
2709-
.append(indent).append(" case TIME_UNIT: return \"").append(timeUnit).append("\";\n")
2710-
.append(indent).append(" case SEMANTIC_TYPE: return \"").append(semanticType).append("\";\n")
2705+
.append(indent).append(" {\n");
2706+
2707+
if (!Strings.isEmpty(epoch))
2708+
{
2709+
sb.append(indent).append(" case EPOCH: return \"").append(epoch).append("\";\n");
2710+
}
2711+
if (!Strings.isEmpty(timeUnit))
2712+
{
2713+
sb.append(indent).append(" case TIME_UNIT: return \"").append(timeUnit).append("\";\n");
2714+
}
2715+
if (!Strings.isEmpty(semanticType))
2716+
{
2717+
sb.append(indent).append(" case SEMANTIC_TYPE: return \"").append(semanticType).append("\";\n");
2718+
}
2719+
2720+
sb
27112721
.append(indent).append(" case PRESENCE: return \"").append(presence).append("\";\n")
27122722
.append(indent).append(" }\n\n")
27132723
.append(indent).append(" return \"\";\n")

sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/generated/FrameCodecDecoder.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ public static String irIdMetaAttribute(final MetaAttribute metaAttribute)
122122
{
123123
switch (metaAttribute)
124124
{
125-
case EPOCH: return "";
126-
case TIME_UNIT: return "";
127-
case SEMANTIC_TYPE: return "";
128125
case PRESENCE: return "required";
129126
}
130127

@@ -176,9 +173,6 @@ public static String irVersionMetaAttribute(final MetaAttribute metaAttribute)
176173
{
177174
switch (metaAttribute)
178175
{
179-
case EPOCH: return "";
180-
case TIME_UNIT: return "";
181-
case SEMANTIC_TYPE: return "";
182176
case PRESENCE: return "required";
183177
}
184178

@@ -230,9 +224,6 @@ public static String schemaVersionMetaAttribute(final MetaAttribute metaAttribut
230224
{
231225
switch (metaAttribute)
232226
{
233-
case EPOCH: return "";
234-
case TIME_UNIT: return "";
235-
case SEMANTIC_TYPE: return "";
236227
case PRESENCE: return "required";
237228
}
238229

@@ -279,9 +270,6 @@ public static String packageNameMetaAttribute(final MetaAttribute metaAttribute)
279270
{
280271
switch (metaAttribute)
281272
{
282-
case EPOCH: return "unix";
283-
case TIME_UNIT: return "nanosecond";
284-
case SEMANTIC_TYPE: return "";
285273
case PRESENCE: return "required";
286274
}
287275

@@ -390,9 +378,6 @@ public static String namespaceNameMetaAttribute(final MetaAttribute metaAttribut
390378
{
391379
switch (metaAttribute)
392380
{
393-
case EPOCH: return "unix";
394-
case TIME_UNIT: return "nanosecond";
395-
case SEMANTIC_TYPE: return "";
396381
case PRESENCE: return "required";
397382
}
398383

@@ -501,9 +486,6 @@ public static String semanticVersionMetaAttribute(final MetaAttribute metaAttrib
501486
{
502487
switch (metaAttribute)
503488
{
504-
case EPOCH: return "unix";
505-
case TIME_UNIT: return "nanosecond";
506-
case SEMANTIC_TYPE: return "";
507489
case PRESENCE: return "required";
508490
}
509491

sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/generated/FrameCodecEncoder.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ public static String irIdMetaAttribute(final MetaAttribute metaAttribute)
127127
{
128128
switch (metaAttribute)
129129
{
130-
case EPOCH: return "";
131-
case TIME_UNIT: return "";
132-
case SEMANTIC_TYPE: return "";
133130
case PRESENCE: return "required";
134131
}
135132

@@ -182,9 +179,6 @@ public static String irVersionMetaAttribute(final MetaAttribute metaAttribute)
182179
{
183180
switch (metaAttribute)
184181
{
185-
case EPOCH: return "";
186-
case TIME_UNIT: return "";
187-
case SEMANTIC_TYPE: return "";
188182
case PRESENCE: return "required";
189183
}
190184

@@ -237,9 +231,6 @@ public static String schemaVersionMetaAttribute(final MetaAttribute metaAttribut
237231
{
238232
switch (metaAttribute)
239233
{
240-
case EPOCH: return "";
241-
case TIME_UNIT: return "";
242-
case SEMANTIC_TYPE: return "";
243234
case PRESENCE: return "required";
244235
}
245236

@@ -282,9 +273,6 @@ public static String packageNameMetaAttribute(final MetaAttribute metaAttribute)
282273
{
283274
switch (metaAttribute)
284275
{
285-
case EPOCH: return "unix";
286-
case TIME_UNIT: return "nanosecond";
287-
case SEMANTIC_TYPE: return "";
288276
case PRESENCE: return "required";
289277
}
290278

@@ -369,9 +357,6 @@ public static String namespaceNameMetaAttribute(final MetaAttribute metaAttribut
369357
{
370358
switch (metaAttribute)
371359
{
372-
case EPOCH: return "unix";
373-
case TIME_UNIT: return "nanosecond";
374-
case SEMANTIC_TYPE: return "";
375360
case PRESENCE: return "required";
376361
}
377362

@@ -456,9 +441,6 @@ public static String semanticVersionMetaAttribute(final MetaAttribute metaAttrib
456441
{
457442
switch (metaAttribute)
458443
{
459-
case EPOCH: return "unix";
460-
case TIME_UNIT: return "nanosecond";
461-
case SEMANTIC_TYPE: return "";
462444
case PRESENCE: return "required";
463445
}
464446

sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/generated/TokenCodecDecoder.java

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ public static String tokenOffsetMetaAttribute(final MetaAttribute metaAttribute)
122122
{
123123
switch (metaAttribute)
124124
{
125-
case EPOCH: return "";
126-
case TIME_UNIT: return "";
127-
case SEMANTIC_TYPE: return "";
128125
case PRESENCE: return "required";
129126
}
130127

@@ -176,9 +173,6 @@ public static String tokenSizeMetaAttribute(final MetaAttribute metaAttribute)
176173
{
177174
switch (metaAttribute)
178175
{
179-
case EPOCH: return "";
180-
case TIME_UNIT: return "";
181-
case SEMANTIC_TYPE: return "";
182176
case PRESENCE: return "required";
183177
}
184178

@@ -230,9 +224,6 @@ public static String fieldIdMetaAttribute(final MetaAttribute metaAttribute)
230224
{
231225
switch (metaAttribute)
232226
{
233-
case EPOCH: return "";
234-
case TIME_UNIT: return "";
235-
case SEMANTIC_TYPE: return "";
236227
case PRESENCE: return "required";
237228
}
238229

@@ -284,9 +275,6 @@ public static String tokenVersionMetaAttribute(final MetaAttribute metaAttribute
284275
{
285276
switch (metaAttribute)
286277
{
287-
case EPOCH: return "";
288-
case TIME_UNIT: return "";
289-
case SEMANTIC_TYPE: return "";
290278
case PRESENCE: return "required";
291279
}
292280

@@ -338,9 +326,6 @@ public static String componentTokenCountMetaAttribute(final MetaAttribute metaAt
338326
{
339327
switch (metaAttribute)
340328
{
341-
case EPOCH: return "";
342-
case TIME_UNIT: return "";
343-
case SEMANTIC_TYPE: return "";
344329
case PRESENCE: return "required";
345330
}
346331

@@ -392,9 +377,6 @@ public static String signalMetaAttribute(final MetaAttribute metaAttribute)
392377
{
393378
switch (metaAttribute)
394379
{
395-
case EPOCH: return "";
396-
case TIME_UNIT: return "";
397-
case SEMANTIC_TYPE: return "";
398380
case PRESENCE: return "required";
399381
}
400382

@@ -431,9 +413,6 @@ public static String primitiveTypeMetaAttribute(final MetaAttribute metaAttribut
431413
{
432414
switch (metaAttribute)
433415
{
434-
case EPOCH: return "";
435-
case TIME_UNIT: return "";
436-
case SEMANTIC_TYPE: return "";
437416
case PRESENCE: return "required";
438417
}
439418

@@ -470,9 +449,6 @@ public static String byteOrderMetaAttribute(final MetaAttribute metaAttribute)
470449
{
471450
switch (metaAttribute)
472451
{
473-
case EPOCH: return "";
474-
case TIME_UNIT: return "";
475-
case SEMANTIC_TYPE: return "";
476452
case PRESENCE: return "required";
477453
}
478454

@@ -509,9 +485,6 @@ public static String presenceMetaAttribute(final MetaAttribute metaAttribute)
509485
{
510486
switch (metaAttribute)
511487
{
512-
case EPOCH: return "";
513-
case TIME_UNIT: return "";
514-
case SEMANTIC_TYPE: return "";
515488
case PRESENCE: return "required";
516489
}
517490

@@ -548,9 +521,6 @@ public static String deprecatedMetaAttribute(final MetaAttribute metaAttribute)
548521
{
549522
switch (metaAttribute)
550523
{
551-
case EPOCH: return "";
552-
case TIME_UNIT: return "";
553-
case SEMANTIC_TYPE: return "";
554524
case PRESENCE: return "optional";
555525
}
556526

@@ -597,9 +567,6 @@ public static String nameMetaAttribute(final MetaAttribute metaAttribute)
597567
{
598568
switch (metaAttribute)
599569
{
600-
case EPOCH: return "unix";
601-
case TIME_UNIT: return "nanosecond";
602-
case SEMANTIC_TYPE: return "";
603570
case PRESENCE: return "required";
604571
}
605572

@@ -708,9 +675,6 @@ public static String constValueMetaAttribute(final MetaAttribute metaAttribute)
708675
{
709676
switch (metaAttribute)
710677
{
711-
case EPOCH: return "unix";
712-
case TIME_UNIT: return "nanosecond";
713-
case SEMANTIC_TYPE: return "";
714678
case PRESENCE: return "required";
715679
}
716680

@@ -819,9 +783,6 @@ public static String minValueMetaAttribute(final MetaAttribute metaAttribute)
819783
{
820784
switch (metaAttribute)
821785
{
822-
case EPOCH: return "unix";
823-
case TIME_UNIT: return "nanosecond";
824-
case SEMANTIC_TYPE: return "";
825786
case PRESENCE: return "required";
826787
}
827788

@@ -930,9 +891,6 @@ public static String maxValueMetaAttribute(final MetaAttribute metaAttribute)
930891
{
931892
switch (metaAttribute)
932893
{
933-
case EPOCH: return "unix";
934-
case TIME_UNIT: return "nanosecond";
935-
case SEMANTIC_TYPE: return "";
936894
case PRESENCE: return "required";
937895
}
938896

@@ -1041,9 +999,6 @@ public static String nullValueMetaAttribute(final MetaAttribute metaAttribute)
1041999
{
10421000
switch (metaAttribute)
10431001
{
1044-
case EPOCH: return "unix";
1045-
case TIME_UNIT: return "nanosecond";
1046-
case SEMANTIC_TYPE: return "";
10471002
case PRESENCE: return "required";
10481003
}
10491004

@@ -1152,9 +1107,6 @@ public static String characterEncodingMetaAttribute(final MetaAttribute metaAttr
11521107
{
11531108
switch (metaAttribute)
11541109
{
1155-
case EPOCH: return "unix";
1156-
case TIME_UNIT: return "nanosecond";
1157-
case SEMANTIC_TYPE: return "";
11581110
case PRESENCE: return "required";
11591111
}
11601112

@@ -1263,9 +1215,6 @@ public static String epochMetaAttribute(final MetaAttribute metaAttribute)
12631215
{
12641216
switch (metaAttribute)
12651217
{
1266-
case EPOCH: return "unix";
1267-
case TIME_UNIT: return "nanosecond";
1268-
case SEMANTIC_TYPE: return "";
12691218
case PRESENCE: return "required";
12701219
}
12711220

@@ -1374,9 +1323,6 @@ public static String timeUnitMetaAttribute(final MetaAttribute metaAttribute)
13741323
{
13751324
switch (metaAttribute)
13761325
{
1377-
case EPOCH: return "unix";
1378-
case TIME_UNIT: return "nanosecond";
1379-
case SEMANTIC_TYPE: return "";
13801326
case PRESENCE: return "required";
13811327
}
13821328

@@ -1485,9 +1431,6 @@ public static String semanticTypeMetaAttribute(final MetaAttribute metaAttribute
14851431
{
14861432
switch (metaAttribute)
14871433
{
1488-
case EPOCH: return "unix";
1489-
case TIME_UNIT: return "nanosecond";
1490-
case SEMANTIC_TYPE: return "";
14911434
case PRESENCE: return "required";
14921435
}
14931436

@@ -1596,9 +1539,6 @@ public static String descriptionMetaAttribute(final MetaAttribute metaAttribute)
15961539
{
15971540
switch (metaAttribute)
15981541
{
1599-
case EPOCH: return "unix";
1600-
case TIME_UNIT: return "nanosecond";
1601-
case SEMANTIC_TYPE: return "";
16021542
case PRESENCE: return "required";
16031543
}
16041544

@@ -1707,9 +1647,6 @@ public static String referencedNameMetaAttribute(final MetaAttribute metaAttribu
17071647
{
17081648
switch (metaAttribute)
17091649
{
1710-
case EPOCH: return "unix";
1711-
case TIME_UNIT: return "nanosecond";
1712-
case SEMANTIC_TYPE: return "";
17131650
case PRESENCE: return "required";
17141651
}
17151652

0 commit comments

Comments
 (0)