001package org.unix4j.option;
002
003import java.util.Iterator;
004import java.util.Set;
005
006/**
007 * An option set is a very simple unmodifiable set of options.
008 * 
009 * @param <O>
010 *            the recursive type definition for the implementing option, usually
011 *            an enum
012 */
013public interface OptionSet<O extends Option> extends Iterable<O> {
014        /**
015         * Returns the option type class, usually an enum.
016         * @return the option type
017         */
018        Class<O> optionType();
019        /**
020         * Returns true if the specified {@code option} is set and false otherwise
021         * 
022         * @param option
023         *            the option to test
024         * 
025         * @return true if {@code option} is set in this {@code OptionSet}
026         */
027        boolean isSet(O option);
028
029        /**
030         * Returns the active options in a {@link Set}. It depends on the
031         * implementation whether the returned set is modifiable or not.
032         * 
033         * @return an set containing all active options
034         */
035        Set<O> asSet();
036
037        /**
038         * Returns an iterator over the active options in this option set.
039         * <p>
040         * It depends on the implementation whether the returned iterator is
041         * modifiable or not, that is, whether it supports the {@code remove()}
042         * method.
043         * 
044         * @return an iterator over all active options
045         */
046        @Override
047        Iterator<O> iterator();
048        
049        /**
050         * Returns the number of active options in this option set.
051         * 
052         * @return the number of active options
053         */
054        int size();
055
056        /**
057         * Returns true if the {@link Option#acronym() acronym} should be used in
058         * for the specified {@code option} string representations. Note that some
059         * implementations may return the same value for all options.
060         * 
061         * @param option
062         *            the option of interest
063         * 
064         * @return true if the acronym should be used in string representations for
065         *         the specified {@code option}
066         */
067        boolean useAcronymFor(O option);
068}