org.vaadin.viritinv7.ListContainer - java examples

Here are the examples of the java api org.vaadin.viritinv7.ListContainer taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

15 Examples 7

19 View Complete Implementation : MGrid.java
Copyright Apache License 2.0
Author : viritin
/**
 * Manually forces refresh of the whole data. ListContainer backing
 * MGrid/MTable don't support property change listeners (to save memory and
 * CPU cycles). This method explicitly forces Grid's row cache invalidation.
 */
public void refreshRows() {
    if (getContainerDataSource() instanceof ListContainer) {
        ListContainer<T> listContainer = getListContainer();
        if (listContainer.gereplacedemIds() instanceof LazyList) {
            ((LazyList) listContainer.gereplacedemIds()).reset();
        }
        listContainer.fireItemSetChange();
    }
    refreshVisibleRows();
}

19 View Complete Implementation : MGrid.java
Copyright Apache License 2.0
Author : viritin
protected ListContainer<T> getListContainer() {
    ListContainer<T> listContainer = (ListContainer<T>) getContainerDataSource();
    return listContainer;
}

19 View Complete Implementation : MGrid.java
Copyright Apache License 2.0
Author : viritin
public MGrid<T> withProperties(String... propertyIds) {
    Container.Indexed containerDataSource = getContainerDataSource();
    if (containerDataSource instanceof ListContainer) {
        ListContainer<T> lc = (ListContainer<T>) containerDataSource;
        lc.setContainerPropertyIds(propertyIds);
    }
    setColumns((Object[]) propertyIds);
    return this;
}

19 View Complete Implementation : DynaBeanBasedContainerTest.java
Copyright Apache License 2.0
Author : viritin
@Test
@Ignore("Irrelevant with V8")
public void testMemoryUsage() {
    System.out.println("\n Testing List container from Maddon");
    long initial = reportMemoryUsage();
    long ms = System.currentTimeMillis();
    ListContainer lc = new ListContainer<>(persons);
    System.out.println("After creation (took " + (System.currentTimeMillis() - ms) + ")");
    long after = reportMemoryUsage();
    System.err.println("Delta (bytes)" + (after - initial));
    ms = System.currentTimeMillis();
    for (int i = 0; i < amount; i++) {
        Item item = lc.gereplacedem(persons.get(i));
        String str;
        str = item.gereplacedemProperty("firstName").toString();
    }
    System.out.println("After loop (took " + (System.currentTimeMillis() - ms) + ")");
    after = reportMemoryUsage();
    System.err.println("Delta (bytes)" + (after - initial));
    // call to avoid GC:n the whole container
    lc.gereplacedemIds();
    System.out.println("After GC");
    after = reportMemoryUsage();
    System.err.println("Delta (bytes)" + (after - initial));
}

19 View Complete Implementation : NestedPropertyTest.java
Copyright Apache License 2.0
Author : viritin
public static ListContainer<Enreplacedy> getTestListContainer() {
    ListContainer<Enreplacedy> listContainer = new ListContainer<>(getEnreplacedies(3));
    return listContainer;
}

18 View Complete Implementation : TypedSelect.java
Copyright Apache License 2.0
Author : viritin
/**
 * A select implementation with better typed API than in core Vaadin.
 *
 * By default the options toString is used to generate the caption for option.
 * To override this behavior, use setCaptionGenerator or override getCaption(T)
 * to provide your own strategy.
 * <p>
 * Behind the scenes uses Vaadin cores NativeSelect (default) or other cores
 * AbstractSelect implementation, type provided in constructor. Tree and Table
 * are not supported, see MTable.
 * <p>
 * Note, that this select is always in single select mode. See MultiSelectTable
 * for a proper "multiselect".
 * <p>
 * NOTE, that if your options might be empty OR you might use multiple different
 * types of options in your select, you have to specify the common superclreplaced
 * for the options either using constructor with the clreplaced parameter or using
 * setFieldType method. Due to Java type erasure, we cannot properly detect it
 * with generics (type parameters) only.
 *
 * @author mstahv
 * @param <T> the type of selects value
 */
