File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
main/java/uk/co/real_logic/sbe/generation/java
java/uk/co/real_logic/sbe/generation/java Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1657,6 +1657,10 @@ private static CharSequence generateDeclaration(
1657
1657
final StringBuilder sb = new StringBuilder ();
1658
1658
1659
1659
generateTypeJavadoc (sb , BASE_INDENT , typeToken );
1660
+ if (typeToken .deprecated () > 0 )
1661
+ {
1662
+ sb .append ("@Deprecated\n " );
1663
+ }
1660
1664
sb .append ("@SuppressWarnings(\" all\" )\n " )
1661
1665
.append ("public final class " ).append (className ).append (implementsString ).append ('\n' )
1662
1666
.append ("{\n " );
Original file line number Diff line number Diff line change @@ -458,6 +458,29 @@ public void shouldGenerateRepeatingGroupCountLimits() throws Exception
458
458
assertEquals (65534 , maxValue .invoke (null ));
459
459
}
460
460
461
+ @ Test
462
+ public void shouldMarkDeprecatedClasses () throws Exception
463
+ {
464
+ final ParserOptions options = ParserOptions .builder ().stopOnError (true ).build ();
465
+ final MessageSchema schema = parse (Tests .getLocalResource ("deprecated-msg-test-schema.xml" ), options );
466
+ final IrGenerator irg = new IrGenerator ();
467
+ ir = irg .generate (schema );
468
+
469
+ outputManager .clear ();
470
+ outputManager .setPackageName (ir .applicableNamespace ());
471
+
472
+ generator ().generate ();
473
+ final String encoderFqcn = ir .applicableNamespace () + ".DeprecatedMessageEncoder" ;
474
+ final Class <?> encoderClazz = compile (encoderFqcn );
475
+ assertNotNull (encoderClazz );
476
+ assertTrue (encoderClazz .isAnnotationPresent (Deprecated .class ));
477
+
478
+ final String decoderFqcn = ir .applicableNamespace () + ".DeprecatedMessageDecoder" ;
479
+ final Class <?> decoderClazz = compile (decoderFqcn );
480
+ assertNotNull (decoderClazz );
481
+ assertTrue (decoderClazz .isAnnotationPresent (Deprecated .class ));
482
+ }
483
+
461
484
private Class <?> getModelClass (final Object encoder ) throws ClassNotFoundException
462
485
{
463
486
final String className = "Model" ;
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" standalone =" yes" ?>
2
+ <sbe : messageSchema xmlns : sbe =" http://fixprotocol.io/2016/sbe"
3
+ package =" since.deprecated"
4
+ id =" 876"
5
+ version =" 4"
6
+ semanticVersion =" 5.2"
7
+ description =" Issue 876 - Test case for Deprecated messages for Java"
8
+ byteOrder =" littleEndian" >
9
+ <types >
10
+ <composite name =" messageHeader" description =" Message identifiers and length of message root" >
11
+ <type name =" blockLength" primitiveType =" uint16" />
12
+ <type name =" templateId" primitiveType =" uint16" />
13
+ <type name =" schemaId" primitiveType =" uint16" />
14
+ <type name =" version" primitiveType =" uint16" />
15
+ </composite >
16
+ </types >
17
+ <sbe : message name =" DeprecatedMessage" id =" 1" semanticType =" n/a" description =" Message deprecated since version 3" deprecated =" 3" >
18
+ <field name =" v1" id =" 1" type =" uint64" />
19
+ </sbe : message >
20
+ </sbe : messageSchema >
You can’t perform that action at this time.
0 commit comments