Example usage for org.apache.commons.lang ArrayUtils isEmpty

List of usage examples for org.apache.commons.lang ArrayUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils isEmpty.

Prototype

public static boolean isEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is empty or null.

Usage

From source file:com.stratio.deep.cassandra.cql.DeepRecordReader.java

/**
 * Initialized this object./*from w ww.jav a2  s  .co m*/
 * <p>
 * Creates a new client and row iterator.
 * </p>
 */
private void initialize() {
    cfName = config.getTable();

    if (!ArrayUtils.isEmpty(config.getInputColumns())) {
        columns = StringUtils.join(config.getInputColumns(), ",");
    }

    partitioner = Utils.newTypeInstance(config.getPartitionerClassName(), IPartitioner.class);

    try {
        session = createConnection();

        retrieveKeys();
    } catch (Exception e) {
        throw new DeepIOException(e);
    }

    rowIterator = new RowIterator();
}

From source file:com.emental.mindraider.core.rest.resource.OutlineResource.java

/**
 * Get concepts URIs. We're presuming that there exists exactly one concepts
 * group./*from w  ww  .jav  a2 s  . co  m*/
 *
 * @return array of uri.
 */
@SuppressWarnings("unchecked")
public String[] getConceptUris() {
    ResourcePropertyGroup[] concepts;
    try {
        concepts = resource.getData().getPropertyGroup(new URI(PROPERTY_GROUP_URI_CONCEPTS));
    } catch (URISyntaxException e) {
        cat.debug("URISyntaxException: " + e.getMessage());
        return null;
    }

    if (concepts != null) {
        ConceptProperty[] properties = (ConceptProperty[]) concepts[0].getProperties()
                .toArray(new ConceptProperty[0]);
        if (!ArrayUtils.isEmpty(properties)) {
            String[] result = new String[properties.length];
            for (int i = 0; i < properties.length; i++) {
                result[i] = properties[i].getUri().toASCIIString();
            }
            return result;
        }
    }
    return null;
}

From source file:net.shopxx.service.impl.MemberAttributeServiceImpl.java