public clreplaced TypedSelect<T> extends CustomField<T> {

    private static final long serialVersionUID = -8585094121129546069L;

    private CaptionGenerator<T> captionGenerator;

    private IconGenerator<T> iconGenerator;

    private AbstractSelect select;

    private ListContainer<T> bic;

    private Clreplaced<T> fieldType;

    /**
     * The type of element options in the select
     *
     * @param type the type of options in the list
     */
    public TypedSelect(Clreplaced<T> type) {
        this.fieldType = type;
        bic = new ListContainer<>(type);
    }

    /**
     * Note, that with this constructor, you cannot override the select type.
     *
     * @param options options to select from
     */
    public TypedSelect(T... options) {
        setOptions(options);
    }

    public TypedSelect(String caption) {
        setCaption(caption);
    }

    /**
     * {@inheritDoc}
     *
     * Sets the width of the wrapped select component.
     *
     * @param width the new width for this select
     * @param unit the unit of the new width
     */
    @Override
    public void setWidth(float width, Unit unit) {
        if (select != null) {
            select.setWidth(width, unit);
        }
        super.setWidth(width, unit);
    }

    @Override
    public void addStyleName(String style) {
        getSelect().addStyleName(style);
        super.addStyleName(style);
    }

    @Override
    public void removeStyleName(String style) {
        getSelect().removeStyleName(style);
        super.removeStyleName(style);
    }

    @Override
    public void setStyleName(String style) {
        getSelect().setStyleName(style);
        super.setStyleName(style);
    }

    /**
     * Note, that with this constructor, you cannot override the select type.
     *
     * @param caption the caption for the select
     * @param options available options for the select
     */
    public TypedSelect(String caption, Collection<T> options) {
        this(caption);
        setOptions(options);
    }

    public TypedSelect<T> withCaption(String caption) {
        setCaption(caption);
        return this;
    }

    public TypedSelect<T> withCaption(String caption, boolean captionAsHtml) {
        setCaption(caption);
        setCaptionAsHtml(captionAsHtml);
        return this;
    }

    public TypedSelect<T> asListSelectType() {
        return asListSelectType(null);
    }

    public TypedSelect<T> asListSelectType(ListSelectConfig config) {
        ListSelect listSelect = new ListSelect() {

            private static final long serialVersionUID = -6410506555879530635L;

            @SuppressWarnings("unchecked")
            @Override
            public String gereplacedemCaption(Object itemId) {
                return TypedSelect.this.getCaption((T) itemId);
            }

            @Override
            public Resource gereplacedemIcon(Object itemId) {
                if (iconGenerator != null) {
                    return iconGenerator.getIcon((T) itemId);
                }
                return super.gereplacedemIcon(itemId);
            }
        };
        if (config != null) {
            config.configurateListSelect(listSelect);
        }
        setSelectInstance(listSelect);
        return this;
    }

    public TypedSelect<T> asOptionGroupType() {
        return asOptionGroupType(null);
    }

    public TypedSelect<T> asOptionGroupType(OptionGroupConfig config) {
        OptionGroup optionGroup = new OptionGroup() {

            private static final long serialVersionUID = 6181647051422960470L;

            @SuppressWarnings("unchecked")
            @Override
            public String gereplacedemCaption(Object itemId) {
                return TypedSelect.this.getCaption((T) itemId);
            }

            @Override
            public Resource gereplacedemIcon(Object itemId) {
                if (iconGenerator != null) {
                    return iconGenerator.getIcon((T) itemId);
                }
                return super.gereplacedemIcon(itemId);
            }
        };
        if (config != null) {
            config.configurateOptionGroup(optionGroup);
        }
        setSelectInstance(optionGroup);
        return this;
    }

    public TypedSelect<T> asComboBoxType() {
        return asComboBoxType(null);
    }

    public TypedSelect<T> asComboBoxType(ComboBoxConfig config) {
        ComboBox comboBox = new ComboBox() {

            private static final long serialVersionUID = -468737106391765750L;

            @SuppressWarnings("unchecked")
            @Override
            public String gereplacedemCaption(Object itemId) {
                return TypedSelect.this.getCaption((T) itemId);
            }

            @Override
            public Resource gereplacedemIcon(Object itemId) {
                if (iconGenerator != null) {
                    return iconGenerator.getIcon((T) itemId);
                }
                return super.gereplacedemIcon(itemId);
            }
        };
        if (config != null) {
            config.configurateComboBox(comboBox);
        }
        setSelectInstance(comboBox);
        LazyComboBox.fixComboBoxVaadinIssue16647(comboBox);
        return this;
    }

    public TypedSelect<T> asNativeSelectType() {
        setSelectInstance(new NativeSelect() {

            private static final long serialVersionUID = 7903027904040681357L;

            @SuppressWarnings("unchecked")
            @Override
            public String gereplacedemCaption(Object itemId) {
                return TypedSelect.this.getCaption((T) itemId);
            }

            @Override
            public Resource gereplacedemIcon(Object itemId) {
                if (iconGenerator != null) {
                    return iconGenerator.getIcon((T) itemId);
                }
                return super.gereplacedemIcon(itemId);
            }
        });
        return this;
    }

    public TypedSelect<T> withSelectType(Clreplaced<? extends AbstractSelect> selectType) {
        if (selectType == ListSelect.clreplaced) {
            asListSelectType();
        } else if (selectType == OptionGroup.clreplaced) {
            asOptionGroupType();
        } else if (selectType == ComboBox.clreplaced) {
            asComboBoxType();
        } else {
            asNativeSelectType();
        }
        return this;
    }

    protected void setSelectInstance(AbstractSelect select) {
        if (this.select != null) {
            piggyBackListener = null;
        }
        this.select = select;
    }

    /**
     * @return the backing select instance, overriding this method may be
     * hazardous
     */
    protected AbstractSelect getSelect() {
        if (select == null) {
            withSelectType(null);
            if (bic != null) {
                select.setContainerDataSource(bic);
            }
        }
        ensurePiggybackListener();
        return select;
    }

    /**
     * Sets the input prompt used by the TypedSelect, in case the backing
     * instance supports inputprompt (read: is ComboBox).
     *
     * @param inputPrompt the input prompt
     * @return this TypedSelect instance
     */
    public TypedSelect<T> setInputPrompt(String inputPrompt) {
        if (getSelect() instanceof ComboBox) {
            ((ComboBox) getSelect()).setInputPrompt(inputPrompt);
        }
        return this;
    }

    protected String getCaption(T option) {
        if (captionGenerator != null) {
            return captionGenerator.getCaption(option);
        }
        return option == null ? "" : option.toString();
    }

    protected Resource getIcon(T enreplacedy) {
        if (iconGenerator != null) {
            return iconGenerator.getIcon(enreplacedy);
        }
        return null;
    }

    @Override
    public void focus() {
        getSelect().focus();
    }

    public final TypedSelect<T> setOptions(T... values) {
        return setOptions(Arrays.asList(values));
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Override
    public Clreplaced getType() {
        if (fieldType == null) {
            try {
                fieldType = (Clreplaced<T>) ((Container.Ordered) select.getContainerDataSource()).firsreplacedemId().getClreplaced();
            } catch (Exception e) {
                // If field type isn't set or can't be detected just report
                // Object, should be fine in most cases (vaadin will just
                // replacedign value without conversion.
                return Object.clreplaced;
            }
        }
        return fieldType;
    }

    /**
     * Explicitly sets the element type of the select.
     *
     * @param type the type of options in the select
     * @return this typed select instance
     */
    public TypedSelect<T> setType(Clreplaced<T> type) {
        this.fieldType = type;
        return this;
    }

    /**
     * Explicitly sets the element type of the select.
     *
     * @param type the type of options in the select
     * @return this typed select instance
     */
    public TypedSelect<T> setFieldType(Clreplaced<T> type) {
        this.fieldType = type;
        return this;
    }

    @Override
    public void setInvalidCommitted(boolean isCommitted) {
        super.setInvalidCommitted(isCommitted);
        getSelect().setInvalidCommitted(isCommitted);
    }

    @Override
    public void commit() throws SourceException, InvalidValueException {
        getSelect().commit();
        super.commit();
    }

    @Override
    public void discard() throws SourceException {
        getSelect().discard();
        super.discard();
    }

    /**
     * Buffering probably doesn't work correctly for this field, but in general
     * you should never use buffering either.
     * https://vaadin.com/web/matti/blog/-/blogs/3-pro-tips-for-vaadin-developers
     *
     * @param buffered true if buffering should be on
     */
    @Override
    public void setBuffered(boolean buffered) {
        getSelect().setBuffered(buffered);
        super.setBuffered(buffered);
    }

    @Override
    public boolean isBuffered() {
        return getSelect().isBuffered();
    }

    @Override
    protected void setInternalValue(T newValue) {
        super.setInternalValue(newValue);
        getSelect().setValue(newValue);
    }

    public TypedSelect<T> addMValueChangeListener(MValueChangeListener<T> listener) {
        addListener(MValueChangeEvent.clreplaced, listener, MValueChangeEventImpl.VALUE_CHANGE_METHOD);
        return this;
    }

    public TypedSelect<T> removeMValueChangeListener(MValueChangeListener<T> listener) {
        removeListener(MValueChangeEvent.clreplaced, listener, MValueChangeEventImpl.VALUE_CHANGE_METHOD);
        return this;
    }

    @Override
    public int getTabIndex() {
        return getSelect().getTabIndex();
    }

    @Override
    public void setTabIndex(int tabIndex) {
        getSelect().setTabIndex(tabIndex);
    }

    public CaptionGenerator<T> getCaptionGenerator() {
        return captionGenerator;
    }

    public TypedSelect<T> setCaptionGenerator(CaptionGenerator<T> captionGenerator) {
        this.captionGenerator = captionGenerator;
        return this;
    }

    public TypedSelect<T> setIconGenerator(IconGenerator<T> generator) {
        this.iconGenerator = generator;
        return this;
    }

    public IconGenerator<T> getIconGenerator() {
        return iconGenerator;
    }

    public final TypedSelect<T> setOptions(Collection<T> options) {
        if (bic != null) {
            bic.setCollection(options);
        } else {
            bic = new ListContainer<>(options);
        }
        getSelect().setContainerDataSource(bic);
        return this;
    }

    public final List<T> getOptions() {
        if (bic == null) {
            return Collections.EMPTY_LIST;
        } else {
            return (List<T>) bic.gereplacedemIds();
        }
    }

    public TypedSelect<T> setNullSelectionAllowed(boolean nullAllowed) {
        getSelect().setNullSelectionAllowed(nullAllowed);
        return this;
    }

    public TypedSelect<T> setBeans(Collection<T> options) {
        return setOptions(options);
    }

    public Collection<T> getBeans() {
        return (Collection) bic.gereplacedemIds();
    }

    @Override
    public void attach() {
        ensureContainerSet();
        super.attach();
    }

    private void ensureContainerSet() {
        if (bic != null && getSelect().getContainerDataSource() != bic) {
            getSelect().setContainerDataSource(bic);
        }
    }

    @Override
    public void setValue(T newFieldValue) throws com.vaadin.v7.data.Property.ReadOnlyException, ConversionException {
        ensureContainerSet();
        super.setValue(newFieldValue);
    }

    private ValueChangeListener piggyBackListener;

    private void ensurePiggybackListener() {
        if (piggyBackListener == null) {
            piggyBackListener = new ValueChangeListener() {

                private static final long serialVersionUID = 8457613845310646169L;

                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    setValue((T) event.getProperty().getValue());
                    fireEvent(new MValueChangeEventImpl<T>(TypedSelect.this));
                }
            };
            getSelect().addValueChangeListener(piggyBackListener);
        }
    }

    public TypedSelect<T> withFullWidth() {
        setWidth("100%");
        return this;
    }

    public TypedSelect<T> withReadOnly(boolean readOnly) {
        setReadOnly(readOnly);
        return this;
    }

    public TypedSelect<T> withValidator(Validator validator) {
        setImmediate(true);
        addValidator(validator);
        return this;
    }

    public TypedSelect<T> withWidth(float width, Unit unit) {
        setWidth(width, unit);
        return this;
    }

    public TypedSelect<T> withWidth(String width) {
        setWidth(width);
        return this;
    }

    public TypedSelect<T> withWidthUndefined() {
        setWidthUndefined();
        return this;
    }

    public TypedSelect<T> withId(String id) {
        setId(id);
        return this;
    }

    public TypedSelect<T> withStyleName(String... styleNames) {
        for (String styleName : styleNames) {
            addStyleName(styleName);
        }
        return this;
    }

    public TypedSelect<T> withIcon(Resource icon) {
        setIcon(icon);
        return this;
    }

    public void selectFirst() {
        if (bic != null && bic.size() > 0) {
            getSelect().setValue(bic.getIdByIndex(0));
        }
    }

    public TypedSelect<T> withNullSelectionAllowed(boolean nullAllowed) {
        setNullSelectionAllowed(nullAllowed);
        return this;
    }

    public TypedSelect<T> withVisible(boolean visible) {
        setVisible(visible);
        return this;
    }

    public TypedSelect<T> withDescription(String description) {
        setDescription(description);
        return this;
    }

    public TypedSelect<T> withEnabled(boolean enabled) {
        setEnabled(enabled);
        return this;
    }

    /**
     * @return gets the ListContainer used by this component
     */
    protected ListContainer<T> getBic() {
        return bic;
    }

    /**
     * @param listContainer sets the ListContainer used by this select. For
     * extensions only, should be set early or will fail.
     */
    protected void setBic(ListContainer<T> listContainer) {
        bic = listContainer;
    }

    @Override
    public void setReadOnly(boolean readOnly) {
        super.setReadOnly(readOnly);
        getSelect().setReadOnly(readOnly);
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        getSelect().setEnabled(enabled);
    }

    @Override
    protected Component initContent() {
        return getSelect();
    }

    public void addOption(T option) {
        getBic().addItem(option);
    }

    @Override
    public ErrorMessage getErrorMessage() {
        final ErrorMessage errorMessage = super.getErrorMessage();
        getSelect().setStyleName("error", errorMessage != null);
        return errorMessage;
    }
}

