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

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

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

import java.util.Set;

import org.apache.wicket.model.IModel;

/**
 * A model modeling "true" or "false" based upon whether an element is in a Set.
 *
 * @author This source is copyright Adrian Smith and licensed under the LGPL 3.
 * @see Project on GitHub
 */
@SuppressWarnings("serial")
public class BooleanSetModel implements IModel {
    final protected Set set;
    final E element;
    public BooleanSetModel(Set s, E e) { set=s; element=e; }
    @Override public void detach() {  }
    @Override public Boolean getObject() { return set.contains(element); }
    @Override public void setObject(Boolean x) { if (x) set.add(element); else set.remove(element); }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy