001package jmri.jmrix.swing;
002
003import java.util.Set;
004import javax.annotation.CheckForNull;
005import javax.annotation.Nonnull;
006import jmri.SystemConnectionMemo;
007
008/**
009 * Interface for a {@link javax.swing.Action} that is bound to a
010 * {@link SystemConnectionMemo}.
011 *
012 * @author Randall Wood (c) 2016
013 * @param <M> the supported subclass of SystemConnectionMemo
014 */
015public interface SystemConnectionAction<M extends SystemConnectionMemo> {
016
017    /**
018     * Get the {@link SystemConnectionMemo} this action is bound to.
019     * 
020     * @return the SystemConnectionMemo or null if not bound.
021     */
022    @CheckForNull
023    M getSystemConnectionMemo();
024
025    /**
026     * Set the {@link SystemConnectionMemo} this action is bound to.
027     * <p>
028     * Implementing classes may throw an IllegalArgumentException if the
029     * implementing class requires a specific subclass of SystemConnectionMemo.
030     *
031     * @param memo the SystemConnectionMemo
032     * @throws IllegalArgumentException if the SystemConnectionMemo is invalid
033     */
034    void setSystemConnectionMemo(@Nonnull M memo);
035
036    /**
037     * Get a list of {@link SystemConnectionMemo} subclasses that the
038     * implementing class accepts.
039     * <p>
040     * If the implementing class is a subclass of a class that does accept
041     * SystemConnectionMemos, but the implementing class does not accept any,
042     * return an empty array instead of null.
043     *
044     * @return Set of SystemConnectionMemo subclasses or empty array.
045     */
046    @Nonnull
047    Set<Class<? extends SystemConnectionMemo>> getSystemConnectionMemoClasses();
048}