17 View Complete Implementation : MTable.java
Copyright Apache License 2.0
Author : viritin
/**
 * A better typed version of the Table component in Vaadin. Expects that users
 * are always listing POJOs, which is most often the case in modern Java
 * development. Uses ListContainer to bind data due to its superior performance
 * compared to BeanItemContainer.
 * <p>
 * Note, that MTable don't support "multiselection mode". It is also very little
 * tested in "editable mode".
 * <p>
 * If your "list" of enreplacedies is too large to load into memory, there are also
 * constructors for typical "service layers". Then paged requests are used to
 * fetch enreplacedies that are visible (or almost visible) in the UI. Behind the
 * scenes LazyList is used to "wrap" your service into list.
 *
 * @param <T> the type of the POJO listed in this Table.
 */
public clreplaced MTable<T> extends Table {

    private static final long serialVersionUID = 3330985834015680723L;

    private ListContainer<T> bic;

    private String[] pendingProperties;

    private String[] pendingHeaders;

    private Collection sortableProperties;

    // Cached last sort properties, used to maintain sorting when re-setting
    // lazy load strategy
    private String sortProperty;

    private boolean sortAscending;

    public MTable() {
    }

    /**
     * Constructs a Table with explicit bean type. Handy for example if your
     * beans are JPA proxies or the table is empty when showing it initially.
     *
     * @param type the type of beans that are listed in this table
     */
    public MTable(Clreplaced<? extends T> type) {
        bic = createContainer(type);
        setContainerDataSource(bic);
    }

    public MTable(T... beans) {
        this(new ArrayList<>(Arrays.asList(beans)));
    }

    /**
     * Constructs a Table with explicit bean type. Handy for example if your
     * beans are JPA proxies or the table is empty when showing it initially.
     *
     * @param type the type of beans that are listed in this table
     */
    public MTable(DynaClreplaced type) {
        bic = createContainer(type);
        setContainerDataSource(bic);
    }

    /**
     * A shorthand to create MTable using LazyList. By default page size of
     * LazyList.DEFAULT_PAGE_SIZE (30) is used.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     */
    public MTable(LazyList.PagingProvider<T> pageProvider, LazyList.CountProvider countProvider) {
        this(new LazyList(pageProvider, countProvider, DEFAULT_PAGE_SIZE));
    }

    /**
     * A shorthand to create MTable using LazyList.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @param pageSize the page size (aka maxResults) that is used in paging.
     */
    public MTable(LazyList.PagingProvider<T> pageProvider, LazyList.CountProvider countProvider, int pageSize) {
        this(new LazyList(pageProvider, countProvider, pageSize));
    }

    /**
     * A shorthand to create MTable using SortableLazyList. By default page size
     * of LazyList.DEFAULT_PAGE_SIZE (30) is used.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     */
    public MTable(SortableLazyList.SortablePagingProvider<T> pageProvider, LazyList.CountProvider countProvider) {
        this(new SortableLazyList(pageProvider, countProvider, DEFAULT_PAGE_SIZE));
    }

    /**
     * A shorthand to create MTable using SortableLazyList.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @param pageSize the page size (aka maxResults) that is used in paging.
     */
    public MTable(SortableLazyList.SortablePagingProvider<T> pageProvider, LazyList.CountProvider countProvider, int pageSize) {
        this(new SortableLazyList(pageProvider, countProvider, pageSize));
    }

    /**
     * A shorthand to create MTable using LazyList. By default page size of
     * LazyList.DEFAULT_PAGE_SIZE (30) is used.
     *
     * @param rowType the type of enreplacedies listed in the table
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     */
    public MTable(Clreplaced<T> rowType, LazyList.PagingProvider<T> pageProvider, LazyList.CountProvider countProvider) {
        this(rowType, pageProvider, countProvider, DEFAULT_PAGE_SIZE);
    }

    /**
     * A shorthand to create MTable using LazyList.
     *
     * @param rowType the type of enreplacedies listed in the table
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @param pageSize the page size (aka maxResults) that is used in paging.
     */
    public MTable(Clreplaced<T> rowType, LazyList.PagingProvider<T> pageProvider, LazyList.CountProvider countProvider, int pageSize) {
        this(rowType);
        lazyLoadFrom(pageProvider, countProvider, pageSize);
    }

    /**
     * A shorthand to create MTable using SortableLazyList. By default page size
     * of LazyList.DEFAULT_PAGE_SIZE (30) is used.
     *
     * @param rowType the type of enreplacedies listed in the table
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     */
    public MTable(Clreplaced<T> rowType, SortableLazyList.SortablePagingProvider<T> pageProvider, LazyList.CountProvider countProvider) {
        this(rowType, pageProvider, countProvider, DEFAULT_PAGE_SIZE);
    }

    /**
     * A shorthand to create MTable using SortableLazyList.
     *
     * @param rowType the type of enreplacedies listed in the table
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @param pageSize the page size (aka maxResults) that is used in paging.
     */
    public MTable(Clreplaced<T> rowType, SortableLazyList.SortablePagingProvider<T> pageProvider, LazyList.CountProvider countProvider, int pageSize) {
        this(rowType);
        lazyLoadFrom(pageProvider, countProvider, pageSize);
    }

    public MTable(Collection<T> beans) {
        this();
        if (beans != null) {
            bic = createContainer(beans);
            setContainerDataSource(bic);
        }
    }

    /**
     * Makes the table lazy load its content with given strategy.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @return this MTable object
     */
    public MTable<T> lazyLoadFrom(LazyList.PagingProvider<T> pageProvider, LazyList.CountProvider countProvider) {
        setBeans(new LazyList(pageProvider, countProvider, DEFAULT_PAGE_SIZE));
        return this;
    }

    /**
     * Makes the table lazy load its content with given strategy.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @param pageSize the page size (aka maxResults) that is used in paging.
     * @return this MTable object
     */
    public MTable<T> lazyLoadFrom(LazyList.PagingProvider<T> pageProvider, LazyList.CountProvider countProvider, int pageSize) {
        setBeans(new LazyList(pageProvider, countProvider, pageSize));
        return this;
    }

    /**
     * Makes the table lazy load its content with given strategy.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @return this MTable object
     */
    public MTable<T> lazyLoadFrom(SortableLazyList.SortablePagingProvider<T> pageProvider, LazyList.CountProvider countProvider) {
        setBeans(new SortableLazyList(pageProvider, countProvider, DEFAULT_PAGE_SIZE));
        return this;
    }

    /**
     * Makes the table lazy load its content with given strategy.
     *
     * @param pageProvider the interface via enreplacedies are fetched
     * @param countProvider the interface via the count of items is detected
     * @param pageSize the page size (aka maxResults) that is used in paging.
     * @return this MTable object
     */
    public MTable<T> lazyLoadFrom(SortableLazyList.SortablePagingProvider<T> pageProvider, LazyList.CountProvider countProvider, int pageSize) {
        setBeans(new SortableLazyList(pageProvider, countProvider, pageSize));
        return this;
    }

    protected ListContainer<T> createContainer(Clreplaced<? extends T> type) {
        // Type parameter just to keep NB happy
        return new ListContainer<T>(type);
    }

    private ListContainer<T> createContainer(DynaClreplaced type) {
        return new ListContainer<>(type);
    }

    protected ListContainer<T> createContainer(Collection<T> beans) {
        return new ListContainer<>(beans);
    }

    protected ListContainer<T> getContainer() {
        return bic;
    }

    public MTable<T> withProperties(String... visibleProperties) {
        if (isContainerInitialized()) {
            bic.setContainerPropertyIds(visibleProperties);
            setVisibleColumns((Object[]) visibleProperties);
        } else {
            pendingProperties = visibleProperties;
            for (String string : visibleProperties) {
                addContainerProperty(string, String.clreplaced, "");
            }
        }
        for (String visibleProperty : visibleProperties) {
            String[] parts = StringUtils.splitByCharacterTypeCamelCase(visibleProperty);
            parts[0] = StringUtils.capitalize(parts[0]);
            for (int i = 1; i < parts.length; i++) {
                parts[i] = parts[i].toLowerCase();
            }
            String saneCaption = StringUtils.join(parts, " ");
            setColumnHeader(visibleProperty, saneCaption);
        }
        return this;
    }

    protected boolean isContainerInitialized() {
        return bic != null;
    }

    public MTable<T> withColumnHeaders(String... columnNamesForVisibleProperties) {
        if (isContainerInitialized()) {
            setColumnHeaders(columnNamesForVisibleProperties);
        } else {
            pendingHeaders = columnNamesForVisibleProperties;
            // Add headers to temporary indexed container, in case table is initially
            // empty
            for (String prop : columnNamesForVisibleProperties) {
                addContainerProperty(prop, String.clreplaced, "");
            }
        }
        return this;
    }

    /**
     * the propertyId has to been added before!
     *
     * @param propertyId columns property id
     * @param width width to be reserved for columns content
     * @return MTable
     */
    public MTable<T> withColumnWidth(String propertyId, int width) {
        setColumnWidth(propertyId, width);
        return this;
    }

    /**
     * Explicitly sets which properties are sortable in the UI.
     *
     * @param sortableProperties the collection of property identifiers/names
     * that should be sortable
     * @return the MTable instance
     */
    public MTable<T> setSortableProperties(Collection sortableProperties) {
        this.sortableProperties = sortableProperties;
        return this;
    }

    /**
     * Explicitly sets which properties are sortable in the UI.
     *
     * @param sortableProperties the collection of property identifiers/names
     * that should be sortable
     * @return the MTable instance
     */
    public MTable<T> setSortableProperties(String... sortableProperties) {
        this.sortableProperties = Arrays.asList(sortableProperties);
        return this;
    }

    public Collection getSortableProperties() {
        return sortableProperties;
    }

    @Override
    public Collection<?> getSortableContainerPropertyIds() {
        if (getSortableProperties() != null) {
            return Collections.unmodifiableCollection(sortableProperties);
        }
        return super.getSortableContainerPropertyIds();
    }

    public void addMValueChangeListener(MValueChangeListener<T> listener) {
        addListener(MValueChangeEvent.clreplaced, listener, MValueChangeEventImpl.VALUE_CHANGE_METHOD);
        // implicitly consider the table should be selectable
        setSelectable(true);
        // Needed as client side checks only for "real value change listener"
        setImmediate(true);
    }

    public void removeMValueChangeListener(MValueChangeListener<T> listener) {
        removeListener(MValueChangeEvent.clreplaced, listener, MValueChangeEventImpl.VALUE_CHANGE_METHOD);
        setSelectable(hasListeners(MValueChangeEvent.clreplaced));
    }

    @Override
    protected void fireValueChange(boolean repaintIsNotNeeded) {
        super.fireValueChange(repaintIsNotNeeded);
        fireEvent(new MValueChangeEventImpl(this));
    }

    protected void ensureBeanItemContainer(Collection<T> beans) {
        if (!isContainerInitialized()) {
            bic = createContainer(beans);
            if (pendingProperties != null) {
                bic.setContainerPropertyIds(pendingProperties);
                setContainerDataSource(bic, Arrays.asList(pendingProperties));
                pendingProperties = null;
            } else {
                setContainerDataSource(bic);
            }
            if (pendingHeaders != null) {
                setColumnHeaders(pendingHeaders);
                pendingHeaders = null;
            }
        }
    }

    @Override
    public T getValue() {
        return (T) super.getValue();
    }

    @Override
    @Deprecated
    public void setMultiSelect(boolean multiSelect) {
        super.setMultiSelect(multiSelect);
    }

    public MTable<T> addBeans(T... beans) {
        addBeans(Arrays.asList(beans));
        return this;
    }

    public MTable<T> addBeans(Collection<T> beans) {
        if (!beans.isEmpty()) {
            if (isContainerInitialized()) {
                bic.addAll(beans);
            } else {
                ensureBeanItemContainer(beans);
            }
        }
        return this;
    }

    public MTable<T> setBeans(T... beans) {
        setBeans(new ArrayList<>(Arrays.asList(beans)));
        return this;
    }

    public MTable<T> setRows(T... beansForRows) {
        return setBeans(beansForRows);
    }

    public MTable<T> setBeans(Collection<T> beans) {
        if (sortProperty != null && beans instanceof SortableLazyList) {
            final SortableLazyList sll = (SortableLazyList) beans;
            sll.setSortProperty(new String[] { sortProperty });
            sll.setSortAscending(new boolean[] { sortAscending });
        }
        if (!isContainerInitialized() && !beans.isEmpty()) {
            ensureBeanItemContainer(beans);
        } else if (isContainerInitialized()) {
            bic.setCollection(beans);
        }
        return this;
    }

    public MTable<T> setRows(Collection<T> beansForRows) {
        return setBeans(beansForRows);
    }

    /**
     * Makes the first column of the table a primary column, for which all space
     * left out from other columns is given. The method also makes sure the
     * Table has a width defined (otherwise the setting makes no sense).
     *
     * @return {@link MTable}
     */
    public MTable<T> expandFirstColumn() {
        expand(getContainerPropertyIds().iterator().next().toString());
        if (getWidth() == -1) {
            return withFullWidth();
        }
        return this;
    }

    public MTable<T> withFullWidth() {
        setWidth(100, Unit.PERCENTAGE);
        return this;
    }

    public MTable<T> withHeight(String height) {
        setHeight(height);
        return this;
    }

    public MTable<T> withFullHeight() {
        return withHeight("100%");
    }

    public MTable<T> withWidth(String width) {
        setWidth(width);
        return this;
    }

    public MTable<T> withSize(MSize mSize) {
        setWidth(mSize.getWidth(), mSize.getWidthUnit());
        setHeight(mSize.getHeight(), mSize.getHeightUnit());
        return this;
    }

    public MTable<T> withCaption(String caption) {
        setCaption(caption);
        return this;
    }

    public MTable<T> withStyleName(String... styleNames) {
        for (String styleName : styleNames) {
            addStyleName(styleName);
        }
        return this;
    }

    public MTable<T> withIcon(Resource icon) {
        setIcon(icon);
        return this;
    }

    public MTable<T> withId(String id) {
        setId(id);
        return this;
    }

    public MTable<T> expand(String... propertiesToExpand) {
        for (String property : propertiesToExpand) {
            setColumnExpandRatio(property, 1);
        }
        return this;
    }

    /**
     * the propertyId has to been added before!
     *
     * @param propertyId columns property id
     * @param ratio the expandRatio used to divide excess space for this column
     * @return MTable
     */
    public MTable<T> withColumnExpand(String propertyId, float ratio) {
        setColumnExpandRatio(propertyId, ratio);
        return this;
    }

    private ItemClickListener itemClickPiggyback;

    private void ensureTypedItemClickPiggybackListener() {
        if (itemClickPiggyback == null) {
            itemClickPiggyback = new ItemClickListener() {

                private static final long serialVersionUID = -2318797984292753676L;

                @Override
                public void itemClick(ItemClickEvent event) {
                    fireEvent(new RowClickEvent<T>(event));
                }
            };
            addItemClickListener(itemClickPiggyback);
        }
    }

    public MTable<T> withProperties(List<String> a) {
        return withProperties(a.toArray(new String[a.size()]));
    }

    public static interface SimpleColumnGenerator<T> {

        public Object generate(T enreplacedy);
    }

    public MTable<T> withGeneratedColumn(String columnId, final SimpleColumnGenerator<T> columnGenerator) {
        addGeneratedColumn(columnId, new ColumnGenerator() {

            private static final long serialVersionUID = 2855441121974230973L;

            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                return columnGenerator.generate((T) itemId);
            }
        });
        return this;
    }

    public static clreplaced SortEvent extends Component.Event {

        private static final long serialVersionUID = 267382182533317834L;

        private boolean preventContainerSort = false;

        private final boolean sortAscending;

        private final String sortProperty;

        public SortEvent(Component source, boolean sortAscending, String property) {
            super(source);
            this.sortAscending = sortAscending;
            this.sortProperty = property;
        }

        public String getSortProperty() {
            return sortProperty;
        }

        public boolean isSortAscending() {
            return sortAscending;
        }

        /**
         * By calling this method you can prevent the sort call to the container
         * used by MTable. In this case you most most probably you want to
         * manually sort the container instead.
         */
        public void preventContainerSort() {
            preventContainerSort = true;
        }

        public boolean isPreventContainerSort() {
            return preventContainerSort;
        }

        private final static Method method = ReflectTools.findMethod(SortListener.clreplaced, "onSort", SortEvent.clreplaced);
    }

    /**
     * A listener that can be used to track when user sorts table on a column.
     *
     * Via the event user can also prevent the "container sort" done by the
     * Table and implement own sorting logic instead (e.g. get a sorted list of
     * enreplacedies from the backend).
     */
    public interface SortListener {

        public void onSort(SortEvent event);
    }

    public MTable addSortListener(SortListener listener) {
        addListener(SortEvent.clreplaced, listener, SortEvent.method);
        return this;
    }

    public MTable removeSortListener(SortListener listener) {
        removeListener(SortEvent.clreplaced, listener, SortEvent.method);
        return this;
    }

    private boolean isSorting = false;

    @Override
    public void sort(Object[] propertyId, boolean[] ascending) throws UnsupportedOperationException {
        if (isSorting) {
            // hack to avoid recursion
            return;
        }
        boolean refreshingPreviouslyEnabled = disableContentRefreshing();
        boolean defaultTableSortingMethod = false;
        try {
            isSorting = true;
            // create sort event and fire it, allow user to prevent default
            // operation
            sortAscending = ascending != null && ascending.length > 0 ? ascending[0] : true;
            sortProperty = propertyId != null && propertyId.length > 0 ? propertyId[0].toString() : null;
            final SortEvent sortEvent = new SortEvent(this, sortAscending, sortProperty);
            fireEvent(sortEvent);
            if (!sortEvent.isPreventContainerSort()) {
                // if not prevented, do sorting
                if (bic != null && bic.gereplacedemIds() instanceof SortableLazyList) {
                    // Explicit support for SortableLazyList, set sort parameters
                    // it uses to backend services and clear internal buffers
                    SortableLazyList<T> sll = (SortableLazyList) bic.gereplacedemIds();
                    if (ascending == null || ascending.length == 0) {
                        sll.sort(true, null);
                    } else {
                        sll.sort(ascending[0], propertyId[0].toString());
                    }
                    resetPageBuffer();
                } else {
                    super.sort(propertyId, ascending);
                    defaultTableSortingMethod = true;
                }
            }
            if (!defaultTableSortingMethod) {
                // Ensure the values used in UI are set as this method is public
                // and can be called by both UI event and app logic
                setSortAscending(sortAscending);
                setSortContainerPropertyId(sortProperty);
            }
        } catch (UnsupportedOperationException e) {
            throw new RuntimeException(e);
        } finally {
            isSorting = false;
            if (refreshingPreviouslyEnabled) {
                enableContentRefreshing(true);
            }
        }
    }

    /**
     * A version of ItemClickEvent that is properly typed and named.
     *
     * @param <T> the type of the row
     */
    public static clreplaced RowClickEvent<T> extends MouseEvents.ClickEvent {

        private static final long serialVersionUID = -73902815731458960L;

        public static final Method TYPED_ITEM_CLICK_METHOD;

        static {
            try {
                TYPED_ITEM_CLICK_METHOD = RowClickListener.clreplaced.getDeclaredMethod("rowClick", new Clreplaced[] { RowClickEvent.clreplaced });
            } catch (final java.lang.NoSuchMethodException e) {
                // This should never happen
                throw new java.lang.RuntimeException();
            }
        }

        private final ItemClickEvent orig;

        public RowClickEvent(ItemClickEvent orig) {
            super(orig.getComponent(), null);
            this.orig = orig;
        }

        /**
         * @return the enreplacedy(~row) that was clicked.
         */
        public T getEnreplacedy() {
            return (T) orig.gereplacedemId();
        }

        /**
         * @return the enreplacedy(~row) that was clicked.
         */
        public T getRow() {
            return getEnreplacedy();
        }

        /**
         * @return the identifier of the column on which the row click happened.
         */
        public String getColumnId() {
            return orig.getPropertyId().toString();
        }

        @Override
        public MouseEventDetails.MouseButton getButton() {
            return orig.getButton();
        }

        @Override
        public int getClientX() {
            return orig.getClientX();
        }

        @Override
        public int getClientY() {
            return orig.getClientY();
        }

        @Override
        public int getRelativeX() {
            return orig.getRelativeX();
        }

        @Override
        public int getRelativeY() {
            return orig.getRelativeY();
        }

        @Override
        public boolean isAltKey() {
            return orig.isAltKey();
        }

        @Override
        public boolean isCtrlKey() {
            return orig.isCtrlKey();
        }

        @Override
        public boolean isDoubleClick() {
            return orig.isDoubleClick();
        }

        @Override
        public boolean isMetaKey() {
            return orig.isMetaKey();
        }

        @Override
        public boolean isShiftKey() {
            return orig.isShiftKey();
        }
    }

    /**
     * A better typed version of ItemClickEvent.
     *
     * @param <T> the type of enreplacedies listed in the table
     */
    public interface RowClickListener<T> extends Serializable {

        public void rowClick(RowClickEvent<T> event);
    }

    public void addRowClickListener(RowClickListener<T> listener) {
        ensureTypedItemClickPiggybackListener();
        addListener(RowClickEvent.clreplaced, listener, RowClickEvent.TYPED_ITEM_CLICK_METHOD);
    }

    public void removeRowClickListener(RowClickListener<T> listener) {
        removeListener(RowClickEvent.clreplaced, listener, RowClickEvent.TYPED_ITEM_CLICK_METHOD);
    }

    /**
     * Clears caches in case the Table is backed by a LazyList implementation.
     * Also resets "pageBuffer" used by table. If you know you have changes in
     * the listing, you can call this method to ensure the UI gets updated.
     *
     * @deprecated use refreshRows instead
     */
    @Deprecated
    public void resetLazyList() {
        refreshRows();
    }

    /**
     * Clears caches in case the Table is backed by a LazyList implementation.
     * Also resets "pageBuffer" used by table. If you know you have changes in
     * the listing, you can call this method to ensure the UI gets updated.
     */
    public void refreshRows() {
        if (bic != null && bic.gereplacedemIds() instanceof LazyList) {
            ((LazyList) bic.gereplacedemIds()).reset();
        }
        resetPageBuffer();
    }

    /**
     * Sets the row of given enreplacedy as selected. This is practically a better
     * typed version for select(Object) and setValue(Object) methods.
     *
     * @param enreplacedy the enreplacedy whose row should be selected
     * @return the MTable instance
     */
    public MTable<T> setSelected(T enreplacedy) {
        setValue(enreplacedy);
        return this;
    }

    public MTable<T> withValueChangeListener(MValueChangeListener<T> listener) {
        addMValueChangeListener(listener);
        return this;
    }

    public MTable<T> withRowClickListener(RowClickListener<T> listener) {
        addRowClickListener(listener);
        return this;
    }

    public MTable<T> withSortListener(SortListener listener) {
        addSortListener(listener);
        return this;
    }
}

