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

eu.cedarsoft.utils.springrcp.selection.DefaultSelection Maven / Gradle / Ivy

package com.cedarsoft.utils.springrcp.selection;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

/**
 * 

* Date: 22.08.2006
* Time: 20:35:19
* * @author Johannes Schneider - * Xore Systems */ public class DefaultSelection implements Selection { private Class type; private Collection selectedElements; private T selected; public DefaultSelection( @NotNull Class type, @NotNull Collection selectedElements ) { this.type = type; this.selectedElements = new ArrayList( selectedElements ); } public DefaultSelection( @NotNull Class type ) { this( type, ( T ) null ); } public DefaultSelection( @NotNull Class type, @Nullable T selected ) { this.type = type; this.selected = selected; this.selectedElements = Collections.emptyList(); } public boolean isEmty() { return selectedElements.isEmpty() && selected == null; } public boolean isSingleSelection() { return selected != null; } public boolean isMultiSelection() { return !selectedElements.isEmpty(); } @NotNull public T getSingleSelection() { return selected; } @NotNull public Collection getMultiSelection() { return Collections.unmodifiableCollection( selectedElements ); } @NotNull public Class getType() { return type; } @Override public String toString() { return "DefaultSelection{" + "type=" + type + ", selectedElements=" + selectedElements + ", selected=" + selected + '}'; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy