public void fillStatementWithBean()

in src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java [406:433]


    public void fillStatementWithBean(final PreparedStatement stmt, final Object bean,
            final String... propertyNames) throws SQLException {
        PropertyDescriptor[] descriptors;
        try {
            descriptors = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors();
        } catch (final IntrospectionException e) {
            throw new IllegalArgumentException("Couldn't introspect bean " + bean.getClass().toString(), e);
        }
        final PropertyDescriptor[] sorted = new PropertyDescriptor[propertyNames.length];
        for (int i = 0; i < propertyNames.length; i++) {
            final String propertyName = propertyNames[i];
            if (propertyName == null) {
                throw new NullPointerException("propertyName can't be null: " + i);
            }
            boolean found = false;
            for (final PropertyDescriptor descriptor : descriptors) {
                if (propertyName.equals(descriptor.getName())) {
                    sorted[i] = descriptor;
                    found = true;
                    break;
                }
            }
            if (!found) {
                throw new IllegalStateException("Couldn't find bean property: " + bean.getClass() + " " + propertyName);
            }
        }
        fillStatementWithBean(stmt, bean, sorted);
    }