@Transactional(readOnly = true)
public Object toMemberAttributeValue(MemberAttribute memberAttribute, String[] values) {
    Assert.notNull(memberAttribute);//from  w ww.  j av  a2 s. c om
    Assert.notNull(memberAttribute.getType());

    if (ArrayUtils.isEmpty(values)) {
        return null;
    }

    String value = values[0].trim();
    switch (memberAttribute.getType()) {
    case name:
    case address:
    case zipCode:
    case phone:
    case mobile:
    case text:
        return StringUtils.isNotEmpty(value) ? value : null;
    case gender:
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        try {
            return Member.Gender.valueOf(value);
        } catch (IllegalArgumentException e) {
            return null;
        }
    case birth:
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        try {
            return DateUtils.parseDate(value, CommonAttributes.DATE_PATTERNS);
        } catch (ParseException e) {
            return null;
        }
    case area:
        Long id = NumberUtils.toLong(value, -1L);
        return areaDao.find(id);
    case select:
        if (CollectionUtils.isNotEmpty(memberAttribute.getOptions())
                && memberAttribute.getOptions().contains(value)) {
            return value;
        }
        break;
    case checkbox:
        if (CollectionUtils.isNotEmpty(memberAttribute.getOptions())
                && memberAttribute.getOptions().containsAll(Arrays.asList(values))) {
            return Arrays.asList(values);
        }
        break;
    }
    return null;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getInvoiceAmount() {
    BigDecimal total = new BigDecimal(0.0);
    if (!ArrayUtils.isEmpty(invoices)) {
        for (int i = 0; i < invoices.length; i++) {
            total = total.add(invoices[i].getAmount());
        }/*from w  w  w  . j  av a  2 s .  c om*/
    }
    return total;
}

From source file:de.codesourcery.jasm16.compiler.Main.java

private void dumpObjectCode() {
    final byte[] combined = this.generatedObjectCode.toByteArray();

    if (ArrayUtils.isEmpty(combined)) {
        System.out.println("No object code generated.");
        return;//from w  w w  .j  av  a2  s  .  c  om
    }

    System.out.println("\nHex dump:\n\n" + Misc.toHexDumpWithAddresses(Address.byteAddress(0), combined, 8));
}

From source file:de.codesourcery.eve.apiclient.datamodel.Credentials.java

public void setKeys(APIKey[] keys) {

    this.fullAccessKey = null;
    this.limitedKey = null;

    if (!ArrayUtils.isEmpty(keys)) {
        for (APIKey k : keys) {
            setKey(k);//from   ww  w .jav a2s.c om
        }
    }
}

From source file:br.com.autonomiccs.starthost.plugin.proxies.StartHostMethodInterceptor.java

private VMEntityVO getVmEntityVoFromMethodArguments(MethodInvocation methodInvocation) {
    Object[] arguments = methodInvocation.getArguments();
    if (!ArrayUtils.isEmpty(arguments)) {
        for (Object o : arguments) {
            if (o instanceof VMEntityVO) {
                return (VMEntityVO) o;
            }//from  w ww  .jav a2s .  c  om
        }
    }
    throw new RuntimeException("Could not find VMEntityVo from method arguments");
}

From source file:nc.noumea.mairie.appock.services.impl.MailServiceImpl.java

@Override
public Message sendMail(AppockMail appockMail) throws MessagingException {

    if (CollectionUtils.isEmpty(appockMail.getListeDestinataire())) {
        log.warn("Mail non envoy, liste des destinataires vide : " + appockMail);
        return null;
    }/*  w w  w  .j  a v  a  2  s  .c  o  m*/

    MimeMessage msg = new MimeMessage(mailServer);
    msg.setFrom(appockMail.getFrom() != null ? appockMail.getFrom() : defaultFrom());

    String prefixeSujet = isModeProduction() ? "" : "[TEST APPOCK] ";
    msg.setSubject(prefixeSujet + appockMail.getSujet(), configService.getEncodageSujetEmail());

    StringBuilder infoAdditionnelle = new StringBuilder();

    for (InternetAddress adresse : appockMail.getListeDestinataire()) {
        if (isModeProduction()) {
            // on est en production, envoi rel de mail au destinataire
            msg.addRecipient(Message.RecipientType.TO, adresse);
        } else {
            // en test, on envoie le mail  la personne connecte
            InternetAddress adresseTesteur = getAdresseMailDestinataireTesteur();
            if (adresseTesteur != null) {
                msg.addRecipient(Message.RecipientType.TO, adresseTesteur);
            }
            List<String> listeAdresseMail = new ArrayList<>();
            for (InternetAddress internetAddress : appockMail.getListeDestinataire()) {
                listeAdresseMail.add(internetAddress.getAddress());
            }
            infoAdditionnelle.append("En production cet email serait envoy vers ")
                    .append(StringUtils.join(listeAdresseMail, ", ")).append("<br/><hr/>");
            break;
        }
    }

    String contenuFinal = "";
    if (!StringUtils.isBlank(infoAdditionnelle.toString())) {
        contenuFinal += "<font face=\"arial\" >" + infoAdditionnelle.toString() + "</font>";
    }

    contenuFinal += "<font face=\"arial\" >" + appockMail.getContenu() + "<br/><br/></font>"
            + configService.getPiedDeMail();

    gereBonLivraisonDansMail(appockMail, msg, contenuFinal);

    if (!ArrayUtils.isEmpty(msg.getAllRecipients())) {
        Transport.send(msg);
    }

    return msg;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getInvoiceVeaAmount() {
    BigDecimal total = new BigDecimal(0.0);
    if (!ArrayUtils.isEmpty(invoices)) {
        for (int i = 0; i < invoices.length; i++) {
            total = total.add(BigDecimalUtil.nullSafe(invoices[i].getVeaAmount()));
        }// ww  w  .  j av a2s  . co m
    }
    return total;
}

From source file:com.nec.harvest.service.impl.PettyCashServiceImpl.java

/** {@inheritDoc} */
@Override//from   w  w  w.  j  av a2s  .  c  om
public boolean deleteByRecordIds(String... recordIds) throws ServiceException {
    if (ArrayUtils.isEmpty(recordIds)) {
        throw new IllegalArgumentException("The list of petty cash's Id must not be null or empty");
    }

    final Session session = HibernateSessionManager.getSession();
    Transaction tx = null;

    boolean isDeleted = false;
    try {
        StringBuilder sql = new StringBuilder();
        sql.append(" DELETE FROM " + TblConstants.TBL_PETTY_CASH);
        sql.append(" WHERE RecID in (:recordIDs) ");

        tx = session.beginTransaction();
        Query query = pettyCashRepository.getSQLQuery(session, sql.toString()).setParameterList("recordIDs",
                recordIds);

        int deletedRecords = query.executeUpdate();
        isDeleted = deletedRecords == recordIds.length;
        tx.commit();
    } catch (Exception ex) {
        if (tx != null) {
            tx.rollback();
        }
        throw new ServiceException("Hibernate runtime exception occur when delete a list of petty cashes", ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return isDeleted;
}