Example usage for java.util Collection isEmpty

List of usage examples for java.util Collection isEmpty

Introduction

In this page you can find the example usage for java.util Collection isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this collection contains no elements.

Usage

From source file:com.jcwhatever.resourcepackermc.Main.java

public static void main(String[] args) {

    if (args.length == 0) {
        launch(args);/*from w  w w  .  j  av  a 2 s .  co  m*/
        return;
    }

    CommandLineParser parser = new BasicParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(_options, args);
    } catch (ParseException e) {
        System.err.println(e.getLocalizedMessage());
        showHelp();
        System.exit(-1);
        return;
    }

    // show help if requested
    if (cmd.hasOption("help")) {
        showHelp();
        return;
    }

    File folder;

    if (cmd.hasOption("folder")) {
        // use specified folder
        String foldername = cmd.getOptionValue("folder");
        folder = new File(foldername);
    } else {
        // use folder jar file is in.
        folder = Utils.getJarFolder();
    }

    // make sure folder exists
    if (!folder.exists()) {
        System.err.println("Folder not found: " + folder);
        System.exit(-1);
        return;
    }

    ResourcePackFiles files = new ResourcePackFiles(folder);
    Collection<OggSound> sounds = files.getSounds();
    Collection<OggSound> extraSounds = MinecraftSounds.removeMinecraft(sounds);

    // generate/update sounds.json file
    if (cmd.hasOption("sounds")) {

        SoundsJSONGenerator generator = new SoundsJSONGenerator();

        generator.generate(files, SoundsJSONGenerator.getFile(folder));

        // add newly generated sounds.json files to files collection
        if (files.getSoundsJson() == null) {
            File file = SoundsJSONGenerator.getFile(folder);
            files.getFiles().add(file);
        }
    }

    // Generate resource-sounds.yml
    if (cmd.hasOption("nucleus")) {
        NucleusGenerator generator = new NucleusGenerator();
        generator.generate(files, new File(Utils.getJarFolder(), "resource-sounds.yml"));
    }

    // Generate SOUNDS.TXT and SOUNDS_EXTRA.TXT
    if (cmd.hasOption("soundtxt")) {
        SoundsTxtGenerator generator = new SoundsTxtGenerator();

        File tracksFile = new File(Utils.getJarFolder(), "SOUNDS.TXT");

        generator.generate(files, tracksFile);
        System.out.println("Generated SOUNDS.TXT");

        if (!files.getFiles().contains(tracksFile)) {
            files.getFiles().add(tracksFile);
            System.out.println("Packed SOUNDS.TXT");
        }

        if (!extraSounds.isEmpty()) {

            SoundsExtraTxtGenerator extraGen = new SoundsExtraTxtGenerator();
            File extraTracksFile = new File(Utils.getJarFolder(), "SOUNDS_EXTRA.TXT");

            extraGen.generate(files, extraTracksFile);
            System.out.println("Generated SOUNDS_EXTRA.TXT");

            if (!files.getFiles().contains(extraTracksFile)) {
                files.getFiles().add(extraTracksFile);
                System.out.println("Packed SOUNDS_EXTRA.TXT");
            }
        }
    }

    // Generate Zip file
    if (cmd.hasOption("zip")) {
        String filename = cmd.getOptionValue("zip");
        File file = new File(Utils.getJarFolder(), filename);

        PackGenerator generator = new PackGenerator();
        generator.generate(files, file);
    }
}

From source file:Main.java

public static boolean isEmpty(Collection<?> collection) {
    return collection.isEmpty() || collection.size() == 0;
}

From source file:Main.java

public static boolean isNullOrEmpty(Collection c) {
    return null == c || c.isEmpty();
}

From source file:Main.java

public static <T> boolean isNotEmptyAndElementsInCollectionTheSame(Collection<T> colllection) {
    return !colllection.isEmpty() && (Sets.newHashSet(colllection).size() == 1);
}

From source file:Main.java

public static boolean isNullOrEmpty(Collection c) {
    if (null == c || c.isEmpty()) {
        return true;
    }//from ww w .j  a va  2 s .  c  o m
    return false;
}

From source file:Main.java

public static boolean isBlank(Collection col) {
    return col == null || col.isEmpty();
}

From source file:Main.java

public static boolean isNullOrEmpty(Collection<?> c) {
    return (null == c || c.isEmpty());
}

From source file:Main.java

public static boolean isNullOrEmpty(Collection c) {
    return c == null || c.isEmpty();
}

From source file:Main.java

public static boolean emptyOrNull(Collection<?> c) {
    return c == null || c.isEmpty();
}

From source file:Main.java

public static Object findSingleObject(Collection c) {
    if (c == null || c.isEmpty())
        return null;
    if (c.size() > 1)
        throw new IllegalStateException("found more than one object when single object requested");
    return c.iterator().next();
}