17 View Complete Implementation : DynaBeanBasedContainerTest.java
Copyright Apache License 2.0
Author : viritin
@Test
public void ensureNullFromNextAndPrevId() {
    final List<Person> persons = Service.getListOfPersons(2);
    ListContainer lc = new ListContainer<>(persons);
    replacedert.replacedertNull(lc.prevItemId(persons.get(0)));
    replacedert.replacedertEquals(persons.get(0), lc.prevItemId(persons.get(1)));
    replacedert.replacedertEquals(persons.get(1), lc.nexreplacedemId(persons.get(0)));
    replacedert.replacedertNull(lc.nexreplacedemId(persons.get(1)));
}

17 View Complete Implementation : DynaBeanItemTest.java
Copyright Apache License 2.0
Author : viritin
@Test
public void testReturnedPropertyInstances() {
    final Person robin = new Person(0, "Dick", "Grayson", 12);
    final ListContainer<Person> listContainer = new ListContainer<>(Person.clreplaced, Arrays.asList(robin));
    final Item robinItem = listContainer.gereplacedem(robin);
    replacedertTrue("An item instance should always the same property instance " + "for a given key", robinItem.gereplacedemProperty("age") == robinItem.gereplacedemProperty("age"));
}

15 View Complete Implementation : NullEntryComparator.java
Copyright Apache License 2.0
Author : viritin
@Test
public void test() {
    ArrayList<Person> arrayList = new ArrayList<>();
    Person person = new Person();
    person.setFirstName("Matti");
    arrayList.add(person);
    person = new Person();
    person.setFirstName(null);
    arrayList.add(person);
    ListContainer<Person> listContainer = new ListContainer<>(arrayList);
    listContainer.sort(new Object[] { "firstName" }, new boolean[] { false });
}

