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

org.unix4j.unix.uniq.UniqOptionSet_gu Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
package org.unix4j.unix.uniq;

import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Iterator;
import org.unix4j.option.Option;

import org.unix4j.unix.Uniq;

/**
 * Option sets for the {@link Uniq uniq} command with 
 * the following options: {@link #g g}, {@link #u u}.
 * 

* Application code does normally not directly refer to this class; * {@link Uniq#Options} should be used instead to specify command * options. See also {@link org.unix4j.unix.uniq.UniqOptions} for more information. */ public enum UniqOptionSet_gu implements UniqOptions { /** Option set with the following active options: {@link #global g}, {@link #uniqueOnly u}.*/ Active_gu( /*g:*/null /*already set*/, /*global:*/null /*already set*/, /*u:*/null /*already set*/, /*uniqueOnly:*/null /*already set*/, true, /*active:*/UniqOption.global, UniqOption.uniqueOnly ), /** Option set with the following active options: {@link #global g}, {@link #uniqueOnly u}.*/ Active_gu_long( /*g:*/null /*already set*/, /*global:*/null /*already set*/, /*u:*/null /*already set*/, /*uniqueOnly:*/null /*already set*/, false, /*active:*/UniqOption.global, UniqOption.uniqueOnly ), /** Option set with the following active options: {@link #uniqueOnly u}.*/ Active_u( /*g:*/Active_gu, /*global:*/Active_gu_long, /*u:*/null /*already set*/, /*uniqueOnly:*/null /*already set*/, true, /*active:*/UniqOption.uniqueOnly ), /** Option set with the following active options: {@link #uniqueOnly u}.*/ Active_u_long( /*g:*/Active_gu, /*global:*/Active_gu_long, /*u:*/null /*already set*/, /*uniqueOnly:*/null /*already set*/, false, /*active:*/UniqOption.uniqueOnly ); private UniqOptionSet_gu( UniqOptionSet_gu g, UniqOptionSet_gu global, UniqOptionSet_gu u, UniqOptionSet_gu uniqueOnly, boolean useAcronym, UniqOption... activeOptions ) { this.g = g == null ? this : g; this.global = global == null ? this : global; this.u = u == null ? this : u; this.uniqueOnly = uniqueOnly == null ? this : uniqueOnly; this.useAcronym = useAcronym; this.options = activeOptions.length == 0 ? EnumSet.noneOf(UniqOption.class) : EnumSet.copyOf(Arrays.asList(activeOptions)); } private final boolean useAcronym; /** * Option {@code "-g"}: Suppresses repeated lines globally, that is, if lines are non-adjacent. This option guarantees unique output lines even if the input lines are not sorted. *

* The option {@code "-g"} is equivalent to the {@code "--}{@link #global global}{@code "} option. *

* Technically speaking, this field points to a set with the options of the * current set plus the option {@code "-g"}. If the option {@code "-g"} * is already set, the field {@code g} points to the enum constant itself * as it already represents the current set of options. */ public final UniqOptionSet_gu g; /** * Option {@code "--global"}: Suppresses repeated lines globally, that is, if lines are non-adjacent. This option guarantees unique output lines even if the input lines are not sorted. *

* The option {@code "--global"} is equivalent to the {@code "-}{@link #g g}{@code "} option. *

* Technically speaking, this field points to a set with the options of the * current set plus the option {@code "--global"}. If the option {@code "--global"} * is already set, the field {@code global} points to the enum constant itself * as it already represents the current set of options. */ public final UniqOptionSet_gu global; /** * Option {@code "-u"}: Suppresses the writing of lines that are repeated in the input. *

* The option {@code "-u"} is equivalent to the {@code "--}{@link #uniqueOnly uniqueOnly}{@code "} option. *

* Technically speaking, this field points to a set with the options of the * current set plus the option {@code "-u"}. If the option {@code "-u"} * is already set, the field {@code u} points to the enum constant itself * as it already represents the current set of options. */ public final UniqOptionSet_gu u; /** * Option {@code "--uniqueOnly"}: Suppresses the writing of lines that are repeated in the input. *

* The option {@code "--uniqueOnly"} is equivalent to the {@code "-}{@link #u u}{@code "} option. *

* Technically speaking, this field points to a set with the options of the * current set plus the option {@code "--uniqueOnly"}. If the option {@code "--uniqueOnly"} * is already set, the field {@code uniqueOnly} points to the enum constant itself * as it already represents the current set of options. */ public final UniqOptionSet_gu uniqueOnly; private final EnumSet options; //inherit javadoc @Override public Class optionType() { return UniqOption.class; } //inherit javadoc @Override public boolean isSet(UniqOption option) { return options.contains(option); } //inherit javadoc @Override public int size() { return options.size(); } /** * Returns the set with the active options. The returned set a new defensive * copy instance created when this method is called, modifications of this * set will therefore not alter {@code this} option set. * * @return a copy of the set with the active options. */ @Override public EnumSet asSet() { return EnumSet.copyOf(options); } /** * Returns an immutable iterator with the active options of this option set. * * @return an immutable iterator for over the active options */ @Override public Iterator iterator() { return Collections.unmodifiableSet(options).iterator(); } /** * Returns true if the {@link Option#acronym() acronym} should be used in * for the specified {@code option} string representations. *

* In particular and independent from the {@code option} argument, this * option set returns true if the last option added to this set was an * acronym, and false if it was a long option name. *

* For instance, the set defined as *

	 *    UniqOptionSet_gu.global.u;
	 * 
* uses acronyms, that is, this method always returns true for the above * set. *

* On the other hand, long option names are used and this method always * returns false for the set *

	 *    UniqOptionSet_gu.g.uniqueOnly;
	 * 
*

* Note that a repeated option is not treated as the last set option. * For instance, the first and last option of the following set are * equivalent and acronyms are used: *

	 *    UniqOptionSet_gu.g.u.global;
	 * 
*

* This method always returns true for the empty set with no active options. * * @param option * the option of interest, has no impact on the result returned * by this method * @return true if option acronyms should be used for string representations * of any option of this option set */ @Override public boolean useAcronymFor(UniqOption option) { return useAcronym; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy