List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2)
Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
null s are handled without exceptions.
From source file:edu.umn.se.trap.rule.businessrule.TravelTypeMatchesGrantRule.java
/** * @param grants/* w w w.j a v a2 s . c o m*/ * @param trip * @throws TrapException */ protected void checkExportGrantCitizen(Set<FormGrant> grants, Trip trip) throws TrapException { boolean cseSponsored = trip.isTravelTypeCseSponsored(); boolean dtcSponsored = trip.isTravelTypeDtcSponsored(); boolean nonSponsored = trip.isTravelTypeNonsponsored(); /* * Iterate over the set and throw an error if any of the grants are * non-export. */ Iterator<FormGrant> grantIter = grants.iterator(); while (grantIter.hasNext()) { FormGrant grant = grantIter.next(); if (StringUtils.equalsIgnoreCase(grant.getAccountType(), "Sponsored")) { // Throw an error if the grant is not sponsored by Dtc or Cse. if (!(cseSponsored || dtcSponsored)) { throw new TrapException( "A trip must be sponsored by Dtc or CSE to charge to a sponsored grant."); } } else if (StringUtils.equalsIgnoreCase(grant.getAccountType(), "Non-sponsored")) { // Throw an error if the trip is sponsored and trying to charge // to a non-sponsored grant. if (!nonSponsored) { throw new TrapException(TrapErrors.NON_SPONSORED); } } } checkForGrantType("non-sponsored", trip.isTravelTypeNonsponsored(), grants); checkForGrantType("sponsored", trip.isTravelTypeCseSponsored() || trip.isTravelTypeDtcSponsored(), grants); }
From source file:com.threewks.thundr.http.ContentType.java
public static boolean matchesAny(String contentType, Iterable<ContentType> types) { contentType = cleanContentType(contentType); for (ContentType supported : types) { if (StringUtils.equalsIgnoreCase(supported.value, contentType)) { return true; }//from w w w. jav a2s .co m } return false; }
From source file:com.hybris.mobile.lib.commerce.data.order.CartModification.java
public boolean isQuantityAddedNotFulfilled() { return StringUtils.equalsIgnoreCase(statusCode, StockLevelEnum.LOW_STOCK.getStatus()); }
From source file:edu.umn.se.trap.rule.grantrule.SponsoredNoAlcoholRule.java
/** * @param expense/*from w w w . j a va 2s . c o m*/ * @throws TrapException */ private void checkSponsoredAlcohol(Expense expense) throws TrapException { /* * Check to make sure the expense is an other expense. */ if (expense.getType().equals(ExpenseType.OTHER)) { /* * Try to match "alcohol" in the justification field. */ Pattern alcoholPattern = Pattern.compile(alcoholRegex, Pattern.CASE_INSENSITIVE); Matcher alcoholMatcher = alcoholPattern.matcher(expense.getJustification()); // If alcohol is found, check the grants. if (alcoholMatcher.find()) { GrantSet grantSet = expense.getEligibleGrants(); if (grantSet == null) { throw new TrapException("Invalid TrapForm object: grantSet was null."); } Set<FormGrant> grants = grantSet.getGrants(); if (grants == null) { throw new TrapException("Invalid TrapForm object: grants was null."); } Iterator<FormGrant> grantIter = grants.iterator(); while (grantIter.hasNext()) { FormGrant grant = grantIter.next(); if (StringUtils.equalsIgnoreCase(grant.getAccountType(), "Sponsored")) { // Remove the grant if it is a sponsored grant trying to // cover alcohol. grantSet.removeGrant(grant.getAccountName()); } } } } }
From source file:hammingcode.HammingCode.java
String addCheckBits(String str, String parity) { String codeWord = ""; double noOfCheckBits = Math.log(str.length()); noOfCheckBits /= Math.log(2); noOfCheckBits++;/*w ww . j ava 2 s . c o m*/ for (int i = 0, j = 1; j <= str.length() + noOfCheckBits; j++) { if ((j & (j - 1)) == 0) { codeWord += "0"; } else { codeWord += str.charAt(i); i++; } } str = codeWord; codeWord = ""; for (int i = 0, j = 1; j <= str.length() + noOfCheckBits; j++) { if ((j & (j - 1)) == 0) { if (StringUtils.equalsIgnoreCase(parity, "even")) { if (StringUtils.countMatches(takeNthPower(str, j), "1") % 2 == 0) { codeWord += "0"; } else { codeWord += "1"; } } else if (StringUtils.equalsIgnoreCase(parity, "odd")) { if (StringUtils.countMatches(takeNthPower(str, j), "1") % 2 == 0) { codeWord += "1"; } else { codeWord += "0"; } } } else { codeWord += str.charAt(i); i++; } } return codeWord; }
From source file:edu.sabanciuniv.sentilab.utils.text.nlp.base.PosTag.java
/** * Checks if this POS tag belongs to one of the given type or not. * @param tags the {@link Iterable} of tag strings. * @return {@code true} if this POS tag is one of the given types; {@code false} otherwise. *///w w w .j a va 2s .c o m public boolean is(Iterable<String> tags) { if (tags == null) { return true; } for (String tag : tags) { if (StringUtils.equalsIgnoreCase(tag, this.getSimpleTag()) || StringUtils.equalsIgnoreCase(tag, this.getTag())) { return true; } } return false; }
From source file:com.sap.csc.poc.ems.persistence.initial.entitlement.EntitlementItemAttributeDataInitializer.java
public EntitlementItemAttribute getByName(String name) { return get().stream().filter(type -> StringUtils.equalsIgnoreCase(type.getName(), name)).findFirst().get(); }
From source file:edu.umn.se.trap.rule.grantrule.SponsoredNoInternetRule.java
/** * @param expense// w w w . j a v a 2 s. c o m * @throws TrapException */ private void checkSponsoredInternet(Expense expense) throws TrapException { /* * Check to make sure the expense is an other expense. */ if (expense.getType().equals(ExpenseType.OTHER)) { /* * Try to match "internet" or "wifi" in the justification field. */ Pattern alcoholPattern = Pattern.compile(internetRegex, Pattern.CASE_INSENSITIVE); Matcher alcoholMatcher = alcoholPattern.matcher(expense.getJustification()); // If internet is found, check the grants. if (alcoholMatcher.find()) { GrantSet grantSet = expense.getEligibleGrants(); if (grantSet == null) { throw new TrapException("Invalid TrapForm object: grantSet was null."); } Set<FormGrant> grants = grantSet.getGrants(); if (grants == null) { throw new TrapException("Invalid TrapForm object: grants was null."); } Iterator<FormGrant> grantIter = grants.iterator(); while (grantIter.hasNext()) { FormGrant grant = grantIter.next(); if (StringUtils.equalsIgnoreCase(grant.getAccountType(), "Sponsored")) { // Remove the grant if it is a sponsored grant trying to // cover internet. grantSet.removeGrant(grant.getAccountName()); } } } } }
From source file:io.cloudslang.content.database.utils.SQLUtils.java
/** * Some databases (Sybase) throw exceptions during a database dump. This function processes that exception, and if it is that type, builds up the output of the command * * @param sqlException The exception to analyze * @return The output of the dump command * @throws java.sql.SQLException If it was not a successful dump command's exception. *//*from w w w . j av a2 s . c o m*/ public static String processDumpException(SQLException sqlException) throws SQLException { final String sqlState = sqlException.getSQLState(); if (sqlState != null && StringUtils.equalsIgnoreCase(sqlState, "s1000")) { SQLException f = sqlException; StringBuilder s = new StringBuilder(); s.append(f.getMessage()); while ((f = f.getNextException()) != null) { s.append("\n").append(f.getMessage()); } String str = s.toString(); if (StringUtils.containsIgnoreCase(str, "dump is complete")) return str; } throw sqlException; }
From source file:com.sap.csc.poc.ems.persistence.initial.entitlement.EntitlementHeaderAttributeDataInitializer.java
public EntitlementHeaderAttribute getByName(String name) { return get().stream().filter(type -> StringUtils.equalsIgnoreCase(type.getName(), name)).findFirst().get(); }