org.ops4j.pax.exam
Class OptionUtils

java.lang.Object
  extended by org.ops4j.pax.exam.OptionUtils

public class OptionUtils
extends java.lang.Object

Utility methods related to Options.

Since:
0.3.0, December 08, 2008
Author:
Alin Dreghiciu (adreghiciu@gmail.com)

Method Summary
static Option[] combine(Option[] options1, Option... options2)
          Combines two arrays of options in one array containing both provided arrays in order they are provided.
static Option[] expand(Option... options)
          Expand options to one level by expanding eventual CompositeOption.
static
<T extends Option>
T[]
filter(java.lang.Class<T> optionType, Option... options)
          Filters the provided options by class returning an array of those option that are instance of the provided class.
static Option[] remove(java.lang.Class<? extends Option> optionType, Option... options)
          Removes from the provided options all options that are instance of the provided class, returning the remaining options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

expand

public static Option[] expand(Option... options)
Expand options to one level by expanding eventual CompositeOption. During this process null options are eliminated.

Parameters:
options - options to be expanded (can be null or an empty array)
Returns:
expanded options (never null). In case that the options to be expanded is null an empty array is returned

combine

public static Option[] combine(Option[] options1,
                               Option... options2)
Combines two arrays of options in one array containing both provided arrays in order they are provided.

Parameters:
options1 - array of options (can be null or empty array)
options2 - array of options (can be null or empty array)
Returns:
combined array of options (never null). In case that both arrays are null or empty an empty array is returned

filter

public static <T extends Option> T[] filter(java.lang.Class<T> optionType,
                                            Option... options)
Filters the provided options by class returning an array of those option that are instance of the provided class. Before filtering the options are expanded expand(Option[]).

Type Parameters:
T - type of desired options
Parameters:
optionType - class of the desired options
options - options to be filtered (can be null or empty array)
Returns:
array of desired option type (never null). In case that the array of filtered options is null, empty or there is no option that matches the desired type an empty array is returned

remove

public static Option[] remove(java.lang.Class<? extends Option> optionType,
                              Option... options)
Removes from the provided options all options that are instance of the provided class, returning the remaining options.

Parameters:
optionType - class of the desired options to be removed
options - options to be filtered (can be null or empty array)
Returns:
array of remaining options (never null) after removing the desired type


Copyright © 2006-2012 OPS4J - Open Participation Software for Java. All Rights Reserved.