@Override protected boolean isInputValid(ConversationContext context, String input) { String[] accepted = {"true", "false", "on", "off", "yes", "no"}; return ArrayUtils.contains(accepted, input.toLowerCase()); }
private CloseablesIteratorWrapper(CloseableIterator<T> iterator, AutoCloseable... otherCloseables) { requireNonNull(iterator); checkArgument(!ArrayUtils.contains(otherCloseables, iterator)); this.iterator = iterator; // the advantage of using ImmutableList is that it does not accept null elements, so it fails fast, during // construction of the wrapper, but not in close() this.otherCloseables = ImmutableList.copyOf(otherCloseables); }
/** * @param contextSource * @param groupSearchBase */ public AuthoritiesPopulator(ContextSource contextSource, String groupSearchBase, String adminRole, String defaultRole) { super(contextSource, groupSearchBase); this.adminRoleAsAuthority = new SimpleGrantedAuthority(adminRole.toUpperCase(Locale.ROOT)); // spring will // convert group names to uppercase by default String[] defaultRoles = StringUtils.split(defaultRole, ","); if (ArrayUtils.contains(defaultRoles, Constant.ROLE_MODELER)) { this.defaultAuthorities.add(modelerAuthority); this.defaultAuthorities.add(analystAuthority); } if (ArrayUtils.contains(defaultRoles, Constant.ROLE_ANALYST)) this.defaultAuthorities.add(analystAuthority); }
/** * @param keys the languages keys * @return the list of suffix files associates to languages included in the current object */ public String[] getSuffixes(String... keys) { List<String> suffixes = new ArrayList<>(); for (Map.Entry<String, Language> entry : map.entrySet()) { if (ArrayUtils.isEmpty(keys) || ArrayUtils.contains(keys, entry.getKey())) { suffixes.addAll(Arrays.asList(entry.getValue().getFileSuffixes())); } } return suffixes.toArray(new String[suffixes.size()]); }
@Override public Long valueOf(String str) { if (str == null) return Long.valueOf(0L); else return Long .valueOf(BooleanUtils.toInteger(ArrayUtils.contains(TRUE_VALUE_SET, str.toLowerCase(Locale.ROOT)))); } }
for (int i = 0; i < fields.length && builder.isEquals; i++) { Field f = fields[i]; if (!ArrayUtils.contains(excludeFields, f.getName()) && (f.getName().indexOf('$') == -1) && (useTransients || !Modifier.isTransient(f.getModifiers()))
for (int i = 0; i < fields.length && builder.comparison == 0; i++) { Field f = fields[i]; if (!ArrayUtils.contains(excludeFields, f.getName()) && (f.getName().indexOf('$') == -1) && (useTransients || !Modifier.isTransient(f.getModifiers()))
public BoolQueryBuilder getStickyFacetFilter(String... fieldNames) { BoolQueryBuilder facetFilter = boolQuery().must(query); for (Map.Entry<String, QueryBuilder> filter : filters.entrySet()) { if (filter.getValue() != null && !ArrayUtils.contains(fieldNames, filter.getKey())) { facetFilter.must(filter.getValue()); } } return facetFilter; }
public static void addNewCodePathsFromInternErlangSdk(@NotNull Sdk elixirSdk, @NotNull Sdk internalErlangSdk, @NotNull SdkModificator elixirSdkModificator) { codePathsFromInternalErlangSdk( elixirSdk, internalErlangSdk, elixirSdkModificator, (sdkModificator, configuredRoots, expandedInternalRoot, type) -> { if (!ArrayUtils.contains(configuredRoots, expandedInternalRoot)) { sdkModificator.addRoot(expandedInternalRoot, type); } } ); }
public List<ProfileExporter> exportersForLanguage(String language) { List<ProfileExporter> result = new ArrayList<>(); for (ProfileExporter exporter : exporters) { if (exporter.getSupportedLanguages() == null || exporter.getSupportedLanguages().length == 0 || ArrayUtils.contains(exporter.getSupportedLanguages(), language)) { result.add(exporter); } } return result; }
for (int i = 0; i < fields.length; i++) { Field field = fields[i]; if (!ArrayUtils.contains(excludeFields, field.getName()) && (field.getName().indexOf('$') == -1) && (useTransients || !Modifier.isTransient(field.getModifiers()))
private void addListener( Control el, int event, TypedListener listener ) { if ( ArrayUtils.contains( el.getListeners( event ), listener ) ) { return; } el.addListener( event, listener ); }
@Override public BroadleafAttributeModifier getModifiedAttributes(String tagName, Map<String, String> tagAttributes, String attributeName, String attributeValue, BroadleafTemplateContext context) { BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext(); HttpServletRequest request = blcContext.getRequest(); String baseUrl = request.getRequestURL().toString(); Map<String, String[]> params = new HashMap<>(request.getParameterMap()); SearchFacetResultDTO result = (SearchFacetResultDTO) context.parseExpression(attributeValue); String key = facetService.getUrlKey(result); String value = facetService.getValue(result); String[] paramValues = params.get(key); if (ArrayUtils.contains(paramValues, facetService.getValue(result))) { paramValues = (String[]) ArrayUtils.removeElement(paramValues, facetService.getValue(result)); } else { paramValues = (String[]) ArrayUtils.add(paramValues, value); } params.remove(SearchCriteria.PAGE_NUMBER); params.put(key, paramValues); String url = ProcessorUtils.getUrl(baseUrl, params); Map<String, String> newAttributes = new HashMap<>(); newAttributes.put("href", url); return new BroadleafAttributeModifier(newAttributes); }
@Override public void removeNonApplicableFields(ClassMetadata cmd, EntityForm entityForm, String entityType) { for (Property p : cmd.getProperties()) { if (!ArrayUtils.contains(p.getMetadata().getAvailableToTypes(), entityType)) { entityForm.removeField(p.getName()); } } }
@Test public void test_v4_6_0__That_Group_Membership_Perf_Id_Index_Exists() throws Exception { String tableName = "group_membership"; validate_index_existence(new String[] {tableName,tableName.toUpperCase()}, "group_membership_perf_group_idx"); if (ArrayUtils.contains(environment.getActiveProfiles(), "postgresql")) { validate_index_existence(new String[] {tableName,tableName.toUpperCase()}, "group_membership_perf_group_lower_idx"); } }
@Test public void testIntPredicateEvaluators() { int intValue = _random.nextInt(); EqPredicate eqPredicate = new EqPredicate(COLUMN_NAME, Collections.singletonList(Integer.toString(intValue))); PredicateEvaluator eqPredicateEvaluator = EqualsPredicateEvaluatorFactory.newRawValueBasedEvaluator(eqPredicate, FieldSpec.DataType.INT); NEqPredicate neqPredicate = new NEqPredicate(COLUMN_NAME, Collections.singletonList(Integer.toString(intValue))); PredicateEvaluator neqPredicateEvaluator = NotEqualsPredicateEvaluatorFactory.newRawValueBasedEvaluator(neqPredicate, FieldSpec.DataType.INT); Assert.assertTrue(eqPredicateEvaluator.applySV(intValue)); Assert.assertFalse(neqPredicateEvaluator.applySV(intValue)); int[] randomInts = new int[NUM_MULTI_VALUES]; PredicateEvaluatorTestUtils.fillRandom(randomInts); randomInts[_random.nextInt(NUM_MULTI_VALUES)] = intValue; Assert.assertTrue(eqPredicateEvaluator.applyMV(randomInts, NUM_MULTI_VALUES)); Assert.assertFalse(neqPredicateEvaluator.applyMV(randomInts, NUM_MULTI_VALUES)); for (int i = 0; i < 100; i++) { int random = _random.nextInt(); Assert.assertEquals(eqPredicateEvaluator.applySV(random), (random == intValue)); Assert.assertEquals(neqPredicateEvaluator.applySV(random), (random != intValue)); PredicateEvaluatorTestUtils.fillRandom(randomInts); Assert.assertEquals(eqPredicateEvaluator.applyMV(randomInts, NUM_MULTI_VALUES), ArrayUtils.contains(randomInts, intValue)); Assert.assertEquals(neqPredicateEvaluator.applyMV(randomInts, NUM_MULTI_VALUES), !ArrayUtils.contains(randomInts, intValue)); } }
@Test public void testDoublePredicateEvaluators() { double doubleValue = _random.nextDouble(); EqPredicate eqPredicate = new EqPredicate(COLUMN_NAME, Collections.singletonList(Double.toString(doubleValue))); PredicateEvaluator eqPredicateEvaluator = EqualsPredicateEvaluatorFactory.newRawValueBasedEvaluator(eqPredicate, FieldSpec.DataType.DOUBLE); NEqPredicate neqPredicate = new NEqPredicate(COLUMN_NAME, Collections.singletonList(Double.toString(doubleValue))); PredicateEvaluator neqPredicateEvaluator = NotEqualsPredicateEvaluatorFactory.newRawValueBasedEvaluator(neqPredicate, FieldSpec.DataType.DOUBLE); Assert.assertTrue(eqPredicateEvaluator.applySV(doubleValue)); Assert.assertFalse(neqPredicateEvaluator.applySV(doubleValue)); double[] randomDoubles = new double[NUM_MULTI_VALUES]; PredicateEvaluatorTestUtils.fillRandom(randomDoubles); randomDoubles[_random.nextInt(NUM_MULTI_VALUES)] = doubleValue; Assert.assertTrue(eqPredicateEvaluator.applyMV(randomDoubles, NUM_MULTI_VALUES)); Assert.assertFalse(neqPredicateEvaluator.applyMV(randomDoubles, NUM_MULTI_VALUES)); for (int i = 0; i < 100; i++) { double random = _random.nextDouble(); Assert.assertEquals(eqPredicateEvaluator.applySV(random), (random == doubleValue)); Assert.assertEquals(neqPredicateEvaluator.applySV(random), (random != doubleValue)); PredicateEvaluatorTestUtils.fillRandom(randomDoubles); Assert.assertEquals(eqPredicateEvaluator.applyMV(randomDoubles, NUM_MULTI_VALUES), ArrayUtils.contains(randomDoubles, doubleValue)); Assert.assertEquals(neqPredicateEvaluator.applyMV(randomDoubles, NUM_MULTI_VALUES), !ArrayUtils.contains(randomDoubles, doubleValue)); } }
@Test public void testNoDupColInDimAndMeasure() { DataModelDesc model = DataModelManager.getInstance(getTestConfig()).getDataModelDesc("test_kylin_inner_join_model_desc"); String[] metrics = model.getMetrics(); TblColRef col = model.findColumn("edw.test_cal_dt.cal_dt"); assertTrue(metrics.length == 2); assertTrue(ArrayUtils.contains(metrics, col.getIdentity()) == false); }
private int checkNaPath(SharedTreeNode parentNode, String[] previousNaSplits) { final SharedTreeNode leftChild = parentNode.getLeftChild(); final SharedTreeNode rightChild = parentNode.getRightChild(); if (leftChild == null && rightChild == null) return 0; final boolean isRightInclusive = rightChild != null ? rightChild.isInclusiveNa() : false; final boolean isLeftInclusive = leftChild != null ? leftChild.isInclusiveNa() : false; if (!(isLeftInclusive ^ isRightInclusive) && isLeftInclusive) { fail("Parent node " + parentNode.getNodeNumber() + " includes NAs for both children"); } final boolean splitsOnExcluded = ArrayUtils.contains(previousNaSplits, parentNode.getColName()); if (splitsOnExcluded && (isRightInclusive || isLeftInclusive)) { // If NAs for given column went any other way before, there should be no NA direction for the column fail("Parent node " + parentNode.getNodeNumber() + " includes NAs for column " + parentNode.getColName()); } else if (!splitsOnExcluded && !(isLeftInclusive ^ isRightInclusive)) { // If NAs for given column may appear on this node, it should point a way to one of its children fail("Parent node " + parentNode.getNodeNumber() + " should set NA direction to one of its children"); } final String[] leftPreviousSplits = isRightInclusive ? (String[]) ArrayUtils.add(previousNaSplits, parentNode.getColName()) : previousNaSplits; final String[] rightPreviousSplits = isLeftInclusive ? (String[]) ArrayUtils.add(previousNaSplits, parentNode.getColName()) : previousNaSplits; int naSplits = 0; if(isRightInclusive ^ isLeftInclusive){ naSplits++; } if (leftChild != null) naSplits += checkNaPath(leftChild, leftPreviousSplits); if (rightChild != null) naSplits += checkNaPath(rightChild, rightPreviousSplits); return naSplits; }