14 View Complete Implementation : ListContainerSortablePropertiesTest.java
Copyright Apache License 2.0
Author : viritin
@Test
public void testSortableProperties() {
    ListContainer<Person> listContainer = new ListContainer<>(Service.getListOfPersons(100));
    listContainer.setContainerPropertyIds("id", "firstName", "lastName", "age", "groups[0].name", "generated");
    Object[] expectedSortableProperties = new Object[] { "id", "firstName", "lastName", "age", "groups[0].name" };
    Collection<Object> actualSortableProperties = (Collection<Object>) listContainer.getSortableContainerPropertyIds();
    replacedert.replacedertThat(actualSortableProperties, JUnitMatchers.hasItems(expectedSortableProperties));
}

13 View Complete Implementation : ListContainerTest.java
Copyright Apache License 2.0
Author : viritin
@Test
public void testSort() {
    ListContainer<Person> lc = new ListContainer<>(Service.getListOfPersons(100));
    lc.sort(new Object[] { "age", "firstName" }, new boolean[] { true, false });
    List<Person> sortedList = lc.getBackingList();
    for (int i = 0; i < sortedList.size() - 1; i++) {
        Person a = sortedList.get(i);
        Person b = sortedList.get(i + 1);
        int ageCompare = a.getAge().compareTo(b.getAge());
        replacedertTrue(ageCompare <= 0);
        if (ageCompare == 0) {
            int nameCompare = a.getFirstName().compareTo(b.getFirstName());
            replacedertTrue(nameCompare >= 0);
        }
    }
}

