Java Code Examples for org.apache.commons.lang.Validate.noNullElements()

The following are Jave code examples for showing how to use noNullElements() of the org.apache.commons.lang.Validate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: living-documentation   File: Leg.java   View Source Code Vote up 5 votes
public Leg(Voyage voyage, Location loadLocation, Location unloadLocation, Date loadTime, Date unloadTime) {
    Validate.noNullElements(new Object[]{voyage, loadLocation, unloadLocation, loadTime, unloadTime});

    this.voyage = voyage;
    this.loadLocation = loadLocation;
    this.unloadLocation = unloadLocation;
    this.loadTime = loadTime;
    this.unloadTime = unloadTime;
}
 
Example 2
Project: living-documentation   File: Itinerary.java   View Source Code Vote up 5 votes
/**
 * Constructor.
 *
 * @param legs List of legs for this itinerary.
 */
public Itinerary(final List<Leg> legs) {
    Validate.notEmpty(legs);
    Validate.noNullElements(legs);

    this.legs = legs;
}
 
Example 3
Project: living-documentation   File: Schedule.java   View Source Code Vote up 5 votes
Schedule(final List<CarrierMovement> carrierMovements) {
    Validate.notNull(carrierMovements);
    Validate.noNullElements(carrierMovements);
    Validate.notEmpty(carrierMovements);

    this.carrierMovements = carrierMovements;
}
 
Example 4
Project: living-documentation   File: CarrierMovement.java   View Source Code Vote up 5 votes
/**
 * Constructor.
 *
 * @param departureLocation location of departure
 * @param arrivalLocation   location of arrival
 * @param departureTime     time of departure
 * @param arrivalTime       time of arrival
 */
// TODO make package local
public CarrierMovement(Location departureLocation,
                       Location arrivalLocation,
                       Date departureTime,
                       Date arrivalTime) {
    Validate.noNullElements(new Object[]{departureLocation, arrivalLocation, departureTime, arrivalTime});
    this.departureTime = departureTime;
    this.arrivalTime = arrivalTime;
    this.departureLocation = departureLocation;
    this.arrivalLocation = arrivalLocation;
}
 
Example 5
Project: Uranium   File: CraftInventory.java   View Source Code Vote up 4 votes
public HashMap<Integer, ItemStack> addItem(ItemStack... items) {
    Validate.noNullElements(items, "Item cannot be null");
    HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();

    /* TODO: some optimization
     *  - Create a 'firstPartial' with a 'fromIndex'
     *  - Record the lastPartial per Material
     *  - Cache firstEmpty result
     */

    for (int i = 0; i < items.length; i++) {
        ItemStack item = items[i];
        while (true) {
            // Do we already have a stack of it?
            int firstPartial = firstPartial(item);

            // Drat! no partial stack
            if (firstPartial == -1) {
                // Find a free spot!
                int firstFree = firstEmpty();

                if (firstFree == -1) {
                    // No space at all!
                    leftover.put(i, item);
                    break;
                } else {
                    // More than a single stack!
                    if (item.getAmount() > getMaxItemStack()) {
                        CraftItemStack stack = CraftItemStack.asCraftCopy(item);
                        stack.setAmount(getMaxItemStack());
                        setItem(firstFree, stack);
                        item.setAmount(item.getAmount() - getMaxItemStack());
                    } else {
                        // Just store it
                        setItem(firstFree, item);
                        break;
                    }
                }
            } else {
                // So, apparently it might only partially fit, well lets do just that
                ItemStack partialItem = getItem(firstPartial);

                int amount = item.getAmount();
                int partialAmount = partialItem.getAmount();
                int maxAmount = partialItem.getMaxStackSize();

                // Check if it fully fits
                if (amount + partialAmount <= maxAmount) {
                    partialItem.setAmount(amount + partialAmount);
                    break;
                }

                // It fits partially
                partialItem.setAmount(maxAmount);
                item.setAmount(amount + partialAmount - maxAmount);
            }
        }
    }
    return leftover;
}
 
Example 6
Project: datax   File: Channel.java   View Source Code Vote up 4 votes
public void pushAll(final Collection<Record> rs) {
    Validate.notNull(rs);
    Validate.noNullElements(rs);
    this.doPushAll(rs);
    this.statPush(rs.size(), this.getByteSize(rs));
}