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

com.databasesandlife.util.wicket.MapKeyModel Maven / Gradle / Ivy

There is a newer version: 21.0.1
Show newest version
package com.databasesandlife.util.wicket;

import org.apache.wicket.model.AbstractWrapModel;
import org.apache.wicket.model.IModel;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;

/**
 * Takes an underlying model which returns a map, and returns that map's keys.
 *   

* Performance note: * Do not use this in a ListView if there are a large number of entries (e.g. more than 1,000). * Unfortunately the model's getObject method gets called a great number of times if it's used as a ListView's model, * and the populateItem method calls getModelObject, which does a listView.getModel().get(i). *

* * @author This source is copyright Adrian Smith and licensed under the LGPL 3. * @see Project on GitHub */ public class MapKeyModel> extends AbstractWrapModel> { final @Nonnull IModel> wrappedModel; public MapKeyModel(@Nonnull IModel> wrappedModel) { this.wrappedModel = wrappedModel; } @Override public IModel> getWrappedModel() { return wrappedModel; } @Override public List getObject() { return new ArrayList<>(getWrappedModel().getObject().keySet()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy