File tree Expand file tree Collapse file tree
jaxb-plugins-parent/jaxb-plugins/src
main/java/org/jvnet/jaxb/plugin/nobean
test/java/org/jvnet/jaxb/plugin/nobean/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import com .sun .tools .xjc .Options ;
55import com .sun .tools .xjc .Plugin ;
66import com .sun .tools .xjc .outline .ClassOutline ;
7+ import com .sun .tools .xjc .outline .FieldOutline ;
78import com .sun .tools .xjc .outline .Outline ;
9+ import org .jvnet .jaxb .plugin .util .FieldOutlineUtils ;
810import org .xml .sax .ErrorHandler ;
911import org .xml .sax .SAXException ;
1012
@@ -35,9 +37,12 @@ public String getUsage() {
3537 @ Override
3638 public boolean run (Outline model , Options opts , ErrorHandler errors ) throws SAXException {
3739 for (ClassOutline co : model .getClasses ()) {
38- Collection <JMethod > methods = co .implClass .methods ();
39- methods .removeIf (next -> next .name ().startsWith ("get" ));
40- methods .removeIf (next -> next .name ().startsWith ("is" ));
40+ for (FieldOutline fo : co .getDeclaredFields ()) {
41+ String getterSuffix = fo .getPropertyInfo ().getName (true );
42+ String getterName = "get" + getterSuffix ;
43+ String isGetterName = "is" + getterSuffix ;
44+ co .implClass .methods ().removeIf (n -> getterName .equals (n .name ()) || isGetterName .equals (n .name ()));
45+ }
4146 }
4247 return true ;
4348 }
Original file line number Diff line number Diff line change 44import com .sun .tools .xjc .Options ;
55import com .sun .tools .xjc .Plugin ;
66import com .sun .tools .xjc .outline .ClassOutline ;
7+ import com .sun .tools .xjc .outline .FieldOutline ;
78import com .sun .tools .xjc .outline .Outline ;
89import org .xml .sax .ErrorHandler ;
910import org .xml .sax .SAXException ;
@@ -35,8 +36,10 @@ public String getUsage() {
3536 @ Override
3637 public boolean run (Outline model , Options opts , ErrorHandler errors ) throws SAXException {
3738 for (ClassOutline co : model .getClasses ()) {
38- Collection <JMethod > methods = co .implClass .methods ();
39- methods .removeIf (next -> next .name ().startsWith ("set" ));
39+ for (FieldOutline fo : co .getDeclaredFields ()) {
40+ String setterName = "set" + fo .getPropertyInfo ().getName (true );
41+ co .implClass .methods ().removeIf (n -> setterName .equals (n .name ()));
42+ }
4043 }
4144 return true ;
4245 }
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ public void testExecute() throws Exception {
4646 List <String > lines = Files .readAllLines (javaFile );
4747 for (int i = 0 ; i < lines .size (); i ++) {
4848 String line = lines .get (i );
49- if (line .matches ("^ *public [a-zA-Z]+ (isSet|get)[A-Z]\\ w+\\ (\\ ) \\ {" )) {
49+ if (line .matches ("^ *public [a-zA-Z]+ (is|get)[A-Z]\\ w+\\ (\\ ) \\ {" )
50+ && !line .matches ("^ *public boolean isSet[A-Z]\\ w*\\ (\\ ) \\ {" )) {
5051 String fileLinePath = getGeneratedDirectory ()
5152 .toPath ()
5253 .relativize (javaFile )
You can’t perform that action at this time.
0 commit comments