List of usage examples for org.apache.commons.lang ArrayUtils contains
public static boolean contains(boolean[] array, boolean valueToFind)
Checks if the value is in the given array.
From source file:com.linkedin.pinot.core.predicate.NoDictionaryEqualsPredicateEvaluatorsTest.java
@Test public void testLongPredicateEvaluators() { long longValue = _random.nextLong(); EqPredicate eqPredicate = new EqPredicate(COLUMN_NAME, Collections.singletonList(Long.toString(longValue))); PredicateEvaluator eqPredicateEvaluator = EqualsPredicateEvaluatorFactory .newNoDictionaryBasedEvaluator(eqPredicate, FieldSpec.DataType.LONG); NEqPredicate neqPredicate = new NEqPredicate(COLUMN_NAME, Collections.singletonList(Long.toString(longValue))); PredicateEvaluator neqPredicateEvaluator = NotEqualsPredicateEvaluatorFactory .newNoDictionaryBasedEvaluator(neqPredicate, FieldSpec.DataType.LONG); Assert.assertTrue(eqPredicateEvaluator.apply(longValue)); Assert.assertFalse(neqPredicateEvaluator.apply(longValue)); long[] randomLongs = new long[NUM_MULTI_VALUES]; PredicateEvaluatorTestUtils.fillRandom(randomLongs); randomLongs[_random.nextInt(randomLongs.length)] = longValue; Assert.assertTrue(eqPredicateEvaluator.apply(randomLongs)); Assert.assertFalse(neqPredicateEvaluator.apply(randomLongs)); for (int i = 0; i < 100; i++) { long random = _random.nextLong(); Assert.assertEquals(eqPredicateEvaluator.apply(random), (random == longValue)); Assert.assertEquals(neqPredicateEvaluator.apply(random), (random != longValue)); PredicateEvaluatorTestUtils.fillRandom(randomLongs); Assert.assertEquals(eqPredicateEvaluator.apply(randomLongs), ArrayUtils.contains(randomLongs, longValue)); Assert.assertEquals(neqPredicateEvaluator.apply(randomLongs), !ArrayUtils.contains(randomLongs, longValue)); }// www . j a va2 s .c o m }
From source file:com.excilys.soja.core.handler.StompFrameDecoder.java
private boolean isValidCommand(String command) { return command != null && ArrayUtils.contains(VALID_COMMANDS, command); }
From source file:com.legstar.jaxb.plugin.CobolJAXBAnnotator.java
/** * {@inheritDoc} . Since we have no direct way of communicating with the * annotator, we pass options as extra XJC command line parameters. */// w w w. jav a 2s .c o m @Override public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException { String arg = args[i]; // NameConverters can be set only once so we do it on the first argument if (arg.equals("-" + OPTION_NAME)) { if (ArrayUtils.contains(args, "-eci")) { opt.setNameConverter(new EciCompatibleNameConverter(), this); } else { opt.setNameConverter(new WinCompatibleNameConverter(), this); } } // Tell XJC we consumed this option which is legstar specific if (arg.equals("-eci")) { isEciCompatible = true; return 1; } return 0; }
From source file:com.adobe.acs.commons.users.impl.Ace.java
protected void validate(String type, String path, List<String> privilegeNames) throws EnsureAuthorizableException { if (!ArrayUtils.contains(new String[] { "allow", "deny" }, type)) { throw new EnsureAuthorizableException( "Ensure Service User requires valid type. [ " + type + " ] type is invalid"); } else if (!StringUtils.startsWith(path, "/")) { throw new EnsureAuthorizableException( "Ensure Service User requires an absolute path. [ " + path + " ] path is invalid"); } else if (privilegeNames.size() < 1) { throw new EnsureAuthorizableException("Ensure Service User requires at least 1 privilege to apply."); }//from ww w.j a v a 2 s.co m }
From source file:com.adobe.acs.tools.hc.impl.ComponentIconHealthCheck.java
private boolean isPageType(Component component) { if (component == null) { return false; } else if (ArrayUtils.contains(pageTypes, component.getResourceType())) { return true; } else {/*from w w w . ja v a 2s . c o m*/ return isPageType(component.getSuperComponent()); } }
From source file:com.excilys.soja.core.handler.StompFrameDecoder.java
private boolean isExpectedBody(String command) { return command != null && ArrayUtils.contains(COMMANDS_WITH_BODY, command); }
From source file:gov.nih.nci.cabig.caaers.service.UnreportedSAENotificationProcessService.java
@Transactional public void process() { // get all the distinct report definitions List<ReportDefinition> rds = adverseEventRecommendedReportDao.getAllRecommendedReportsNotReported(); // get planned notifications associated with the report definitions for (ReportDefinition rd1 : rds) { for (PlannedNotification plannedNotification : rd1.getUnreportedAePlannedNotification()) { Set<String> contactBasedEmailAddresses = new HashSet<String>(); //find emails of direct recipients if (CollectionUtils.isNotEmpty(plannedNotification.getContactMechanismBasedRecipients())) { for (ContactMechanismBasedRecipient recipient : plannedNotification .getContactMechanismBasedRecipients()) { String contact = recipient.getContact(); if (GenericValidator.isEmail(contact)) contactBasedEmailAddresses.add(contact); }/*from ww w . j a v a 2 s. c om*/ } //now process the notifications. PlannedEmailNotification plannedemailNotification = (PlannedEmailNotification) plannedNotification; String rawSubjectLine = plannedemailNotification.getSubjectLine(); String rawBody = plannedNotification.getNotificationBodyContent().getBody(); Integer dayOfNotification = plannedemailNotification.getIndexOnTimeScale(); List<AdverseEventRecommendedReport> aeRecomReports = adverseEventRecommendedReportDao .getAllAdverseEventsGivenReportDefinition(rd1); for (AdverseEventRecommendedReport aeRecomReport : aeRecomReports) { Set<String> roleBasedEmailAddresses = new HashSet<String>(); Study study = aeRecomReport.getAdverseEvent().getReportingPeriod().getStudy(); StudySite studySite = aeRecomReport.getAdverseEvent().getReportingPeriod().getStudySite(); //find emails of role recipients List<RoleBasedRecipient> roleRecipients = plannedNotification.getRoleBasedRecipients(); if (CollectionUtils.isNotEmpty(roleRecipients)) { List<String> emails = null; for (RoleBasedRecipient recipient : roleRecipients) { if ("SAE Reporter".equals(recipient.getRoleName()) && aeRecomReport.getAdverseEvent().getReporterEmail() != null) { // add adverse event reporter email for email notification roleBasedEmailAddresses.add(aeRecomReport.getAdverseEvent().getReporterEmail()); } else if (ArrayUtils.contains(RoleUtils.reportSpecificRoles, recipient.getRoleName())) { // since there is no report yet, skip if the role is report specific continue; } else if (ArrayUtils.contains(RoleUtils.sponsorAndCoordinatingCenterSpecificRoles, recipient.getRoleName())) { emails = study.getStudyCoordinatingCenter() .findEmailAddressByRole(recipient.getRoleName()); emails.addAll(study.getStudyFundingSponsors().get(0) .findEmailAddressByRole(recipient.getRoleName())); } else if (ArrayUtils.contains(RoleUtils.studySiteSpecificRoles, recipient.getRoleName())) { emails = studySite.findEmailAddressByRole(recipient.getRoleName()); } else { emails = study.findEmailAddressByRole(recipient.getRoleName()); } //now add the valid email addresses obtained if (CollectionUtils.isNotEmpty(emails)) { for (String email : emails) { if (GenericValidator.isEmail(email)) roleBasedEmailAddresses.add(email); } } } } if (aeRecomReport.getAdverseEvent().getGradedDate() != null) { long daysPassedSinceGradedDate = DateUtils.differenceInDays(new Date(), aeRecomReport.getAdverseEvent().getGradedDate()); if (daysPassedSinceGradedDate != dayOfNotification) { continue; } } // get the graded date and compare with the day of notification to check if notification is configured on this day Map<Object, Object> contextVariableMap = aeRecomReport.getAdverseEvent().getContextVariables(); //get the AE reporting deadline contextVariableMap.put("aeReportingDeadline", aeRecomReport.getDueDate().toString()); //apply the replacements. String subjectLine = freeMarkerService.applyRuntimeReplacementsForReport(rawSubjectLine, contextVariableMap); String body = freeMarkerService.applyRuntimeReplacementsForReport(rawBody, contextVariableMap); //create the message SimpleMailMessage mailMsg = new SimpleMailMessage(); mailMsg.setSentDate(new Date()); mailMsg.setSubject(subjectLine); mailMsg.setText(body); // collect emails of both contact based and role based recipients Set<String> allEmailAddresses = new HashSet<String>(); allEmailAddresses.addAll(roleBasedEmailAddresses); allEmailAddresses.addAll(contactBasedEmailAddresses); //send email to each contact based recipient for (String email : allEmailAddresses) { mailMsg.setTo(email); try { caaersJavaMailSender.send(mailMsg); } catch (Exception e) { //no need to throw and rollback logger.warn("Error while emailing to [" + email + "]", e); } } } } } }
From source file:jef.tools.string.StringSpliter.java
/** * ?Key????/*w ww . j av a2 s.c o m*/ * @param chars * @return */ public boolean expandKeyLeftUntil(char[] chars) { boolean res = false; if (keyword == null) return res; Substring left = getLeft(); while (left.lastCharacter() != null && !ArrayUtils.contains(chars, left.lastCharacter().charValue())) { left.setEnd(left.getEnd() - 1); res = true; } if (res) this.keyword = source.subAbsoultOffset(left.getEnd(), keyword.getEnd()); return res; }
From source file:com.gzj.tulip.load.ResourceRef.java
public boolean hasModifier(String modifier) { if (modifier.startsWith("<") && modifier.endsWith(">")) { return ArrayUtils.contains(modifiers, modifier.substring(1, modifier.length() - 1)); }//from w ww.ja va 2 s. com return ArrayUtils.contains(modifiers, "**") || ArrayUtils.contains(modifiers, "*") || ArrayUtils.contains(modifiers, modifier); }
From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java
private void readAllResultsFromDatabases() { if (controllers == null) { logger.error("No ILoggingScriptController configured in the product plugin_customization.ini file.\n" + "Talk to your Data Acq contact to add a uk.ac.gda.client/gda.loggingscriptcontrollers.to_observe entry"); }/*from w w w. j a v a 2 s. c om*/ for (ILoggingScriptController controller : controllers) { ScriptControllerLogResults[] thisTable = controller.getTable(); for (ScriptControllerLogResults row : thisTable) { mapID2Controller.put(row.getUniqueID(), controller); } results = (ScriptControllerLogResults[]) ArrayUtils.addAll(thisTable, results); } // recreate the filters knownScripts = new String[] {}; for (ScriptControllerLogResults result : results) { String scriptName = result.getScriptName(); if (!ArrayUtils.contains(knownScripts, scriptName)) { knownScripts = (String[]) ArrayUtils.add(knownScripts, scriptName); view.updateFilter(knownScripts); } } view.updateFilter(knownScripts); orderResultsByTime(); }