Example usage for java.beans IntrospectionException getLocalizedMessage

List of usage examples for java.beans IntrospectionException getLocalizedMessage

Introduction

In this page you can find the example usage for java.beans IntrospectionException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.opencms.ui.util.table.CmsBeanTableBuilder.java

/**
 * Creates a new table builder instance for the given bean class and view.<p>
 *
 * Depending on the view configuration of the columns, columns may be hidden depending on the view.
 *
 * @param cls the bean class/*from w  w  w .ja  v  a2 s. c  o  m*/
 * @param view the selected view
 *
 */
public CmsBeanTableBuilder(Class<T> cls, String view) {
    m_class = cls;
    m_view = view;
    try {
        List<PropertyDescriptor> descriptors = BeanUtil.getBeanPropertyDescriptor(m_class);
        for (PropertyDescriptor desc : descriptors) {
            Method getter = desc.getReadMethod();
            if (getter != null) {
                Column columnInfo = getter.getAnnotation(Column.class);
                if (columnInfo != null) {
                    if ((columnInfo.view() == null) || matchView(m_view, columnInfo.view())) {
                        m_columns.add(new ColumnBean(desc, columnInfo));
                    }
                }
            }
        }

        Collections.sort(m_columns, new Comparator<ColumnBean>() {

            public int compare(CmsBeanTableBuilder<T>.ColumnBean col1, CmsBeanTableBuilder<T>.ColumnBean col2) {

                return ComparisonChain.start().compare(col1.getInfo().order(), col2.getInfo().order()).result();
            }
        });
    } catch (IntrospectionException e) {
        // Shouldn't normally happen
        LOG.error(e.getLocalizedMessage(), e);
        throw new IllegalArgumentException(e);

    }
}