Packages

c

com.twitter.app

JavaGlobalFlag

abstract class JavaGlobalFlag[T] extends GlobalFlag[T]

In order to declare a new GlobalFlag in Java, it can be done with a bit of ceremony by following a few steps:

  1. the flag's class name must end with "$", e.g. javaGlobalWithDefault$. This is done to mimic the behavior of Scala's singleton object.
  2. the class must have a method, public static Flag<?> globalFlagInstance(), that returns the singleton instance of the Flag.
  3. the class should have a static final field holding the singleton instance of the flag.
  4. the class should extend JavaGlobalFlag.
  5. to avoid extraneous creation of instances, thus forcing users to only access the singleton, the constructor should be private and the class should be public final.

An example of a GlobalFlag declared in Java:

import com.twitter.app.Flag;
import com.twitter.app.Flaggable;
import com.twitter.app.JavaGlobalFlag;

public final class exampleJavaGlobalFlag$ extends JavaGlobalFlag<String> {
  private exampleJavaGlobalFlag() {
    super("The default value", "The help string", Flaggable.ofString());
  }
  public static final Flag<String> Flag = new exampleJavaGlobalFlag();
  public static Flag<?> globalFlagInstance() {
    return Flag;
  }
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JavaGlobalFlag
  2. GlobalFlag
  3. Flag
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new JavaGlobalFlag(help: String, flaggable: Flaggable[T], clazz: Class[T])

    A flag without a default value.

    A flag without a default value.

    _declaration

    If you'd like to declare a new GlobalFlag in Java, see JavaGlobalFlag._declaration

    help

    documentation regarding usage of this flag.

    clazz

    the type of the flag

    Attributes
    protected
  2. new JavaGlobalFlag(default: T, help: String, flaggable: Flaggable[T])

    A flag with a default value.

    A flag with a default value.

    _declaration

    If you'd like to declare a new GlobalFlag in Java, see JavaGlobalFlag._declaration

    default

    the default value used if the value is not specified by the user.

    help

    documentation regarding usage of this flag.

    Attributes
    protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply(): T

    Return this flag's current value.

    Return this flag's current value. The default value is returned when the flag has not otherwise been set.

    Definition Classes
    Flag
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. def defaultString(): String

    String representation of this flag's default value

    String representation of this flag's default value

    Definition Classes
    Flag
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  11. def get: Option[T]

    Get the value if it has been set.

    Get the value if it has been set.

    Definition Classes
    Flag
    Note

    if no user-defined value has been set, None will be returned even when a default value is supplied.

    See also

    Flag.getWithDefault

  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def getGlobalFlag: Flag[_]

    Used by Flags.parseArgs to initialize Flag values.

    Used by Flags.parseArgs to initialize Flag values.

    Definition Classes
    GlobalFlag
    Note

    Called via reflection assuming it will be a static method on a singleton object. This causes problems for Java developers who want to create a GlobalFlag as there is no good means for them to have it be a static method. Thus, Java devs must add a method public static Flag<?> globalFlagInstance() which returns the singleton instance of the flag. See JavaGlobalFlag for more details.

  14. def getUnparsed: Option[String]

    Get the *unparsed* (as string) value if it has been set.

    Get the *unparsed* (as string) value if it has been set.

    Definition Classes
    Flag
    Note

    if no user-defined value has been set, None will be returned even when a default value is supplied.

    See also

    Flag.getWithDefaultUnparsed

  15. def getValue: Option[T]
    Attributes
    protected
    Definition Classes
    GlobalFlagFlag
  16. def getWithDefault: Option[T]

    Get the value if it has been set or if there is a default value supplied.

    Get the value if it has been set or if there is a default value supplied.

    Definition Classes
    Flag
    See also

    Flag.get and Flag.isDefined if you are interested in determining if there is a supplied value.

  17. def getWithDefaultUnparsed: Option[String]

    Get the *unparsed* (as string) value if it has been set or if there is a default value supplied.

    Get the *unparsed* (as string) value if it has been set or if there is a default value supplied.

    Definition Classes
    Flag
    See also

    Flag.get and Flag.isDefined if you are interested in determining if there is a supplied value.

  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. val help: String
    Definition Classes
    Flag
  20. def isDefined: Boolean

    True if the flag has been set.

    True if the flag has been set.

    Definition Classes
    Flag
    Note

    if no user-defined value has been set, false will be returned even when a default value is supplied.

  21. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  22. def let[R](t: T)(f: => R): R

    Override the value of this flag with t, only for the scope of the current com.twitter.util.Local for the given function f.

    Override the value of this flag with t, only for the scope of the current com.twitter.util.Local for the given function f.

    Definition Classes
    Flag
    See also

    letParse

    letClear

  23. def letClear[R](f: => R): R

    Unset the value of this flag, such that isDefined will return false, only for the scope of the current com.twitter.util.Local for the given function f.

    Unset the value of this flag, such that isDefined will return false, only for the scope of the current com.twitter.util.Local for the given function f.

    Definition Classes
    Flag
    See also

    let

    letParse

  24. def letParse[R](arg: String)(f: => R): R

    Override the value of this flag with arg String parsed to this Flag's T type, only for the scope of the current com.twitter.util.Local for the given function f.

    Override the value of this flag with arg String parsed to this Flag's T type, only for the scope of the current com.twitter.util.Local for the given function f.

    Definition Classes
    Flag
    See also

    let

    letClear

  25. val name: String

    The "name", or "id", of this Flag.

    The "name", or "id", of this Flag.

    While not marked final, if a subclass overrides this value, then developers must set that flag via System properties as otherwise it will not be recognized with command-line arguments. e.g. -DyourGlobalFlagName=flagName

    Definition Classes
    GlobalFlagFlag
  26. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. def noArgumentOk: Boolean

    Indicates whether or not the flag is valid without an argument.

    Indicates whether or not the flag is valid without an argument.

    Definition Classes
    Flag
  28. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  29. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  30. def parse(): Unit

    Parse this flag with no argument.

    Parse this flag with no argument.

    Definition Classes
    Flag
  31. def parse(raw: String): Unit

    Parse value raw into this flag.

    Parse value raw into this flag.

    Definition Classes
    Flag
  32. def parsingDone: Boolean
    Attributes
    protected[this]
    Definition Classes
    GlobalFlagFlag
  33. def reset(): Unit

    Reset this flag's value

    Reset this flag's value

    Definition Classes
    Flag
  34. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  35. def toString(): String

    String representation of this flag in -foo='bar' format, suitable for being used on the command line.

    String representation of this flag in -foo='bar' format, suitable for being used on the command line.

    Definition Classes
    Flag → AnyRef → Any
  36. def usageString: String
    Definition Classes
    Flag
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from GlobalFlag[T]

Inherited from Flag[T]

Inherited from AnyRef

Inherited from Any

Ungrouped