11 View Complete Implementation : DynaBeanBasedContainerTest.java
Copyright Apache License 2.0
Author : viritin
@Test
@Ignore("Irrelevant with V8")
public void testEmptyList() {
    List<Person> l = new ArrayList<>();
    // Test with BeanItemContainer
    System.out.println("BeanItemContainer with empty list");
    BeanItemContainer<Person> bc = new BeanItemContainer<>(Person.clreplaced, l);
    System.out.println("   container size=" + bc.size());
    System.out.print("Properties: ");
    for (String p : bc.getContainerPropertyIds()) {
        System.out.print(p + " ");
    }
    // Test ListContainer with setCollection call
    System.out.println("\n\nListContainer with empty list via setCollection");
    ListContainer<Person> lc = new ListContainer<>(Person.clreplaced);
    lc.setCollection(l);
    System.out.println("   container size=" + lc.size());
    System.out.print("Properties: ");
    for (String p : lc.getContainerPropertyIds()) {
        System.out.print(p + " ");
    }
    // Test ListContainer with setCollection call
    System.out.println("\n\nListContainer with Clreplaced<T>, Collection<T> constructor");
    lc = new ListContainer<>(Person.clreplaced, l);
    System.out.println("   container size=" + lc.size());
    System.out.print("Properties: ");
    for (String p : lc.getContainerPropertyIds()) {
        System.out.print(p + " ");
    }
    Person per = new Person();
    per.setFirstName("First");
    per.setLastName("Lastname");
    per.setAge(r.nextInt(100));
    lc.addItem(per);
    System.out.println("\n   container size after addItem = " + lc.size());
    Person per2 = new Person();
    per2.setFirstName("Firs");
    per2.setLastName("Lastnam");
    per2.setAge(r.nextInt(100));
    l.add(per2);
    System.out.println("   container size after add = " + lc.size());
    // Test ListContainer with constructor that takes the List -- empty List
    // will cause zarro properties
    System.out.println("\n\nListContainer with empty list via Collection<T> constructor");
    l = new ArrayList<>();
    lc = new ListContainer<>(l);
    System.out.println("   container size=" + lc.size());
    System.out.println("Properties: none should print due to exception");
    replacedert.replacedertEquals(0, lc.getContainerPropertyIds().size());
}

