generate enum add routine

This commit is contained in:
Grahame Grieve 2024-11-29 11:42:50 +00:00
parent 17b22424f6
commit 69b96d8d3e
2 changed files with 28 additions and 14 deletions

View File

@ -594,13 +594,20 @@ public class PECodeGenerator {
w(accessors, " return "+name+" != null && !"+name+".isEmpty();");
w(accessors, " }");
w(accessors);
if (!isAbstract && !isEnum) {
w(accessors, " public "+type+" add"+csname+"() {");
w(accessors, " "+type+" theThing = new "+type+"();");
w(accessors, " get"+cname+"().add(theThing);");
w(accessors, " return theThing;");
w(accessors, " }");
w(accessors);
if (!isAbstract) {
if (!isEnum) {
w(accessors, " public "+type+" add"+csname+"() {");
w(accessors, " "+type+" theThing = new "+type+"();");
w(accessors, " get"+cname+"().add(theThing);");
w(accessors, " return theThing;");
w(accessors, " }");
w(accessors);
} else {
w(accessors, " public void add"+csname+"("+type+" theThing) {");
w(accessors, " get"+cname+"().add(theThing);");
w(accessors, " }");
w(accessors);
}
}
w(accessors, " public boolean has"+csname+"("+type+" item) {");
w(accessors, " return has"+cname+"() && "+name+".contains(item);");

View File

@ -600,13 +600,20 @@ public class PECodeGenerator {
w(accessors, " return "+name+" != null && !"+name+".isEmpty();");
w(accessors, " }");
w(accessors);
if (!isAbstract && !isEnum) {
w(accessors, " public "+type+" add"+csname+"() {");
w(accessors, " "+type+" theThing = new "+type+"();");
w(accessors, " get"+cname+"().add(theThing);");
w(accessors, " return theThing;");
w(accessors, " }");
w(accessors);
if (!isAbstract) {
if (!isEnum) {
w(accessors, " public "+type+" add"+csname+"() {");
w(accessors, " "+type+" theThing = new "+type+"();");
w(accessors, " get"+cname+"().add(theThing);");
w(accessors, " return theThing;");
w(accessors, " }");
w(accessors);
} else {
w(accessors, " public void add"+csname+"("+type+" theThing) {");
w(accessors, " get"+cname+"().add(theThing);");
w(accessors, " }");
w(accessors);
}
}
w(accessors, " public boolean has"+csname+"("+type+" item) {");
w(accessors, " return has"+cname+"() && "+name+".contains(item);");