com.twitter.common.args
Class ArgFilters

java.lang.Object
  extended by com.twitter.common.args.ArgFilters

public final class ArgFilters
extends Object

Utilities for generating @CmdLine Arg filters suitable for use with ArgScanner.parse(Predicate, Iterable). These filters assume the fields parsed will all be annotated with CmdLine.


Field Summary
static Predicate<Field> SELECT_ALL
          A filter that selects all @CmdLine Args found on the classpath.
 
Method Summary
static Predicate<Field> selectAllPackagesUnderHere(Package pkg)
          Creates a filter that selects all @CmdLine Args found in classes that are members of the given package or its sub-packages.
static Predicate<Field> selectClass(Class<?> clazz)
          Creates a filter that selects all @CmdLine Args found in the given class.
static Predicate<Field> selectClasses(Class<?>... cls)
          Creates a filter that selects all @CmdLine Args found in the given classes.
static Predicate<Field> selectCmdLineArg(Class<?> clazz, String name)
          Creates a filter that selects a single @CmdLine Arg.
static Predicate<Field> selectPackage(Package pkg)
          Creates a filter that selects all @CmdLine Args found in classes that are members of the given package.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_ALL

public static final Predicate<Field> SELECT_ALL
A filter that selects all @CmdLine Args found on the classpath.

Method Detail

selectPackage

public static Predicate<Field> selectPackage(Package pkg)
Creates a filter that selects all @CmdLine Args found in classes that are members of the given package. Note that this will not select subpackages.

Parameters:
pkg - The exact package of classes whose command line args will be selected.
Returns:
A filter that selects only command line args declared in classes that are members of the given pkg.

selectAllPackagesUnderHere

public static Predicate<Field> selectAllPackagesUnderHere(Package pkg)
Creates a filter that selects all @CmdLine Args found in classes that are members of the given package or its sub-packages.

Parameters:
pkg - The ancestor package of classes whose command line args will be selected.
Returns:
A filter that selects only command line args declared in classes that are members of the given pkg or its sub-packages.

selectClass

public static Predicate<Field> selectClass(Class<?> clazz)
Creates a filter that selects all @CmdLine Args found in the given class.

Parameters:
clazz - The class whose command line args will be selected.
Returns:
A filter that selects only command line args declared in the given clazz.

selectClasses

public static Predicate<Field> selectClasses(Class<?>... cls)
Creates a filter that selects all @CmdLine Args found in the given classes.

Parameters:
cls - The classes whose command line args will be selected.
Returns:
A filter that selects only command line args declared in the given classes.

selectCmdLineArg

public static Predicate<Field> selectCmdLineArg(Class<?> clazz,
                                                String name)
Creates a filter that selects a single @CmdLine Arg.

Parameters:
clazz - The class that declares the command line arg to be selected.
name - The com.twitter.common.args.CmdLine#name() of the arg to select.
Returns:
A filter that selects a single specified command line arg.