Example usage for java.util Collections addAll

List of usage examples for java.util Collections addAll

Introduction

In this page you can find the example usage for java.util Collections addAll.

Prototype

@SafeVarargs
public static <T> boolean addAll(Collection<? super T> c, T... elements) 

Source Link

Document

Adds all of the specified elements to the specified collection.

Usage

From source file:Main.java

public static void main(String[] args) {

    HashSet<String> months = new HashSet<String>(24);

    Collections.addAll(months, DateFormatSymbols.getInstance().getMonths());
    Collections.addAll(months, DateFormatSymbols.getInstance().getShortMonths());

    System.out.println(months.contains(args[0]));

}

From source file:com.urbancode.terraform.main.Main.java

/**
 * This method initializes Terraform from the command line.
 * The static main method verifies the command line arguments and terminates if they are incorrect.
 * @param args//ww  w .  j  av a 2 s . c  o m
 * @throws IOException
 * @throws XmlParsingException
 * @throws CredentialsException
 * @throws RestorationException
 * @throws DestructionException
 * @throws CreationException
 */
static public void main(String[] args) throws IOException, XmlParsingException, CredentialsException,
        CreationException, DestructionException, RestorationException {
    File inputXmlFile = null;
    File creds = null;
    List<String> unparsedArgs = new ArrayList<String>();
    String command = null;

    if (args != null && args.length >= 3) {
        if (!AllowedCommands.contains(args[0])) {
            String msg = "Invalid first argument: " + args[0];
            log.fatal(msg);
            throw new IOException(msg);
        } else {
            command = args[0].toLowerCase();
        }

        inputXmlFile = createFile(args[1]);
        creds = createFile(args[2]);

        Collections.addAll(unparsedArgs, args);
        // make args just the unparsed properties
        unparsedArgs.remove(0); // remove inputxmlpath
        unparsedArgs.remove(0); // remove create/destroy
        unparsedArgs.remove(0); // remove creds
    } else {
        log.fatal("Invalid number of arguments!\n" + "Found " + args.length + "\n" + "Expected at least 3");
        throw new IOException("improper args");
    }

    // check to make sure we have legit args
    if (inputXmlFile == null) {
        String msg = "No input xml file specified!";
        throw new IOException(msg);
    }
    if (creds == null) {
        String msg = "No credentials file specified!";
        throw new IOException(msg);
    }

    Main myMain = new Main(command, inputXmlFile, creds, unparsedArgs);
    myMain.execute();
}

From source file:Main.java

public static <A> Set<A> set(A... a) {
    Set<A> set = new HashSet<A>();
    Collections.addAll(set, a);
    return set;/* w w w  .j a v a2  s . co m*/
}

From source file:Main.java

public static <T> List<T> addAll(List<T> in, T... s) {
    Collections.addAll(in, s);
    return in;
}

From source file:Main.java

public static <T> ArrayList<T> newList(T... elements) {
    ArrayList<T> list = new ArrayList<>(elements.length);
    Collections.addAll(list, elements);
    return list;//  w w w  .j  av  a 2s  . c  om
}

From source file:Main.java

public static <T> ArrayList<T> mergeLists(final T... array) {
    final ArrayList<T> retValue = new ArrayList<T>();
    Collections.addAll(retValue, array);
    return retValue;
}

From source file:Main.java

public static <T> List<T> asList(T... objs) {
    if (objs == null) {
        return Collections.EMPTY_LIST;
    }//from  ww  w . j  ava 2s . co  m
    List<T> list = new ArrayList<T>();
    Collections.addAll(list, objs);
    return list;
}

From source file:Main.java

public static void addPref(String... keys) {
    Collections.addAll(prefsClean, keys);
}

From source file:Main.java

public static <T> List<T> asList(T... objs) {
    if (objs == null) {
        return Collections.EMPTY_LIST;
    } else {//from  w w  w  . jav a  2  s.co m
        ArrayList list = new ArrayList();
        Collections.addAll(list, objs);
        return list;
    }
}

From source file:Main.java

public static <T> Set<T> hashSetOf(T... ts) {
    Set<T> results = new HashSet<>();
    Collections.addAll(results, ts);
    return results;
}