diff options
Diffstat (limited to 'src/main/java/org')
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java index 23f699b..a2cbe10 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java @@ -142,18 +142,9 @@ public class JavaTransient0Generator implements Generator { .toList() ) ), - new JavaMethodDeclaration( - decodeMethodName(structDefinition.type()), - JavaVisibility.PUBLIC, - JavaMethodKind.STATIC, + generateDecodeMethod( + structDefinition.type(), structJavaTypeRef, - List.of( - new JavaParam( - JavaTypeRef.INPUT_STREAM, - INPUT_STREAM_NAME - ) - ), - List.of(JavaTypeRef.IO_EXCEPTION), new JavaBlock( Stream.concat( structDefinition.fields().stream() @@ -201,6 +192,27 @@ public class JavaTransient0Generator implements Generator { ); } + private JavaMethodDeclaration generateDecodeMethod( + Type type, + JavaTypeRef javaTypeRef, + JavaBlock body + ) { + return new JavaMethodDeclaration( + decodeMethodName(type), + JavaVisibility.PUBLIC, + JavaMethodKind.STATIC, + javaTypeRef, + List.of( + new JavaParam( + JavaTypeRef.INPUT_STREAM, + INPUT_STREAM_NAME + ) + ), + List.of(JavaTypeRef.IO_EXCEPTION), + body + ); + } + private Stream<JavaBlockStatement> generateEncode(JavaExpression value, Type type) { return switch (type) { case ConstructedNativeType constructedNativeType -> { |
