com.databasesandlife.util.wicket.BooleanSetModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common Show documentation
Show all versions of java-common Show documentation
Utility classes developed at Adrian Smith Software (A.S.S.)
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); }
}