public static JavaConstructorModel ParseConstructor(JavaTypeModel type, XElement element) { var method = new JavaConstructorModel( javaName: element.XGetAttribute("name"), javaVisibility: element.XGetAttribute("visibility"), javaStatic: element.XGetAttributeAsBool("static"), javaDeclaringType: type, deprecated: element.XGetAttribute("deprecated"), jniSignature: element.XGetAttribute("jni-signature"), isSynthetic: element.XGetAttributeAsBool("synthetic"), isBridge: element.XGetAttributeAsBool("bridge") ); // Yes, constructors in Java can have generic type parameters ¯\_(ツ)_/¯ if (element.Element("typeParameters") is XElement tp) { ParseTypeParameters(method.TypeParameters, tp); } foreach (var child in element.Elements("exception")) { method.Exceptions.Add(ParseException(child)); } foreach (var child in element.Elements("parameter")) { method.Parameters.Add(ParseParameter(method, child)); } if (element.XGetAttribute("merge.SourceFile") is string source && source.HasValue()) { method.PropertyBag.Add("merge.SourceFile", source); } if (element.XGetAttribute("deprecated-since") is string dep && dep.HasValue()) { method.PropertyBag.Add("deprecated-since", dep); } return(method); }
static void SaveConstructor(JavaConstructorModel ctor, XmlWriter writer) => SaveMember(ctor, writer, "constructor", null, null, null, null, null, ctor.DeclaringType.FullName, null, null, null, ctor.Parameters, ctor.IsBridge, null, ctor.IsSynthetic, null);