List of usage examples for org.apache.commons.lang StringUtils isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
From source file:net.shopxx.service.impl.SpecificationItemServiceImpl.java
public void filter(List<SpecificationItem> specificationItems) { CollectionUtils.filter(specificationItems, new Predicate() { public boolean evaluate(Object object) { SpecificationItem specificationItem = (SpecificationItem) object; if (specificationItem == null || StringUtils.isEmpty(specificationItem.getName())) { return false; }// w w w . j ava 2 s . c o m CollectionUtils.filter(specificationItem.getEntries(), new Predicate() { private Set<Integer> idSet = new HashSet<Integer>(); private Set<String> valueSet = new HashSet<String>(); public boolean evaluate(Object object) { SpecificationItem.Entry entry = (SpecificationItem.Entry) object; return entry != null && entry.getId() != null && StringUtils.isNotEmpty(entry.getValue()) && entry.getIsSelected() != null && idSet.add(entry.getId()) && valueSet.add(entry.getValue()); } }); return CollectionUtils.isNotEmpty(specificationItem.getEntries()) && specificationItem.isSelected(); } }); }
From source file:com.mmj.app.lucene.search.cons.TimeSearchEnum.java
/** * ?name?/*w w w . j av a 2 s .c o m*/ */ public static TimeSearchEnum getEnum(String name) { if (StringUtils.isEmpty(name)) { return ALL; } for (TimeSearchEnum current : values()) { if (StringUtils.equalsIgnoreCase(current.getName(), name)) { return current; } } return ALL; }
From source file:com.ms.commons.nisa.info.ClientInfo.java
public ClientInfo(String ip, String project, String appName, String configType) { if (StringUtils.isEmpty(ip) || StringUtils.isEmpty(project) || StringUtils.isEmpty(appName) || StringUtils.isEmpty(configType)) { throw new RuntimeException( "The MinaMessage is Error! ip or appName is empty! ip=" + ip + " appName=" + appName); }//from w w w . j a v a 2 s. c o m this.ip = ip; this.project = project; this.appName = appName; this.configType = configType; }
From source file:io.udvi.amqp.mq.api.ConnectionFactory.java
/** * Initialize UdviMQ runtime with a supplied endpointId. The endpointId * allows the runtime to be distinguishable from other UdviMQ endpoints on * the same machine, and also uniquely addressable. * * @param endpointID/* w ww. j a v a2 s .c o m*/ */ public static void initialize(String endpointID) { if (endpointId == null) { if (StringUtils.isEmpty(endpointID)) { throw new IllegalArgumentException("Null EndpointID specified"); } UdviMQEndpointDriver.initialize(endpointID); endpointId = CAMQPConnectionManager.getContainerId(); } }
From source file:com.pureinfo.srm.project.action.outlay.OutlayAssginDetailDeleteAction.java
public ActionForward executeAction() throws PureException { String id = request.getParameter("id"); IOutlayAssginDetailMgr mgr = (IOutlayAssginDetailMgr) ArkContentHelper .getContentMgrOf(OutlayAssginDetail.class); if (!StringUtils.isEmpty(id)) { mgr.deleteById(StrConvertor.strToInt(id, "assginDetailId in deleteAction", 0)); }/*from ww w . j a v a 2s . co m*/ return mapping.findForward("success"); }
From source file:com.googlecode.jtiger.modules.ecside.util.ExtremeUtils.java
/** * Convert camelCase text to a readable word. example: camelCaseToWord --> * Camel Case To Word/*from w w w . ja v a 2 s . c om*/ */ public static String camelCaseToWord(String camelCaseText) { if (StringUtils.isEmpty(camelCaseText)) { return camelCaseText; } if (camelCaseText.equals(camelCaseText.toUpperCase())) { return camelCaseText; } char[] ch = camelCaseText.toCharArray(); String first = "" + ch[0]; String build = first.toUpperCase(); for (int i = 1; i < ch.length; i++) { String test = "" + ch[i]; if (test.equals(test.toUpperCase())) { build += " "; } build += test; } return build; }
From source file:com.yahoo.flowetl.core.util.EnumUtils.java
/** * Attempts to convert a string that represents an enumeration of a given * class into the actual enum object.//from w ww .j a va 2 s .c om * * @param <T> * the generic type of the enum class to use * * @param enumKlass * the enum class that has the enumerations to select from * * @param enumStr * the enum string we will attempt to match * * @param caseSensitive * whether to compare case sensitive or not * * @return the enum object or null if not found/invalid... */ @SuppressWarnings("unchecked") public static <T extends Enum> T fromString(Class<T> enumKlass, String enumStr, boolean caseSensitive) { if (StringUtils.isEmpty(enumStr) || enumKlass == null) { // not valid return null; } Object[] types = enumKlass.getEnumConstants(); if (types == null) { // not an enum return null; } Object enumInstance = null; for (int i = 0; i < types.length; i++) { enumInstance = types[i]; if (caseSensitive == false) { if (StringUtils.equalsIgnoreCase(ObjectUtils.toString(enumInstance), enumStr)) { return (T) (enumInstance); } } else { if (StringUtils.equals(ObjectUtils.toString(enumInstance), enumStr)) { return (T) (enumInstance); } } } // not found throw new IllegalArgumentException( "Unknown enumeration [" + enumStr + "] for enum class [" + enumKlass + "]"); }
From source file:net.shopxx.dao.impl.MemberDaoImpl.java
public boolean usernameExists(String username) { if (StringUtils.isEmpty(username)) { return false; }// w w w.j a va2 s . co m String jpql = "select count(*) from Member members where lower(members.username) = lower(:username)"; Long count = entityManager.createQuery(jpql, Long.class).setParameter("username", username) .getSingleResult(); return count > 0; }
From source file:net.shopxx.dao.impl.PluginConfigDaoImpl.java
public PluginConfig findByPluginId(String pluginId) { if (StringUtils.isEmpty(pluginId)) { return null; }// w w w .ja v a 2 s . co m try { String jpql = "select pluginConfig from PluginConfig pluginConfig where pluginConfig.pluginId = :pluginId"; return entityManager.createQuery(jpql, PluginConfig.class).setParameter("pluginId", pluginId) .getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:com.hangum.tadpole.engine.utils.TimeZoneUtil.java
/** * db? timezone ? ?? .//from w w w.j a v a2 s.com * * @param date * @return */ public static String dateToStr(Date date) { String dbTimeZone = GetAdminPreference.getDBTimezone(); // db? timezone . if (StringUtils.isEmpty(dbTimeZone)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); } else { // UTC . DateTime targetDateTime = new DateTime(date).withZone(DateTimeZone.forID(SessionManager.getTimezone())); String strPretty = targetDateTime.toString(prettyDateTimeFormater()); // if(logger.isDebugEnabled()) { // logger.debug(String.format("[SessionManager dbTimezone] %s => %s", SessionManager.getTimezone(), targetDateTime)); // logger.debug(String.format("[strPretty] %s", strPretty)); // logger.debug("==============================================================="); // } return strPretty; } }