@Override public Iterable<E> order(List<E> insertionOrder) { return gen.order(new ArrayList<E>(new LinkedHashSet<E>(insertionOrder))); } }
/** * Gets the set of unique path parameters used in the given URI. If a parameter is used twice * in the URI, it will only show up once in the set. */ static Set<String> parsePathParameters(String path) { Matcher m = PARAM_URL_REGEX.matcher(path); Set<String> patterns = new LinkedHashSet<>(); while (m.find()) { patterns.add(m.group(1)); } return patterns; }
/** * Update the exposed {@link #cacheNames} set with the given name. * <p>This will always be called within a full {@link #cacheMap} lock * and effectively behaves like a {@code CopyOnWriteArraySet} with * preserved order but exposed as an unmodifiable reference. * @param name the name of the cache to be added */ private void updateCacheNames(String name) { Set<String> cacheNames = new LinkedHashSet<>(this.cacheNames.size() + 1); cacheNames.addAll(this.cacheNames); cacheNames.add(name); this.cacheNames = Collections.unmodifiableSet(cacheNames); }
@Override protected Class<? extends Attribute>[] computeValue(Class<?> clazz) { final Set<Class<? extends Attribute>> intfSet = new LinkedHashSet<>(); // find all interfaces that this attribute instance implements // and that extend the Attribute interface do { for (Class<?> curInterface : clazz.getInterfaces()) { if (curInterface != Attribute.class && Attribute.class.isAssignableFrom(curInterface)) { intfSet.add(curInterface.asSubclass(Attribute.class)); } } clazz = clazz.getSuperclass(); } while (clazz != null); @SuppressWarnings({"unchecked", "rawtypes"}) final Class<? extends Attribute>[] a = intfSet.toArray(new Class[intfSet.size()]); return a; } };
public String[] getMechanismNames(final Map<String, ?> props) { synchronized (loader) { final Set<String> set = new LinkedHashSet<>(); final Iterator<SaslClientFactory> iterator = loader.iterator(); SaslClientFactory clientFactory; for (;;) try { // Service loader iterators can blow up in various ways; that's why the loop is structured this way if (! iterator.hasNext()) { break; } clientFactory = iterator.next(); // let SaslException bubble up Collections.addAll(set, clientFactory.getMechanismNames(props)); } catch (ServiceConfigurationError ignored) {} return set.toArray(new String[set.size()]); } } }
@Override public Set<String> keySet() { HashSet<String> stringSet = mdag.getAllStrings(); LinkedHashSet<String> keySet = new LinkedHashSet<String>(); Iterator<String> iterator = stringSet.iterator(); while (iterator.hasNext()) { String key = iterator.next(); keySet.add(key.substring(0, key.length() - 3)); } return keySet; }
@Override @SuppressWarnings("unchecked") public Set<Tuple> build(Object data) { if (null == data) { return null; } List<byte[]> l = (List<byte[]>) data; final Set<Tuple> result = new LinkedHashSet<Tuple>(l.size()); Iterator<byte[]> iterator = l.iterator(); while (iterator.hasNext()) { result.add(new Tuple(iterator.next(), Double.valueOf(SafeEncoder.encode(iterator.next())))); } return result; }
@Override public List<String> resolveFileExtensions(MediaType mediaType) { Set<String> result = new LinkedHashSet<>(); for (MediaTypeFileExtensionResolver resolver : this.resolvers) { result.addAll(resolver.resolveFileExtensions(mediaType)); } return new ArrayList<>(result); }
Set<Throwable> deDupedExceptions = new LinkedHashSet<Throwable>(); List<Throwable> localExceptions = new ArrayList<Throwable>(); if (errors != null) { for (Throwable ex : errors) { } else if (ex != null) { deDupedExceptions.add(ex); } else { deDupedExceptions.add(new NullPointerException("Throwable was null!")); deDupedExceptions.add(new NullPointerException("errors was null"));
private Set<String> resolvePackagesToScan(Set<String> packagesToScan) { Set<String> resolvedPackagesToScan = new LinkedHashSet<String>(packagesToScan.size()); for (String packageToScan : packagesToScan) { if (StringUtils.hasText(packageToScan)) { String resolvedPackageToScan = environment.resolvePlaceholders(packageToScan.trim()); resolvedPackagesToScan.add(resolvedPackageToScan); } } return resolvedPackagesToScan; }
public static void main(String[] args) { Set<Integer> set = new LinkedHashSet<Integer>(); List<Integer> list = new ArrayList<Integer>(); for (int i = -3; i < 3; i++) { set.add(i); list.add(i); } for (int i = 0; i < 3; i++) { set.remove(i); list.remove(i); } System.out.println(set + " " + list); } }
Set<Integer> linkedHashSet = new LinkedHashSet<>(); linkedHashSet.add(3); linkedHashSet.add(1); linkedHashSet.add(2); for (int i : linkedHashSet) { System.out.println(i); }
/** * Compare columns created from meta-data with declared columns and return a reconciled list. * @param declaredColumns declared column names * @param generatedKeyNames names of generated key columns */ protected List<String> reconcileColumnsToUse(List<String> declaredColumns, String[] generatedKeyNames) { if (generatedKeyNames.length > 0) { this.generatedKeyColumnsUsed = true; } if (!declaredColumns.isEmpty()) { return new ArrayList<>(declaredColumns); } Set<String> keys = new LinkedHashSet<>(generatedKeyNames.length); for (String key : generatedKeyNames) { keys.add(key.toUpperCase()); } List<String> columns = new ArrayList<>(); for (TableParameterMetaData meta : obtainMetaDataProvider().getTableParameterMetaData()) { if (!keys.contains(meta.getParameterName().toUpperCase())) { columns.add(meta.getParameterName()); } } return columns; }
private static SerializationFormat[] newAllowedSerializationFormats( SerializationFormat defaultSerializationFormat, Iterable<SerializationFormat> otherAllowedSerializationFormats) { requireNonNull(defaultSerializationFormat, "defaultSerializationFormat"); requireNonNull(otherAllowedSerializationFormats, "otherAllowedSerializationFormats"); final Set<SerializationFormat> set = new LinkedHashSet<>(); set.add(defaultSerializationFormat); Iterables.addAll(set, otherAllowedSerializationFormats); return set.toArray(EMPTY_FORMATS); }
referencedClassSet = new LinkedHashSet<>(referencedClassSet); referencedClassSet.removeAll(badClasses); for (Iterator<AnalysisPass> passIterator = executionPlan.passIterator(); passIterator.hasNext();) { AnalysisPass pass = passIterator.next(); System.out.println("Analysis order:"); for (ClassDescriptor c : classCollection) { System.out.println(" " + c); && !classScreener.matches(classDescriptor.toResourceName())) { if (DEBUG) { System.out.println("*** Excluded by class screener");
@Override TypeVariable<?> captureAsTypeVariable(Type[] upperBounds) { Set<Type> combined = new LinkedHashSet<>(asList(upperBounds)); // Since this is an artifically generated type variable, we don't bother checking // subtyping between declared type bound and actual type bound. So it's possible that we // may generate something like <capture#1-of ? extends Foo&SubFoo>. // Checking subtype between declared and actual type bounds // adds recursive isSubtypeOf() call and feels complicated. // There is no contract one way or another as long as isSubtypeOf() works as expected. combined.addAll(asList(typeParam.getBounds())); if (combined.size() > 1) { // Object is implicit and only useful if it's the only bound. combined.remove(Object.class); } return super.captureAsTypeVariable(combined.toArray(new Type[0])); } };
DependencyDescriptor desc = new DependencyDescriptor(field, this.required); desc.setContainingClass(bean.getClass()); Set<String> autowiredBeanNames = new LinkedHashSet<>(1); Assert.state(beanFactory != null, "No BeanFactory available"); TypeConverter typeConverter = beanFactory.getTypeConverter(); this.cachedFieldValue = desc; registerDependentBeans(beanName, autowiredBeanNames); if (autowiredBeanNames.size() == 1) { String autowiredBeanName = autowiredBeanNames.iterator().next(); if (beanFactory.containsBean(autowiredBeanName) && beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {
public String deDup(String s) { return new LinkedHashSet<String>(Arrays.asList(s.split("-"))).toString().replaceAll("(^\\[|\\]$)", "").replace(", ", "-"); } public static void main(String[] args) { System.out.println(deDup("Bangalore-Chennai-NewYork-Bangalore-Chennai")); }
/** * Resolves all interfaces of a type. No duplicates are returned. * Direct interfaces are prior the interfaces of subclasses in * the returned array. */ public static Class[] resolveAllInterfaces(Class type) { Set<Class> bag = new LinkedHashSet<>(); _resolveAllInterfaces(type, bag); return bag.toArray(new Class[bag.size()]); }
protected void setScope(Collection<String> scope) { if (scope != null && scope.size() == 1) { String value = scope.iterator().next(); /* * This is really an error, but it can catch out unsuspecting users * and it's easy to fix. It happens when an AuthorizationRequest * gets bound accidentally from request parameters using * @ModelAttribute. */ if (value.contains(" ") || value.contains(",")) { scope = OAuth2Utils.parseParameterList(value); } } this.scope = Collections .unmodifiableSet(scope == null ? new LinkedHashSet<String>() : new LinkedHashSet<String>(scope)); }