diff --git a/Generator/JavaTypeWriters/JavaClassWriter.cs b/Generator/JavaTypeWriters/JavaClassWriter.cs index 920d77c..92bcd3e 100644 --- a/Generator/JavaTypeWriters/JavaClassWriter.cs +++ b/Generator/JavaTypeWriters/JavaClassWriter.cs @@ -17,12 +17,14 @@ public JavaClassWriter(JavaWriter javaWriter) this.javaWriter = javaWriter; } - public bool CanWrite(Type type) => IsClass(type) || IsReadonlyStruct(type); + public bool CanWrite(Type type) => IsClass(type) || IsAnyStruct(type); private bool IsClass(Type type) => type.IsClass; private bool IsReadonlyStruct(Type type) => type.IsValueType && type.GetProperties().All(p => !p.CanWrite); + private bool IsAnyStruct(Type type) => type.IsValueType; + public void Write(IndentedTextWriter writer, Type type, string typeName) { writer.WriteLine($""" @@ -141,6 +143,15 @@ public void Write(IndentedTextWriter writer, Type type, string typeName) javaWriter.PropertyGetterMethodsWriter.Write(writer, type, gettableProperties); javaWriter.PropertySetterMethodsWriter.Write(writer, type, typeName, gettableProperties, gettableProperties.Select(p => p.propertyName).ToArray()); } + else if (IsAnyStruct(type)) + { + javaWriter.SettablePropertiesWriter.Write(writer, type, ownedProperties); + javaWriter.StaticReadonlyPropertiesWriter.Write(writer, type, staticGetterProperties); + + javaWriter.CreatorMethodWriter.Write(writer, type, typeName, settableProperties); + javaWriter.PropertyGetterMethodsWriter.Write(writer, type, ownedProperties); + javaWriter.PropertySetterMethodsWriter.Write(writer, type, typeName, settableProperties, ownedProperties.Select(p => p.propertyName).ToArray()); + } writer.Indent--; writer.WriteLine("}");