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.oneops.util.SearchSenderTest.java
private void assertMessages(MessageData[] expected, MessageData[] actual) { if (ArrayUtils.isEmpty(expected) && ArrayUtils.isEmpty(actual)) return;/* www. j av a 2 s. c om*/ if (ArrayUtils.isEmpty(expected) || ArrayUtils.isEmpty(actual) || expected.length != actual.length) { Assert.fail("expected and actual array lengths are not matching"); } else { Map<String, MessageData> expectedMap = new HashMap<String, MessageData>(expected.length); for (MessageData data : expected) { expectedMap.put(data.getPayload(), data); } for (MessageData data : actual) { MessageData matching = expectedMap.get(data.getPayload()); Assert.assertNotNull(matching); Assert.assertEquals(matching.getHeaders(), data.getHeaders()); } } }
From source file:com.lxht.emos.data.cache.intf.HessianUtil.java
/** * ??./* w w w .j a v a 2s .c o m*/ * * @param strArray * @return */ public static final byte[][] strArrayToByteArray(String[] strArray) { if (ArrayUtils.isEmpty(strArray)) { throw new NullPointerException(); } byte[][] bytes = new byte[strArray.length][]; int i = 0; for (String str : strArray) { bytes[i] = str.getBytes(); i++; } return bytes; }
From source file:com.nec.harvest.service.impl.MoveTransferServiceImpl.java
/** {@inheritDoc} */ @Override//from ww w. j ava 2s . co m public boolean deleteByIDs(String... Ids) throws ServiceException { if (ArrayUtils.isEmpty(Ids)) { throw new IllegalArgumentException("Array movetransfer must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; boolean isDeleted = false; try { tx = session.beginTransaction(); String sql = " DELETE FROM MoveTransfer a WHERE a.delKbn = :delKbn AND a.recID IN (:recIDs) "; Query query = repository.getQuery(session, sql).setParameterList("recIDs", Ids).setParameter("delKbn", Constants.STATUS_ACTIVE); isDeleted = (query.executeUpdate() > 0); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An error occurred while delete MoveTransfer list"); } finally { HibernateSessionManager.closeSession(session); } return isDeleted; }
From source file:cn.fastmc.core.utils.ReflectionUtils.java
/** * ?DeclaredField,?.// ww w .jav a 2 s .c o m * * @param targetClass * Class * @param ignoreParent * ??,?Field * * @return List */ public static List<Field> getAccessibleFields(final Class targetClass, final boolean ignoreParent) { Assert.notNull(targetClass, "targetClass?"); List<Field> fields = new ArrayList<Field>(); Class<?> sc = targetClass; do { Field[] result = sc.getDeclaredFields(); if (!ArrayUtils.isEmpty(result)) { for (Field field : result) { field.setAccessible(true); } CollectionUtils.addAll(fields, result); } sc = sc.getSuperclass(); } while (sc != Object.class && !ignoreParent); return fields; }
From source file:com.hs.mail.imap.dao.MySqlMessageDao.java
private int setSystemFlags(long messageID, Flags.Flag[] flags, boolean replace, boolean set) { if (ArrayUtils.isEmpty(flags)) { return 0; }//from w w w . j a v a 2 s .c om StringBuilder sql = new StringBuilder("UPDATE message SET "); List params = new ArrayList(); sql.append(FlagUtils.buildParams(flags, replace, set, params)); if (params.isEmpty()) { return 0; } sql.append(" WHERE messageid = ?"); params.add(new Long(messageID)); return getJdbcTemplate().update(sql.toString(), params.toArray()); }
From source file:com.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java
/** {@inheritDoc} */ @Override/* w ww .j av a2s. c o m*/ public Map<String, BudgetPerformance> findByOrgCodeAndStartMonthEndMonthAndKmkCodeJs(String orgCode, String startMonth, String endMonth, String... kmkCodeJs) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException( "Organization code or current month in acton must not be null or empty"); } if (StringUtils.isEmpty(startMonth)) { throw new IllegalArgumentException("Start month must not be null or empty"); } if (StringUtils.isEmpty(endMonth)) { throw new IllegalArgumentException("End month month must not be null or empty"); } if (ArrayUtils.isEmpty(kmkCodeJs)) { throw new IllegalArgumentException("KmkCodeJs must not be null"); } // logger.info("Find by organization code:" + orgCode + " startMonth " + startMonth + " endMonth " + endMonth + "kmkcodej " + StringUtils.join(kmkCodeJs, ",")); final Session session = HibernateSessionManager.getSession(); Transaction tx = null; Map<String, BudgetPerformance> mapBudgetPerformances = new HashMap<String, BudgetPerformance>(); try { tx = session.beginTransaction(); Criterion criterion = Restrictions.and(Restrictions.eq("pk.organization.strCode", orgCode), Restrictions.and(Restrictions.ge("pk.getSudo", startMonth), Restrictions.and(Restrictions.le("pk.getSudo", endMonth), Restrictions.and(Restrictions.in("pk.kmkCodeJ", kmkCodeJs), Restrictions.eq("delKbn", Constants.STATUS_ACTIVE))))); Criteria crit = session.createCriteria(BudgetPerformance.class); crit.add(criterion); List<BudgetPerformance> budgetPerformances = repository.findByCriteria(crit); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(budgetPerformances)) { throw new ObjectNotFoundException("There is no the budget performance object"); } mapBudgetPerformances = new HashMap<String, BudgetPerformance>(); for (BudgetPerformance budgetPerformance : budgetPerformances) { mapBudgetPerformances.put( budgetPerformance.getPk().getGetSudo() + budgetPerformance.getPk().getKmkCodeJ(), budgetPerformance); } } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException( "An exception occured while get budget performance data by organization code " + orgCode, ex); } finally { HibernateSessionManager.closeSession(session); } return mapBudgetPerformances; }
From source file:com.fiveamsolutions.nci.commons.search.SearchCallback.java
private void validateSettings(SearchOptions searchOptions, Object result) { boolean isCollection = result instanceof Collection<?>; boolean isPersistentObject = result instanceof PersistentObject; if (!ArrayUtils.isEmpty(searchOptions.getFields()) && searchOptions.isNested()) { throw new IllegalArgumentException("Both fields and nested cannot be set at the same time."); }/* w w w.j a va2s . com*/ validateIsHibernateComponentSetting(searchOptions.isHibernateComponent(), ArrayUtils.isEmpty(searchOptions.getFields()), isCollection, isPersistentObject); }
From source file:com.norconex.collector.http.crawler.HttpCrawlerConfigLoader.java
private static <T> T[] defaultIfEmpty(T[] array, T[] defaultArray) { if (ArrayUtils.isEmpty(array)) { return defaultArray; }/*w w w . j ava2 s.c o m*/ return array; }
From source file:com.photon.phresco.util.ProjectUtils.java
public ProjectInfo getProjectInfo(File baseDir) throws PhrescoException { ProjectInfo projectinfo = null;/*from ww w .j a v a 2 s. c om*/ Gson gson = new Gson(); BufferedReader reader = null; try { File[] dotPhrescoFolders = baseDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); if (!ArrayUtils.isEmpty(dotPhrescoFolders)) { for (File dotPhrescoFolder : dotPhrescoFolders) { File[] dotProjectFiles = dotPhrescoFolder .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); for (File dotProjectFile : dotProjectFiles) { reader = new BufferedReader(new FileReader(dotProjectFile)); projectinfo = gson.fromJson(reader, ProjectInfo.class); } } } } catch (JsonSyntaxException e) { throw new PhrescoException(e); } catch (JsonIOException e) { throw new PhrescoException(e); } catch (FileNotFoundException e) { throw new PhrescoException(e); } finally { Utility.closeReader(reader); } return projectinfo; }
From source file:com.fiveamsolutions.nci.commons.search.OneCriterionSpecifiedCallback.java
private void checkCollectionResultForCriteria(Collection<?> col, String[] fields, boolean nested) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (!col.isEmpty()) { if (!ArrayUtils.isEmpty(fields)) { processCollectionProperties(fields, col, col.iterator().next().getClass()); } else if (nested) { for (Object obj : col) { SearchableUtils.iterateAnnotatedMethods(obj, this); }//w w w. ja v a 2 s.c om } } }