11 View Complete Implementation : NestedPropertyTest.java
Copyright Apache License 2.0
Author : viritin
@Test
public void testListContainer() {
    ListContainer<Enreplacedy> listContainer = getTestListContainer();
    Enreplacedy enreplacedy = listContainer.getIdByIndex(0);
    Item dynaBeanItem = listContainer.gereplacedem(enreplacedy);
    Property itemProperty = dynaBeanItem.gereplacedemProperty("property");
    replacedert.replacedertNotNull(itemProperty);
    replacedert.replacedertEquals("foo", itemProperty.getValue());
    // Should not be reported by default...
    boolean contains = listContainer.getContainerPropertyIds().contains("detail.property");
    replacedert.replacedertFalse(contains);
    // But should be found if explicitly requested
    Property nestedProperty = dynaBeanItem.gereplacedemProperty("detail.property");
    replacedert.replacedertNotNull(nestedProperty);
    replacedert.replacedertEquals("bar", nestedProperty.getValue());
    replacedert.replacedertEquals(String.clreplaced, nestedProperty.getType());
    Property indexedProperty = dynaBeanItem.gereplacedemProperty("numbers[2]");
    replacedert.replacedertNotNull(indexedProperty);
    replacedert.replacedertEquals((enreplacedy.getId() + 1) * 3l, indexedProperty.getValue());
    replacedert.replacedertEquals(Long.clreplaced, indexedProperty.getType());
    Property mappedProperty = dynaBeanItem.gereplacedemProperty("stringToInteger(id)");
    replacedert.replacedertNotNull(mappedProperty);
    replacedert.replacedertEquals(enreplacedy.getId().intValue(), mappedProperty.getValue());
    replacedert.replacedertEquals(Integer.clreplaced, mappedProperty.getType());
    Property thirdLevel = dynaBeanItem.gereplacedemProperty("detailList[1].property");
    replacedert.replacedertNotNull(thirdLevel);
    replacedert.replacedertEquals("bar", thirdLevel.getValue());
    replacedert.replacedertEquals(String.clreplaced, thirdLevel.getType());
    Property awkward = dynaBeanItem.gereplacedemProperty("detailList[1].moreDetails[0]");
    replacedert.replacedertNotNull(awkward);
    Detail2 value = (Detail2) awkward.getValue();
    replacedert.replacedertEquals(Integer.valueOf(69), value.getProperty());
    replacedert.replacedertEquals(Detail2.clreplaced, awkward.getType());
    Property weird = dynaBeanItem.gereplacedemProperty("detailList[1].detail2.property");
    replacedert.replacedertNotNull(weird);
    replacedert.replacedertEquals(69, weird.getValue());
    replacedert.replacedertEquals(Integer.clreplaced, weird.getType());
    Property weirdest = dynaBeanItem.gereplacedemProperty("detailList[1].moreDetails[1].property");
    replacedert.replacedertNotNull(weirdest);
    replacedert.replacedertEquals(69, weirdest.getValue());
    replacedert.replacedertEquals(Integer.clreplaced, weirdest.getType());
    Property nonTypedLisreplacedem = dynaBeanItem.gereplacedemProperty("detailList[1].nonTypedDetails[0]");
    replacedert.replacedertNotNull(weirdest);
    final Detail2 value1 = (Detail2) nonTypedLisreplacedem.getValue();
    // Is of type Detail2, but reported type should be Object
    // (can't be inspected)
    replacedert.replacedertEquals(Integer.valueOf(69), value1.getProperty());
    replacedert.replacedertEquals(Object.clreplaced, nonTypedLisreplacedem.getType());
}

9 View Complete Implementation : ListContainerLoopPerformanceTest.java
Copyright Apache License 2.0
Author : viritin
public void loopAllEnreplacediesAndProperties() throws IOException {
    NullOutputStream nullOutputStream = new NullOutputStream();
    List<Person> listOfPersons = Service.getListOfPersons(100 * 1000);
    long currentTimeMillis = System.currentTimeMillis();
    ListContainer<Person> listContainer = new ListContainer<>(listOfPersons);
    Collection<?> ids = listContainer.getContainerPropertyIds();
    for (int i = 0; i < listContainer.size(); i++) {
        Item item = listContainer.gereplacedem(listOfPersons.get(i));
        for (Object propertyId : ids) {
            Property itemProperty = item.gereplacedemProperty(propertyId);
            final Object value = itemProperty.getValue();
            nullOutputStream.write(value.toString().getBytes());
            LOG.log(Level.FINEST, "Property: %s", value);
        }
    }
    LOG.log(Level.INFO, "Looping all properties in 100 000 Items took {0}ms", (System.currentTimeMillis() - currentTimeMillis));
}