Example usage for org.apache.commons.lang3 ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang3 ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(final Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

This method returns null for a null input array.

Usage

From source file:uk.gov.phe.gis.thematics.classification.classifiers.precision.rounding.Generic.java

public double[] round(double[] values, double[] excludes) {
    SortedSet<Double> excludeSet = new TreeSet<Double>(Arrays.asList(ArrayUtils.toObject(excludes)));
    SortedSet<Double> breakSet = new TreeSet<Double>();

    for (double b : values) {
        double roundedBreak = round(b);
        if (excludeSet.contains(roundedBreak) == false) {
            breakSet.add(roundedBreak);//from  w w w. j av  a2  s  . com
        }
    }
    return ArrayUtils.toPrimitive(breakSet.toArray(new Double[breakSet.size()]));
}

From source file:webreduce.indexing.datasetTools.java

public static int[] generateRandomNumbers(int size, int max) {
    Random rng = new Random(); // Ideally just create one instance globally
    // Note: use LinkedHashSet to maintain insertion order
    Set<Integer> generated = new LinkedHashSet<Integer>();
    while (generated.size() < size) {
        Integer next = rng.nextInt(max - 1) + 1;
        // As we're adding to a set, this will automatically do a containment check
        generated.add(next);/*from  w w  w . j a v a  2 s. c om*/
    }
    List<Integer> genList = new ArrayList<>();
    genList.addAll(generated);
    Collections.shuffle(genList);
    Integer rowIDs[] = new Integer[genList.size()];
    return ArrayUtils.toPrimitive(genList.toArray(rowIDs));
}

From source file:zeldaswordskills.entity.projectile.EntityCyclone.java

@Override
public void writeEntityToNBT(NBTTagCompound compound) {
    super.writeEntityToNBT(compound);
    compound.setFloat("areaOfEffect", getArea());
    compound.setIntArray("affectedEntities",
            ArrayUtils.toPrimitive(affectedEntities.toArray(new Integer[affectedEntities.size()])));
    NBTTagList items = new NBTTagList();
    for (ItemStack stack : capturedItems) {
        NBTTagCompound dropNBT = new NBTTagCompound();
        stack.writeToNBT(dropNBT);/*from   ww  w .j  a  va2 s. c o m*/
        items.appendTag(dropNBT);
    }
    compound.setTag("items", items);
}

From source file:zeldaswordskills.entity.projectile.EntityLeapingBlow.java

@Override
public void writeEntityToNBT(NBTTagCompound compound) {
    super.writeEntityToNBT(compound);
    compound.setBoolean("isMaster", isMaster);
    compound.setFloat("damage", damage);
    compound.setInteger("level", level);
    compound.setInteger("lifespan", lifespan);
    compound.setIntArray("affectedEntities",
            ArrayUtils.toPrimitive(affectedEntities.toArray(new Integer[affectedEntities.size()])));
}

From source file:zeldaswordskills.entity.ZSSPlayerInfo.java

@Override
public void saveNBTData(NBTTagCompound compound) {
    playerSkills.saveNBTData(compound);/*  w w  w. ja v  a  2s  .c om*/
    playerSongs.saveNBTData(compound);
    compound.setIntArray("zssStats",
            ArrayUtils.toPrimitive(playerStats.values().toArray(new Integer[playerStats.size()])));
    compound.setByte("ZSSGearReceived", receivedGear);
    compound.setInteger("lastBoots", Item.getIdFromItem(lastBootsWorn));
    compound.setInteger("borrowedMask", borrowedMask != null ? Item.getIdFromItem(borrowedMask) : -1);
    compound.setInteger("maskStage", maskStage);
}