public static Method findGetMethodForProperty()

in openwire-generator/src/main/java/org/apache/activemq/openwire/generator/GeneratorUtils.java [94:129]


    public static Method findGetMethodForProperty(Class<?> openWireType, OpenWirePropertyDescriptor property) throws Exception {

        if (property.getType().equals(boolean.class)) {
            Set<Method> getters = getAllMethods(openWireType,
                Predicates.and(
                        withModifier(Modifier.PUBLIC),
                        withPrefix("is"),
                        withParametersCount(0)));

            // Found an isX method, use that.
            if (!getters.isEmpty()) {
                for (Method method : getters) {
                    if (method.getName().equalsIgnoreCase("is" + property.getPropertyName())) {
                        return method;
                    }
                }
            }
        }

        Set<Method> getters = getAllMethods(openWireType,
            Predicates.and(
                    withModifier(Modifier.PUBLIC),
                    withPrefix("get"),
                    withParametersCount(0)));

        // Found an getX method, use that.
        if (!getters.isEmpty()) {
            for (Method method : getters) {
                if (method.getName().equalsIgnoreCase("get" + property.getPropertyName())) {
                    return method;
                }
            }
        }

        throw new IllegalArgumentException("Property class has invalid bean method names.");
    }