List of usage examples for org.apache.commons.lang StringUtils equals
public static boolean equals(String str1, String str2)
Compares two Strings, returning true
if they are equal.
From source file:com.dp2345.service.impl.CartServiceImpl.java
public Cart getCurrent() { RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); if (requestAttributes != null) { HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); Principal principal = (Principal) request.getSession().getAttribute(Member.PRINCIPAL_ATTRIBUTE_NAME); Member member = principal != null ? memberDao.find(principal.getId()) : null; if (member != null) { Cart cart = member.getCart(); if (cart != null) { if (!cart.hasExpired()) { if (!DateUtils.isSameDay(cart.getModifyDate(), new Date())) { cart.setModifyDate(new Date()); cartDao.merge(cart); }/*from w w w . j a v a 2 s.com*/ return cart; } else { cartDao.remove(cart); } } } else { String id = WebUtils.getCookie(request, Cart.ID_COOKIE_NAME); String key = WebUtils.getCookie(request, Cart.KEY_COOKIE_NAME); if (StringUtils.isNotEmpty(id) && StringUtils.isNumeric(id) && StringUtils.isNotEmpty(key)) { Cart cart = cartDao.find(Long.valueOf(id)); if (cart != null && cart.getMember() == null && StringUtils.equals(cart.getKey(), key)) { if (!cart.hasExpired()) { if (!DateUtils.isSameDay(cart.getModifyDate(), new Date())) { cart.setModifyDate(new Date()); cartDao.merge(cart); } return cart; } else { cartDao.remove(cart); } } } } } return null; }
From source file:net.big_oh.hibernate.HibernateVOUnitTest.java
@Test public void testToString() { // output objects to console for easy diagnostics logger.info(emptyVo);//from w w w. java2 s . com logger.info(voFrankA); logger.info(voFrankB); logger.info(voAngie); assertNotNull(emptyVo.toString()); assertNotNull(voFrankA.toString()); assertNotNull(voFrankB.toString()); assertFalse(StringUtils.equals(voFrankA.toString(), voFrankB.toString())); assertFalse(StringUtils.equals(voFrankA.toString(), voAngie.toString())); assertTrue(StringUtils.equals(voFrankA.toString(), voFrankA.toString())); }
From source file:hydrograph.ui.common.util.ValidateExpressionOperation.java
/** * //from w w w. j a v a2 s . co m * validate ui expression data with external file data * * @param externalExpression * @param mappingSheetRow * @return * @throws RuntimeException */ public boolean validateUIExpressionVsJaxb(ExternalExpression externalExpression, MappingSheetRow mappingSheetRow) throws RuntimeException { Expression expression = externalExpression.getExpression(); if (expression != null) { if (!StringUtils.equals(expression.getId(), mappingSheetRow.getOperationID())) { throw new RuntimeException( mappingSheetRow.getOperationID() + "- external file is out of sync (Id mismatch)"); } if (isNotEqual(expression.getExpr(), mappingSheetRow.getExpressionEditorData().getExpression())) { throw new RuntimeException( mappingSheetRow.getOperationID() + "- external file is out of sync (Expression mismatch)"); } if (isNotEqual(expression.getMergeExpr(), mappingSheetRow.getMergeExpressionDataForGroupCombine().getExpression())) { throw new RuntimeException(mappingSheetRow.getOperationID() + "- external file is out of sync (Merge Expression mismatch)"); } if (isNotEqual(expression.getAccumulatorInitalValue(), mappingSheetRow.getAccumulator())) { throw new RuntimeException(mappingSheetRow.getOperationID() + "- external file is out of sync (Accumulator value mismatch)"); } if (!checkInputListsAreEqual(expression.getInputFields(), mappingSheetRow.getInputFields())) { throw new RuntimeException( mappingSheetRow.getOperationID() + "- external file is out of sync (Input-List mismatch)"); } if (!checkExpressionOutputListsAreEqual(expression.getOutputFields(), mappingSheetRow.getOutputList())) { throw new RuntimeException(mappingSheetRow.getOperationID() + "- external file is out of sync (Output field mismatch)"); } } return true; }
From source file:controllers.user.UserDetailApp.java
/** * ???????? ?/*from ww w . j av a 2 s . co m*/ */ private static void sortJobExpList(List<JobExp> jobExps) { Collections.sort(jobExps, new Comparator<JobExp>() { public int compare(JobExp o1, JobExp o2) { if (o1 != null && o2 != null && o1.getEndYear() != null && o2.getEndYear() != null && o1.getEndMonth() != null && o2.getEndMonth() != null) { if (StringUtils.isBlank(o2.getEndYear()) || StringUtils.equals(o2.getEndYear(), "")) { return 1; } if (StringUtils.isBlank(o1.getEndYear()) || StringUtils.equals(o1.getEndYear(), "")) { return -1; } int result = Integer.valueOf(o2.getEndYear()) - Integer.valueOf(o1.getEndYear()); if (result == 0) { if (StringUtils.isBlank(o2.getEndMonth())) { return 1; } if (StringUtils.isBlank(o1.getEndMonth())) { return -1; } int result2 = Integer.valueOf(o2.getEndMonth()) - Integer.valueOf(o1.getEndMonth()); if (result2 == 0) { int result3 = Integer.valueOf(o2.getBeginYear()) - Integer.valueOf(o1.getBeginYear()); if (result3 == 0) { return Integer.valueOf(o2.getBeginMonth()) - Integer.valueOf(o1.getBeginMonth()); } else { return result3; } } else { return result2; } } else { return result; } } return 0; } }); }
From source file:com.assemblade.server.model.Property.java
@Override public boolean requiresRename(Session session, Entry currentEntry) throws StorageException { return !StringUtils.equals(name, LdapUtils.getSingleAttributeStringValue(currentEntry.getAttribute("cn"))); }
From source file:com.vmware.bdd.usermgmt.SssdConfigurationGenerator.java
protected void load() { if (isTemplateContentEmpty()) { Map<UserMgmtServer.Type, StringBuilder> templateMap = new HashMap<>(); synchronized (templateContent) { for (UserMgmtServer.Type type : UserMgmtServer.Type.values()) { File templateFile = CommonUtil.getConfigurationFile( "usermgmt" + File.separator + SSSD_CONF_TEMPLATES + type, "sssd.conf"); HashMap<String, String> typeMap = new HashMap<>(); StringBuilder stringBuilder = new StringBuilder(); try (BufferedReader templateBufReader = new BufferedReader(new FileReader(templateFile))) { String line = templateBufReader.readLine(); boolean flag = false; while (line != null) { if (StringUtils.isNotBlank(line)) { if (!flag) { flag = StringUtils.equals(line, "[domain/LDAP]"); }//from ww w . j a va 2s .co m if (flag) { int keyValueSepIndex = line.indexOf('='); if (keyValueSepIndex != -1) { typeMap.put(line.substring(0, keyValueSepIndex).trim(), StringUtils.substring(line, keyValueSepIndex + 1).trim()); } } } stringBuilder.append(line).append('\n'); line = templateBufReader.readLine(); } } catch (FileNotFoundException fnf) { throw new UserMgmtException("SSSD_CONF_TEMPLATE_NOT_FOUND", fnf, templateFile.getAbsolutePath()); } catch (IOException ioe) { throw new UserMgmtException("SSSD_CONF_TEMPLATE_READ_ERR", ioe, templateFile.getAbsolutePath()); } templateMap.put(type, stringBuilder); mapping.put(type, typeMap); } templateContent.putAll(templateMap); } } }
From source file:com.haulmont.cuba.gui.components.AbstractAction.java
@Override public void setDescription(String description) { String oldValue = this.description; if (!StringUtils.equals(oldValue, description)) { this.description = description; firePropertyChange(PROP_DESCRIPTION, oldValue, description); }//from w w w. jav a 2s . com }
From source file:com.sfs.whichdoctor.search.http.GroupInputHandler.java
/** * Process the incoming HttpRequest for search parameters. * * @param request the request//w ww .jav a2 s .c o m * @param user the user * * @return the search bean */ public final SearchBean process(final HttpServletRequest request, final UserBean user) { SearchBean search = groupSqlHandler.initiate(user); GroupBean searchCriteria = (GroupBean) search.getSearchCriteria(); GroupBean searchConstraints = (GroupBean) search.getSearchConstraints(); String name = DataFilter.getHtml(request.getParameter("name")); String groupClass = DataFilter.getHtml(request.getParameter("groupClass")); String groupType = DataFilter.getHtml(request.getParameter("groupType")); String description = DataFilter.getHtml(request.getParameter("description")); String strGUIDList = DataFilter.getHtml(request.getParameter("guidList")); String strIncludeGUIDList = DataFilter.getHtml(request.getParameter("includeGUIDList")); String strCreatedA = DataFilter.getHtml(request.getParameter("createdA")); String strCreatedB = DataFilter.getHtml(request.getParameter("createdB")); String strUpdatedA = DataFilter.getHtml(request.getParameter("updatedA")); String strUpdatedB = DataFilter.getHtml(request.getParameter("updatedB")); try { searchCriteria.setName(DataFilter.getHtml(name.trim())); } catch (Exception e) { dataLogger.debug("Error parsing Name: " + e.getMessage()); } /* Tag searches */ searchCriteria.setTags(setTagArray(request, user)); if (StringUtils.isNotBlank(groupClass) && !StringUtils.equals(groupClass, "Null")) { searchCriteria.setObjectType(groupClass); } if (StringUtils.isNotBlank(groupType) && !StringUtils.equals(groupType, "Null")) { searchCriteria.setType(groupType); } searchCriteria.setDescription(description); if (StringUtils.isNotBlank(strGUIDList)) { // Parse the GUID list string into a collection of strings searchCriteria.setGUIDList(DataFilter.parseTextDataToCollection(strGUIDList)); } if (StringUtils.isNotBlank(strIncludeGUIDList)) { // Parse the GUID list string into a collection of strings searchCriteria.setIncludeGUIDList(DataFilter.parseTextDataToCollection(strIncludeGUIDList)); } if (StringUtils.isNotBlank(strCreatedA)) { searchCriteria.setCreatedDate(DataFilter.parseDate(strCreatedA, false)); } if (StringUtils.isNotBlank(strCreatedB)) { searchConstraints.setCreatedDate(DataFilter.parseDate(strCreatedB, false)); if (strCreatedB.compareTo("+") == 0) { /* All dates above Date A requested */ searchConstraints.setCreatedDate(getMaximumDate()); } if (strCreatedB.compareTo("-") == 0) { /* Add dates below Date A requested */ searchConstraints.setCreatedDate(getMinimumDate()); } } if (StringUtils.isNotBlank(strUpdatedA)) { searchCriteria.setModifiedDate(DataFilter.parseDate(strUpdatedA, false)); } if (StringUtils.isNotBlank(strUpdatedB)) { searchConstraints.setModifiedDate(DataFilter.parseDate(strUpdatedB, false)); if (strUpdatedB.compareTo("+") == 0) { /* All dates above Date A requested */ searchConstraints.setModifiedDate(getMaximumDate()); } if (strUpdatedB.compareTo("-") == 0) { /* Add dates below Date A requested */ searchConstraints.setModifiedDate(getMinimumDate()); } } search.setSearchCriteria(searchCriteria); search.setSearchConstraints(searchConstraints); return search; }
From source file:AIR.Common.Web.Session.CookieHolder.java
@Override public boolean remove(Object cookie) { if (cookie instanceof MultiValueCookie) { for (int counter1 = 0; counter1 < this.size(); ++counter1) { MultiValueCookie existing = this.get(counter1); if (StringUtils.equals(existing.getName(), ((MultiValueCookie) cookie).getName())) { this.remove(counter1); return true; }//from w ww. j a va 2 s . c o m } } return false; }
From source file:com.prowidesoftware.swift.model.SwiftServiceId.java
/** * Tell if name is a valid service id, true if it is, and false in any other * case. This method is null-safe.//from w w w. j av a 2 s. c o m * * @param name * the name to test as service id, may be <code>null</code> * @return <code>true</code> if the parameter name is a valid service id * @since 6.0 */ @SuppressWarnings("unchecked") public static boolean contains(String name) { if (StringUtils.isNotEmpty(name)) { List values = getEnumList(SwiftServiceId.class); for (int i = 0; i < values.size(); i++) { if (StringUtils.equals(((Enum) values.get(i)).getName(), name)) { return true; } } } return false; }