All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dellroad.stuff.vaadin7.SelfKeyedContainer Maven / Gradle / Ivy

The newest version!

/*
 * Copyright (C) 2022 Archie L. Cobbs. All rights reserved.
 */

package org.dellroad.stuff.vaadin7;

import java.util.Collection;

/**
 * A {@link SimpleKeyedContainer} where the item IDs are the underlying container objects themselves.
 *
 * 

* Restriction: instances can't contain two objects that are {@link Object#equals equal()} to each other. * * @param the type of the Java objects that back each {@link com.vaadin.data.Item} in the container */ @SuppressWarnings("serial") public class SelfKeyedContainer extends SimpleKeyedContainer { /** * Constructor. * *

* After using this constructor, subsequent invocations of {@link #setPropertyExtractor setPropertyExtractor()} * and {@link #setProperties setProperties()} are required to define the properties of this container * and how to extract them. */ public SelfKeyedContainer() { } /** * Constructor. * *

* After using this constructor, a subsequent invocation of {@link #setProperties setProperties()} is required * to define the properties of this container. * * @param propertyExtractor used to extract properties from the underlying Java objects; * may be null but then container is not usable until one is configured via * {@link #setPropertyExtractor setPropertyExtractor()} */ public SelfKeyedContainer(PropertyExtractor propertyExtractor) { this(propertyExtractor, null); } /** * Constructor. * *

* After using this constructor, a subsequent invocation of {@link #setPropertyExtractor setPropertyExtractor()} is required * to define how to extract the properties of this container; alternately, subclasses can override * {@link #getPropertyValue getPropertyValue()}. * * @param propertyDefs container property definitions; null is treated like the empty set */ protected SelfKeyedContainer(Collection> propertyDefs) { this(null, propertyDefs); } /** * Constructor. * * @param propertyExtractor used to extract properties from the underlying Java objects; * may be null but then container is not usable until one is configured via * {@link #setPropertyExtractor setPropertyExtractor()} * @param propertyDefs container property definitions; null is treated like the empty set */ public SelfKeyedContainer(PropertyExtractor propertyExtractor, Collection> propertyDefs) { super(propertyExtractor, propertyDefs); } /** * Constructor. * *

* Properties will be determined by the {@link ProvidesProperty @ProvidesProperty} and * {@link ProvidesPropertySort @ProvidesPropertySort} annotated methods in the given class. * * @param type class to introspect for annotated methods * @throws IllegalArgumentException if {@code type} is null * @throws IllegalArgumentException if {@code type} has two {@link ProvidesProperty @ProvidesProperty} * or {@link ProvidesPropertySort @ProvidesPropertySort} annotated methods for the same property * @throws IllegalArgumentException if a {@link ProvidesProperty @ProvidesProperty}-annotated method with no * {@linkplain ProvidesProperty#value property name specified} has a name which cannot be interpreted as a bean * property "getter" method * @see ProvidesProperty * @see ProvidesPropertySort * @see ProvidesPropertyScanner */ public SelfKeyedContainer(Class type) { super(type); } /** * Get the key to be used as item ID for the given object. * *

* The implementation in {@link SelfKeyedContainer} always returns {@code obj}. * * @param obj underlying container object * @return key for object */ @Override protected T getKeyFor(T obj) { return obj; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy