protected boolean isMatch(Method method, String beanKey) { if (this.methodMappings != null) { Set<String> methodNames = this.methodMappings.get(beanKey); if (methodNames != null) { return methodNames.contains(method.getName()); } } return (this.managedMethods != null && this.managedMethods.contains(method.getName())); }
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) { List<TypeElement> list = new ArrayList<>(); for (Element element : elements) { if (TYPE_KINDS.contains(element.getKind()) && element.getModifiers().contains(Modifier.STATIC)) { list.add(TypeElement.class.cast(element)); } } return list; }
@Test public void testCircularCollectionBeansStartingWithSet() { this.beanFactory.getBean("circularSet"); TestBean bean = (TestBean) this.beanFactory.getBean("circularCollectionBeansBean"); List list = bean.getSomeList(); assertFalse(Proxy.isProxyClass(list.getClass())); assertEquals(1, list.size()); assertEquals(bean, list.get(0)); Set set = bean.getSomeSet(); assertTrue(Proxy.isProxyClass(set.getClass())); assertEquals(1, set.size()); assertTrue(set.contains(bean)); Map map = bean.getSomeMap(); assertFalse(Proxy.isProxyClass(map.getClass())); assertEquals(1, map.size()); assertEquals(bean, map.get("foo")); }
private void ensureInitializerInvoked(GoPluginDescriptor pluginDescriptor, GoPlugin plugin, String extensionType) { synchronized (initializedPluginsWithTheirExtensionTypes) { if (initializedPluginsWithTheirExtensionTypes.get(pluginDescriptor) == null) { initializedPluginsWithTheirExtensionTypes.put(pluginDescriptor, new HashSet<>()); } Set<String> initializedExtensions = initializedPluginsWithTheirExtensionTypes.get(pluginDescriptor); if (initializedExtensions == null || initializedExtensions.contains(extensionType)) { return; } initializedPluginsWithTheirExtensionTypes.get(pluginDescriptor).add(extensionType); PluginAwareDefaultGoApplicationAccessor accessor = new PluginAwareDefaultGoApplicationAccessor(pluginDescriptor, requestProcesRegistry); plugin.initializeGoApplicationAccessor(accessor); } }
private static boolean noNonMatchingModifier(Set<String> expectedMethodNames, Map<String, Integer> methodsModifier, Map<String, String> nonMatchingModifiers, int modifier) { for (String method : methodsModifier.keySet()) { if (expectedMethodNames.contains(method) && (methodsModifier.get(method) & modifier) == 0) { nonMatchingModifiers.put(method, Modifier.toString(methodsModifier.get(method))); } } return nonMatchingModifiers.isEmpty(); }
private void cleanup() { if (deleted==null || deleted.isEmpty()) return; Set<InternalRelation> deletedSet = new HashSet<InternalRelation>(deleted); deleted=null; List<InternalRelation> newadded = new ArrayList<InternalRelation>(added.size()-deletedSet.size()/2); for (InternalRelation r : added) { if (!deletedSet.contains(r)) newadded.add(r); } added=newadded; }
@Implementation(minSdk = JELLY_BEAN_MR2) protected Account[] getAccountsByTypeForPackage(String type, String packageName) { List<Account> result = new ArrayList<>(); Account[] accountsByType = getAccountsByType(type); for (Account account : accountsByType) { if (packageVisibileAccounts.containsKey(account) && packageVisibileAccounts.get(account).contains(packageName)) { result.add(account); } } return result.toArray(new Account[result.size()]); }
/** * @return true if this value is duplicated */ public boolean put(Object value, FieldNode fld) { FieldNode prev = values.put(value, fld); if (prev != null) { values.remove(value); duplicates.add(value); return true; } if (duplicates.contains(value)) { values.remove(value); return true; } return false; }
private static List<Sieve.MentionData> eliminateDuplicates(List<Sieve.MentionData> mentionCandidates) { List<Sieve.MentionData> newList = new ArrayList<>(); Set<String> seenText = new HashSet<>(); for(int i = 0; i < mentionCandidates.size(); i++) { Sieve.MentionData mentionCandidate = mentionCandidates.get(i); String text = mentionCandidate.text; if(!seenText.contains(text) || mentionCandidate.type.equals("Pronoun")) newList.add(mentionCandidate); seenText.add(text); } return newList; }
public DefaultCommandLine addRawValue(Option option, String value) { if (!acceptMoreValues(option) && !option.isFlag()) { throw new CLIException("The option " + option.getName() + " does not accept value or has " + "already been set"); } if (! option.getChoices().isEmpty() && ! option.getChoices().contains(value)) { throw new InvalidValueException(option, value); } List<String> list = optionValues.get(option); if (list == null) { list = new ArrayList<>(); optionValues.put(option, list); } list.add(value); return this; }
@Test public void replaceUriTemplateParamsTemplateWithParamMatchNamePreEncoding() throws JspException { List<Param> params = new LinkedList<>(); Set<String> usedParams = new HashSet<>(); Param param = new Param(); param.setName("n me"); param.setValue("value"); params.add(param); String uri = tag.replaceUriTemplateParams("url/{n me}", params, usedParams); assertEquals("url/value", uri); assertEquals(1, usedParams.size()); assertTrue(usedParams.contains("n me")); }
static char[] randomChars(Random rand, int size) { Set<Character> chars = new HashSet<>(size); for (int i = 0; i < size; i++) { char c; while (true) { c = (char) rand.nextInt(Character.MAX_VALUE - Character.MIN_VALUE + 1); if (!chars.contains(c)) { break; } } chars.add(c); } char[] retValue = new char[chars.size()]; int i = 0; for (char c : chars) { retValue[i++] = c; } Arrays.sort(retValue); return retValue; }
private static <T, S> void exploreStates(List<DFSAState<T, S>> toVisit, Set<DFSAState<T, S>> visited) { while (!toVisit.isEmpty()) { DFSAState<T, S> state = toVisit.get(toVisit.size() - 1); toVisit.remove(toVisit.size() - 1); if (!visited.contains(state)) { toVisit.addAll(state.successorStates()); visited.add(state); } } }
public void noMoreSplits(PlanNodeId planNodeId) { if (noMoreSplits.contains(planNodeId)) { return; } noMoreSplits.add(planNodeId); if (noMoreSplits.size() < sourceStartOrder.size()) { return; } checkState(noMoreSplits.size() == sourceStartOrder.size()); checkState(noMoreSplits.containsAll(sourceStartOrder)); status.setNoMoreLifespans(); }
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) { Set<Feature<?>> valuesCollectionFeatures = computeCommonDerivedCollectionFeatures(mapFeatures); if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) { valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES); } if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) { valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES); } return valuesCollectionFeatures; }