Skip to content

Commit 14899e2

Browse files
authored
Merge pull request #354 from benalexau/remove-structure
Remove Structure from interface hierachy.
2 parents db46099 + 3999c9b commit 14899e2

File tree

12 files changed

+12
-136
lines changed

12 files changed

+12
-136
lines changed

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

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@ public class JavaGenerator implements CodeGenerator
4545
private static final String INDENT = " ";
4646
private static final String GEN_COMPOSITE_DECODER_FLYWEIGHT = "CompositeDecoderFlyweight";
4747
private static final String GEN_COMPOSITE_ENCODER_FLYWEIGHT = "CompositeEncoderFlyweight";
48-
private static final String GEN_COMPOSITE_STRUCTURE = "CompositeStructure";
4948
private static final String GEN_DECODER_FLYWEIGHT = "DecoderFlyweight";
5049
private static final String GEN_ENCODER_FLYWEIGHT = "EncoderFlyweight";
5150
private static final String GEN_FLYWEIGHT = "Flyweight";
5251
private static final String GEN_MESSAGE_DECODER_FLYWEIGHT = "MessageDecoderFlyweight";
5352
private static final String GEN_MESSAGE_ENCODER_FLYWEIGHT = "MessageEncoderFlyweight";
5453
private static final String GEN_MESSAGE_FLYWEIGHT = "MessageFlyweight";
55-
private static final String GEN_MESSAGE_STRUCTURE = "MessageStructure";
56-
private static final String GEN_STRUCTURE = "Structure";
5754

5855
private final Ir ir;
5956
private final OutputManager outputManager;
@@ -124,11 +121,6 @@ private String decoderName(final String className)
124121
return className + "Decoder";
125122
}
126123

127-
private String structureName(final String className)
128-
{
129-
return className + "Structure";
130-
}
131-
132124
private void copyInterface(String simpleInterfaceName) throws IOException
133125
{
134126
final String resource = String.format("/java/interfaces/%s.java", simpleInterfaceName);
@@ -152,15 +144,12 @@ public void generateInterfaces() throws IOException
152144
{
153145
copyInterface(GEN_COMPOSITE_DECODER_FLYWEIGHT);
154146
copyInterface(GEN_COMPOSITE_ENCODER_FLYWEIGHT);
155-
copyInterface(GEN_COMPOSITE_STRUCTURE);
156147
copyInterface(GEN_DECODER_FLYWEIGHT);
157148
copyInterface(GEN_ENCODER_FLYWEIGHT);
158149
copyInterface(GEN_FLYWEIGHT);
159150
copyInterface(GEN_MESSAGE_DECODER_FLYWEIGHT);
160151
copyInterface(GEN_MESSAGE_ENCODER_FLYWEIGHT);
161152
copyInterface(GEN_MESSAGE_FLYWEIGHT);
162-
copyInterface(GEN_MESSAGE_STRUCTURE);
163-
copyInterface(GEN_STRUCTURE);
164153
}
165154
}
166155

@@ -171,7 +160,7 @@ private String implementsInterface(final String tokenName, final String interfac
171160
return "";
172161
}
173162

174-
return String.format(" implements %s<%s>", interfaceName, formatClassName(structureName(tokenName)));
163+
return String.format(" implements %s", interfaceName);
175164
}
176165

177166
public void generateMessageHeaderStub() throws IOException
@@ -194,22 +183,6 @@ public void generateMessageHeaderStub() throws IOException
194183
}
195184
}
196185

197-
private void generateMessageStructure(final Token msgToken) throws IOException
198-
{
199-
if (!generateInterfaces)
200-
{
201-
return;
202-
}
203-
204-
final String structName = formatClassName(structureName(msgToken.name()));
205-
try (final Writer out = outputManager.createOutput(structName))
206-
{
207-
out.append(generateStructureFileHeader(structName, ir.applicableNamespace(), GEN_MESSAGE_STRUCTURE));
208-
out.append(generateDeclaration("class", structName, " implements " + GEN_MESSAGE_STRUCTURE));
209-
out.append("}\n");
210-
}
211-
}
212-
213186
public void generateTypeStubs() throws IOException
214187
{
215188
generateMetaAttributeEnum();
@@ -254,7 +227,6 @@ public void generate() throws IOException
254227
final List<Token> varData = new ArrayList<>();
255228
collectVarData(messageBody, i, varData);
256229

257-
generateMessageStructure(msgToken);
258230
generateDecoder(BASE_INDENT, fields, groups, varData, msgToken);
259231
generateEncoder(BASE_INDENT, fields, groups, varData, msgToken);
260232
}
@@ -1061,17 +1033,6 @@ private void generateComposite(final List<Token> tokens) throws IOException
10611033
final String decoderName = decoderName(compositeName);
10621034
final String encoderName = encoderName(compositeName);
10631035

