646
647 /* Select public methods that look like "T getX()" or "boolean
648 isX()", where T is not void and X is not the empty
649 string. Exclude "Class getClass()" inherited from Object. */
650 for (int i = 0; i < methods.length; i++) {
651 final Method method = methods[i];
652 final String name = method.getName();
653 final Type type = method.getGenericReturnType();
654 final String rest;
655 if (name.startsWith("get")) {
656 rest = name.substring(3);
657 } else if (name.startsWith("is") &&
658 type instanceof Class &&
659 ((Class) type) == boolean.class) {
660 rest = name.substring(2);
661 } else {
662 // ignore non-getter methods
663 continue;
664 }
665
666 if (rest.equals("") ||
667 method.getParameterTypes().length > 0 ||
668 type == void.class ||
669 rest.equals("Class")) {
670
671 // ignore non-getter methods
672 continue;
673 }
674 names.add(decapitalize(rest));
675 types.add(toOpenType(type));
676 }
677
678 final String[] nameArray = names.toArray(new String[0]);
679 openType = new CompositeType(c.getName(),
680 c.getName(),
681 nameArray, // field names
682 nameArray, // field descriptions
683 types.toArray(new OpenType<?>[0]));
684 }
685 }
686
|
646
647 /* Select public methods that look like "T getX()" or "boolean
648 isX()", where T is not void and X is not the empty
649 string. Exclude "Class getClass()" inherited from Object. */
650 for (int i = 0; i < methods.length; i++) {
651 final Method method = methods[i];
652 final String name = method.getName();
653 final Type type = method.getGenericReturnType();
654 final String rest;
655 if (name.startsWith("get")) {
656 rest = name.substring(3);
657 } else if (name.startsWith("is") &&
658 type instanceof Class &&
659 ((Class) type) == boolean.class) {
660 rest = name.substring(2);
661 } else {
662 // ignore non-getter methods
663 continue;
664 }
665
666 if (rest.isEmpty() ||
667 method.getParameterTypes().length > 0 ||
668 type == void.class ||
669 rest.equals("Class")) {
670
671 // ignore non-getter methods
672 continue;
673 }
674 names.add(decapitalize(rest));
675 types.add(toOpenType(type));
676 }
677
678 final String[] nameArray = names.toArray(new String[0]);
679 openType = new CompositeType(c.getName(),
680 c.getName(),
681 nameArray, // field names
682 nameArray, // field descriptions
683 types.toArray(new OpenType<?>[0]));
684 }
685 }
686
|