List of usage examples for org.apache.commons.lang ArrayUtils isEmpty
public static boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null
.
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public Invoice[] getDistinctLicPlates() { if (!ArrayUtils.isEmpty(invoices)) { HashMap veaLicPlatesMap = new HashMap(); for (int i = 0; i < invoices.length; i++) { veaLicPlatesMap.put(invoices[i].getLicPlateNumber() + invoices[i].getLicPlateState(), invoices[i]); }// www . j av a2 s . c o m return (Invoice[]) veaLicPlatesMap.values().toArray(new Invoice[0]); } return null; }
From source file:edu.cornell.med.icb.goby.modes.SampleQualityScoresMode.java
/** * Process ONE compact-reads file.//from ww w . j a v a 2 s . co m * @param inputFilename the filename to process * @return the number of read entries processed * @throws IOException error reading file */ private int processCompactReadsFile(final String inputFilename) throws IOException { // Create directory for output file if it doesn't already exist int i = 0; for (final Reads.ReadEntry entry : new ReadsReader(inputFilename)) { final byte[] qualityScores = entry.getQualityScores().toByteArray(); final boolean hasQualityScores = entry.hasQualityScores() && !ArrayUtils.isEmpty(qualityScores); if (hasQualityScores) { qualityScoresFound = true; for (final int qualScore : qualityScores) { minQualScore = Math.min(qualScore, minQualScore); maxQualScore = Math.max(qualScore, maxQualScore); numQualScoresSampled++; sumQualScores += Math.abs(qualScore); } if (++i == numberOfReadEntriesToProcess) { break; } } } return i; }
From source file:com.etcc.csc.presentation.action.payment.InitializePaymentAction.java
private void processVea(PaymentContext paymentContext, AccountLoginDTO accountLoginDTO, String docType, long docId) throws Exception { Invoice[] distinctLicPlates = paymentContext.getDistinctLicPlates(); PaymentInterface pi = (PaymentInterface) DelegateFactory.create(DelegateEnum.PAYMENT_DELEGATE); ArrayList veaEligibleLicPlates = new ArrayList(); if (!ArrayUtils.isEmpty(distinctLicPlates)) { for (Invoice invoice : distinctLicPlates) { if (pi.veaExists(new BigDecimal(docId), docType, accountLoginDTO.getDbSessionId(), accountLoginDTO.getLastLoginIp(), accountLoginDTO.getLoginId(), invoice.getLicPlateNumber(), invoice.getLicPlateState())) { veaEligibleLicPlates.add(invoice.getLicPlateNumber() + invoice.getLicPlateState()); }//from w w w . j av a2 s .com } } Invoice[] invoices = paymentContext.getInvoices(); for (int i = 0; !ArrayUtils.isEmpty(invoices) && i < invoices.length; i++) { invoices[i].setVeaEligible(veaEligibleLicPlates .contains(invoices[i].getLicPlateNumber() + invoices[i].getLicPlateState())); } }
From source file:com.fiveamsolutions.nci.commons.mojo.copywebfiles.CopyWebFilesMojo.java
/** * @return//from ww w. j a v a 2 s. com * @throws MojoExecutionException */ private Collection<File> getLatestDeploymentDirectories() throws MojoExecutionException { Set<File> matchSet = new HashSet<File>(); File latestDeployDirectory = deployDirectory; if (StringUtils.isNotEmpty(deployDirectoryPattern)) { IOFileFilter fileFilter = new WildcardFileFilter(deployDirectoryPattern); fileFilter = FileFilterUtils.andFileFilter(DirectoryFileFilter.DIRECTORY, fileFilter); File[] matches = deployDirectory.listFiles((FileFilter) fileFilter); if (ArrayUtils.isEmpty(matches)) { throw new MojoExecutionException("No directories found that match the given pattern"); } latestDeployDirectory = matches[0]; for (File match : matches) { if (match.lastModified() > latestDeployDirectory.lastModified()) { latestDeployDirectory = match; } if (copyToAllMatches) { matchSet.add(match); } } } matchSet.add(latestDeployDirectory); return appendSubDirectory(matchSet); }
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public Invoice[] getAuthorizedInvoices() { if (!ArrayUtils.isEmpty(invoices)) { ArrayList list = new ArrayList(); for (int i = 0; i < invoices.length; i++) { if (invoices[i].isAuthorized()) { list.add(invoices[i]);/*from www .j av a 2s . c o m*/ } } if (!list.isEmpty()) { return (Invoice[]) list.toArray(new Invoice[0]); } } return null; }
From source file:com.pedra.core.setup.CoreSystemSetup.java
private File getProjectdataUpdateDirectory(String relativeUpdateDirectory) { if (relativeUpdateDirectory == null) { relativeUpdateDirectory = ""; }//from ww w. j a va2 s .c o m String projectdataUpdateFolderProperty = Config.getString("projectdata.update.folder", "/pedracore/import/versions"); projectdataUpdateFolderProperty = projectdataUpdateFolderProperty + relativeUpdateDirectory; File projectdataUpdateFolder = null; try { projectdataUpdateFolder = new File(getClass().getResource(projectdataUpdateFolderProperty).toURI()); } catch (final URISyntaxException e) { Log.error("error finding project data update directory[" + projectdataUpdateFolderProperty + "]", e); return null; } if (!projectdataUpdateFolder.exists()) { Log.warn("project data update directory [" + projectdataUpdateFolderProperty + "] does not exist"); return null; } else if (ArrayUtils.isEmpty(projectdataUpdateFolder.listFiles())) { Log.info("Project datad update directory[" + projectdataUpdateFolderProperty + "] is empty"); } return projectdataUpdateFolder; }
From source file:de.codesourcery.eve.apiclient.HttpAPIClient.java
@Override public APIResponse<Map<String, String>> resolveNames(EntityType[] types, String[] ids, RequestOptions options) throws APIUnavailableException, APIErrorException { if (ArrayUtils.isEmpty(types)) { throw new IllegalArgumentException("entity type(s) cannot be NULL/empty"); }/* w w w .j a v a 2s . c o m*/ if (ids == null) { throw new IllegalArgumentException("ids cannot be NULL"); } final Set<EntityType> typeSet = new HashSet<EntityType>(); for (EntityType t : types) { typeSet.add(t); } final ResolveNamesParser parser = new ResolveNamesParser(ids, typeSet, getSystemClock()); final Map<String, Object> params = new HashMap<String, Object>(); // make sure we don't transmit duplicate IDs final Set<String> idSet = new HashSet<String>(); for (String id : ids) { if (id == null) { throw new IllegalArgumentException("NULL element in ID array ?"); } idSet.add(id.replaceAll(" ", "")); // get rid of all spaces } final StringBuilder builder = new StringBuilder(); for (Iterator<String> it = idSet.iterator(); it.hasNext();) { final String id = it.next(); builder.append(id); if (it.hasNext()) { builder.append(','); } } params.put("ids", builder.toString()); final InternalAPIResponse response = sendRequest(null, parser, params, // request // parameters KeyRole.NONE_REQUIRED, // no API key required options); return new APIResponse<Map<String, String>>(response, parser.getResult(), getSystemClock()); }
From source file:com.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java
/** {@inheritDoc} */ @Override/*from ww w . j a v a2 s . c o m*/ public Map<String, BudgetPerformanceBean> findByOrgCodesAndMonthAndKmkCodeJs(String month, String[] orgCodes, String... kmkCodeJs) throws ServiceException { if (StringUtils.isEmpty(month)) { throw new IllegalArgumentException("Can not find budget performance with given month is empty"); } if (ArrayUtils.isEmpty(orgCodes)) { throw new IllegalArgumentException( "Can not find budget performance with given organization code array is null"); } if (ArrayUtils.isEmpty(kmkCodeJs)) { throw new IllegalArgumentException( "Can not find budget performance with given kmkCodeJs array is null"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; Map<String, BudgetPerformanceBean> mapBudgetPerformances = new HashMap<String, BudgetPerformanceBean>(); try { tx = session.beginTransaction(); StringBuilder sql = new StringBuilder( "SELECT KmkCodeJ as kmkCodeJ, SUM(YosanKingaku) as yosanKingaku, SUM(JisekiKingaku) as jisekiKingaku "); sql.append(" FROM " + TblConstants.TBL_BUDGET_PERFORMANCE); sql.append(" WHERE StrCode IN (:orgCodes) "); sql.append(" AND GetSudo = :month "); sql.append(" AND KmkCodeJ IN (:kmkCodeJs) "); sql.append(" AND DelKbn = 2 "); sql.append(" GROUP BY Getsudo, KmkCodeJ"); Query query = repository.getSQLQuery(session, sql.toString()); query.setParameterList("orgCodes", orgCodes); query.setString("month", month); query.setParameterList("kmkCodeJs", kmkCodeJs); query.setResultTransformer(Transformers.aliasToBean(BudgetPerformanceBean.class)); List<BudgetPerformanceBean> budgetPerformances = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(budgetPerformances)) { throw new ObjectNotFoundException("No budget performance object found"); } for (BudgetPerformanceBean budgetPerformance : budgetPerformances) { mapBudgetPerformances.put(budgetPerformance.getKmkCodeJ(), budgetPerformance); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException( "Runtime exception occur when get a map of budget performance objects with given organization codes, kmkCodeJs and month", ex); } finally { HibernateSessionManager.closeSession(session); } return mapBudgetPerformances; }
From source file:com.nec.harvest.service.impl.PettyCashServiceImpl.java
/** {@inheritDoc} */ @Override/*from w w w .j a va 2 s . co m*/ public List<PettyCash> findUpdateNoById(String... recIDs) throws ServiceException { if (ArrayUtils.isEmpty(recIDs)) { throw new IllegalArgumentException("To get petty cash update number, its record id must not be empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<PettyCash> pettyCashes = new ArrayList<PettyCash>(); try { tx = session.beginTransaction(); Query query = pettyCashRepository .getSQLQuery(session, " SELECT UpdNo FROM AT009 WHERE RecID in (:recIDs) AND DelKbn=2 ") .setParameterList("recIDs", recIDs); pettyCashes = pettyCashRepository.findByQuery(query); tx.commit(); } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("Hibernate runtime exception when get update no of petty cash list ", ex); } finally { HibernateSessionManager.closeSession(session); } return pettyCashes; }
From source file:com.dianping.wed.cache.redis.biz.WeddingRedisServiceImpl.java
@Override public long sAdd(WeddingRedisKeyDTO redisKey, final String... members) { if (ArrayUtils.isEmpty(members)) { return 0; }// w ww .ja v a 2 s. c o m final String finalKey = wcsWeddingRedisKeyCfgService.generateKey(redisKey); return JedisHelper.doJedisOperation(new JedisCallback<Long>() { @Override public Long doWithJedis(Jedis jedis) { return jedis.sadd(finalKey, members); } }, finalKey, RedisActionType.WRITE); }