1064-
if (generateInterfaces)
1065-
{
1066-
final String structureName = structureName(compositeName);
1067-
try (final Writer out = outputManager.createOutput(structureName))
1068-
{
1069-
out.append(generateStructureFileHeader(structureName, ir.applicableNamespace(), GEN_COMPOSITE_STRUCTURE));
1070-
out.append(generateDeclaration("class", structureName, " implements " + GEN_COMPOSITE_STRUCTURE));
1071-
out.append("}\n");
1072-
}
1073-
}
1074-
10751036
try (final Writer out = outputManager.createOutput(decoderName))
10761037
{
10771038
final String implementsString = implementsInterface(token.name(), GEN_COMPOSITE_DECODER_FLYWEIGHT);
@@ -1366,22 +1327,6 @@ private static CharSequence generateEnumFileHeader(final String className, final
13661327
);
13671328
}
13681329

1369-
private static CharSequence generateStructureFileHeader(final String className, final String packageName,
1370-
String structureInterface)
1371-
{
1372-
return String.format(
1373-
"/* Generated SBE (Simple Binary Encoding) message codec */\n" +
1374-
"package %s;\n\n" +
1375-
"import %s.%s;\n\n" +
1376-
"@javax.annotation.Generated(value = {\"%s.%s\"})\n",
1377-
packageName,
1378-
JAVA_INTERFACE_PACKAGE,
1379-
structureInterface,
1380-
packageName,
1381-
className
1382-
);
1383-
}
1384-
13851330
private void generateAnnotations(
13861331
final String indent,
13871332
final String className,

sbe-tool/src/main/resources/java/interfaces/CompositeDecoderFlyweight.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* A <code>sbe:composite</code> decoder flyweight.
2222
*/
23-
public interface CompositeDecoderFlyweight<T extends CompositeStructure> extends DecoderFlyweight<T>
23+
public interface CompositeDecoderFlyweight extends DecoderFlyweight
2424
{
25-
CompositeDecoderFlyweight<T> wrap(DirectBuffer buffer, int offset);
25+
CompositeDecoderFlyweight wrap(DirectBuffer buffer, int offset);
2626
}

sbe-tool/src/main/resources/java/interfaces/CompositeEncoderFlyweight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/**
1919
* A <code>sbe:composite</code> encoder flyweight.
2020
*/
21-
public interface CompositeEncoderFlyweight<T extends CompositeStructure> extends EncoderFlyweight<T>
21+
public interface CompositeEncoderFlyweight extends EncoderFlyweight
2222
{
2323
}

sbe-tool/src/main/resources/java/interfaces/CompositeStructure.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

sbe-tool/src/main/resources/java/interfaces/DecoderFlyweight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/**
1919
* A decoder flyweight.
2020
*/
21-
public interface DecoderFlyweight<T extends Structure> extends Flyweight<T>
21+
public interface DecoderFlyweight extends Flyweight
2222
{
2323
}

sbe-tool/src/main/resources/java/interfaces/EncoderFlyweight.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* An encoder flyweight.
2222
*/
23-
public interface EncoderFlyweight<T extends Structure> extends Flyweight<T>
23+
public interface EncoderFlyweight extends Flyweight
2424
{
25-
EncoderFlyweight<T> wrap(MutableDirectBuffer buffer, int offset);
25+
EncoderFlyweight wrap(MutableDirectBuffer buffer, int offset);
2626
}

sbe-tool/src/main/resources/java/interfaces/Flyweight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* An SBE flyweight.
2020
*/
21-
public interface Flyweight<T extends Structure>
21+
public interface Flyweight
2222
{
2323
int encodedLength();
2424
}

sbe-tool/src/main/resources/java/interfaces/MessageDecoderFlyweight.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* An <code>sbe:message</code> decoder flyweight.
2222
*/
23-
public interface MessageDecoderFlyweight<T extends MessageStructure> extends MessageFlyweight<T>, DecoderFlyweight<T>
23+
public interface MessageDecoderFlyweight extends MessageFlyweight, DecoderFlyweight
2424
{
25-
MessageDecoderFlyweight<T> wrap(DirectBuffer buffer, int offset, int actingBlockLength, int actingVersion);
25+
MessageDecoderFlyweight wrap(DirectBuffer buffer, int offset, int actingBlockLength, int actingVersion);
2626
}

sbe-tool/src/main/resources/java/interfaces/MessageEncoderFlyweight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/**
1919
* An <code>sbe:message</code> encoder flyweight.
2020
*/
21-
public interface MessageEncoderFlyweight<T extends MessageStructure> extends MessageFlyweight<T>, EncoderFlyweight<T>
21+
public interface MessageEncoderFlyweight extends MessageFlyweight, EncoderFlyweight
2222
{
2323
}

sbe-tool/src/main/resources/java/interfaces/MessageFlyweight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Methods common to both <code>sbe:message</code> encoder and decoder flyweights.
2020
*/
21-
public interface MessageFlyweight<T extends MessageStructure> extends Flyweight<T>
21+
public interface MessageFlyweight extends Flyweight
2222
{
2323
int sbeBlockLength();
2424

0 commit comments

Comments
 (0)