List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:net.larry1123.elec.util.config.fieldhanders.strings.StringArrayListFieldHandler.java
/** * {@inheritDoc}//from www . jav a 2 s . c o m */ @Override public void setToFile(ArrayList<String> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setStringArray(getPropertyKey(), value.toArray(new String[value.size()]), getSpacer()); } }
From source file:com.mirth.connect.plugins.httpauth.basic.BasicAuthenticator.java
@Override public AuthenticationResult authenticate(RequestInfo request) { BasicHttpAuthProperties properties = getReplacedProperties(request); List<String> authHeaderList = request.getHeaders().get(HttpHeader.AUTHORIZATION.asString()); if (CollectionUtils.isNotEmpty(authHeaderList)) { String authHeader = StringUtils.trimToEmpty(authHeaderList.iterator().next()); int index = authHeader.indexOf(' '); if (index > 0) { String method = authHeader.substring(0, index); if (StringUtils.equalsIgnoreCase(method, "Basic")) { // Get Base64-encoded credentials String credentials = StringUtils.trim(authHeader.substring(index)); // Get the raw, colon-separated credentials credentials = new String(Base64.decodeBase64(credentials), StandardCharsets.ISO_8859_1); // Split on ':' to get the username and password index = credentials.indexOf(':'); if (index > 0) { String username = credentials.substring(0, index); String password = credentials.substring(index + 1); // Return successful result if the passwords match if (StringUtils.equals(password, properties.getCredentials().get(username))) { return AuthenticationResult.Success(username, properties.getRealm()); }/*w w w. j a v a 2 s . com*/ } } } } // Return authentication challenge return AuthenticationResult.Challenged("Basic realm=\"" + properties.getRealm() + "\""); }
From source file:net.larry1123.elec.util.config.fieldhanders.bytes.ByteArrayListFieldHandler.java
/** * {@inheritDoc}/*from w w w.j a v a2 s. c o m*/ */ @Override public void setToFile(ArrayList<Byte> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setByteArray(getPropertyKey(), Bytes.toArray(value), getSpacer()); } }
From source file:net.larry1123.elec.util.config.fieldhanders.longs.LongArrayListFieldHandler.java
/** * {@inheritDoc}/* ww w .j a v a2 s . c o m*/ */ @Override public void setToFile(ArrayList<Long> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setLongArray(getPropertyKey(), Longs.toArray(value), getSpacer()); } }
From source file:net.larry1123.elec.util.config.fieldhanders.floats.FloatArrayListFieldHandler.java
/** * {@inheritDoc}/* w w w.java2 s . c o m*/ */ @Override public void setToFile(ArrayList<Float> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setFloatArray(getPropertyKey(), Floats.toArray(value), getSpacer()); } }
From source file:net.larry1123.elec.util.config.fieldhanders.shorts.ShortArrayListFieldHandler.java
/** * {@inheritDoc}//from w w w . ja va2 s .co m */ @Override public void setToFile(ArrayList<Short> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setShortArray(getPropertyKey(), Shorts.toArray(value), getSpacer()); } }
From source file:net.larry1123.elec.util.config.fieldhanders.doubles.DoubleArrayListFieldHandler.java
/** * {@inheritDoc}/*from w w w . ja v a2 s .co m*/ */ @Override public void setToFile(ArrayList<Double> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setDoubleArray(getPropertyKey(), Doubles.toArray(value), getSpacer()); } }
From source file:net.larry1123.elec.util.config.fieldhanders.intergers.IntegerArrayListFieldHandler.java
/** * {@inheritDoc}//from w ww . j a va2s. co m */ @Override public void setToFile(ArrayList<Integer> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setIntArray(getPropertyKey(), Ints.toArray(value), getSpacer()); } }
From source file:co.rsk.validators.TxsMinGasPriceRule.java
@Override public boolean isValid(Block block) { List<Transaction> txs = block.getTransactionsList(); if (block.getMinGasPriceAsInteger() == null) { return false; }//from w w w. j a v a 2s. co m BigInteger blockMgp = block.getMinGasPriceAsInteger(); if (CollectionUtils.isNotEmpty(block.getTransactionsList())) { for (Transaction tx : txs) { if (!(tx instanceof RemascTransaction) && tx.getGasPriceAsInteger().compareTo(blockMgp) < 0) { logger.error("Tx gas price is under the Min gas Price of the block"); panicProcessor.panic("invalidmingasprice", "Tx gas price is under the Min gas Price of the block"); return false; } } } return true; }
From source file:com.ctc.fulfilmentprocess.actions.order.SubprocessesCompletedAction.java
@Override public Transition executeAction(final OrderProcessModel process) { LOG.info(PROCESS_MSG + process.getCode() + " in step " + getClass()); LOG.info(PROCESS_MSG + process.getCode() + " is checking for " + process.getConsignmentProcesses().size() + " subprocess results"); final OrderModel order = process.getOrder(); final Collection<ConsignmentProcessModel> consignmentProcesses = process.getConsignmentProcesses(); if (CollectionUtils.isNotEmpty(consignmentProcesses)) { final Optional<ConsignmentProcessModel> atleastOneConsProcessNotDone = consignmentProcesses.stream() .filter(consProcess -> !consProcess.isDone()).findFirst(); final boolean allConsProcessNotDone = consignmentProcesses.stream() .allMatch(consProcess -> !consProcess.isDone()); if (allConsProcessNotDone) { LOG.info(PROCESS_MSG + process.getCode() + " found all subprocesses incomplete"); order.setDeliveryStatus(DeliveryStatus.NOTSHIPPED); save(order);/* w ww .ja va2 s .com*/ return Transition.NOK; } else if (atleastOneConsProcessNotDone.isPresent()) { LOG.info(PROCESS_MSG + process.getCode() + " found subprocess " + atleastOneConsProcessNotDone.get().getCode() + " incomplete -> wait again!"); order.setDeliveryStatus(DeliveryStatus.PARTSHIPPED); save(order); return Transition.NOK; } } LOG.info(PROCESS_MSG + process.getCode() + " found all subprocesses complete"); order.setDeliveryStatus(DeliveryStatus.SHIPPED); save(order); return Transition.OK; }