Refine search
private static Ordering<String> createExplicitComparator(String[] elements) { // Collapse equal elements, which Ordering.explicit() doesn't support, while // maintaining the ordering by first occurrence. Set<String> elementsPlus = Sets.newLinkedHashSet(); elementsPlus.add(BEFORE_FIRST); elementsPlus.add(BEFORE_FIRST_2); elementsPlus.addAll(Arrays.asList(elements)); elementsPlus.add(AFTER_LAST); elementsPlus.add(AFTER_LAST_2); return Ordering.explicit(Lists.newArrayList(elementsPlus)); }
/** Returns a {@link LinkedHashSet} containing the integers in {@code [0, max)}, in order. */ private static Set<Integer> setForRange(int max) { Set<Integer> set = Sets.newLinkedHashSet(); for (int i = 0; i < max; i++) { set.add(i); } return set; }
public static <T> Set<T> addSorted(Set<T> set, T element) { final int size = set.size(); if (size == 0) { return ImmutableSet.of(element); } else if (set instanceof ImmutableSet) { if (size == 1) { final T val = set.iterator().next(); set = Sets.newLinkedHashSet(); set.add(val); } else { set = Sets.newLinkedHashSet(set); } } set.add(element); return set; }
/** * Returns a new proxy for {@code interfaceType}. Proxies of the same interface are equal to each * other if the {@link DummyProxy} instance that created the proxies are equal. */ final <T> T newProxy(TypeToken<T> interfaceType) { Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet(); interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes()); // Make the proxy serializable to work with SerializableTester interfaceClasses.add(Serializable.class); Object dummy = Proxy.newProxyInstance( interfaceClasses.iterator().next().getClassLoader(), interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]), new DummyHandler(interfaceType)); @SuppressWarnings("unchecked") // interfaceType is T T result = (T) dummy; return result; }
Set<K> keysToLoad = Sets.newLinkedHashSet(); for (K key : keys) { V value = get(key); if (value == null) { misses++; keysToLoad.add(key); } else { hits++;
@Override public Set<String> create(String[] elements) { Set<String> unfiltered = Sets.newLinkedHashSet(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); return Sets.filter(unfiltered, Collections2Test.LENGTH_1); } })
/** * Adds an event listener to the session. * * @param listener the event listener callback */ public void addEventListener(EventType eventType, Consumer<PrimitiveEvent> listener) { executor.execute(() -> eventListeners.computeIfAbsent(eventType.canonicalize(), e -> Sets.newLinkedHashSet()).add(listener)); }
/** get all super types of given {@code type}, including, optionally filtered by {@code predicates} * <p> include {@code Object.class} if {@link #includeObject} is true */ public static Set<Class<?>> getAllSuperTypes(final Class<?> type, Predicate<? super Class<?>>... predicates) { Set<Class<?>> result = Sets.newLinkedHashSet(); if (type != null && (includeObject || !type.equals(Object.class))) { result.add(type); for (Class<?> supertype : getSuperTypes(type)) { result.addAll(getAllSuperTypes(supertype)); } } return filter(result, predicates); }
private List<String> getColumnsToInclude(final QueryableIndex index) { final Set<String> columnNames = Sets.newLinkedHashSet(columnNamesFromCli); // Empty columnNames => include all columns. if (columnNames.isEmpty()) { columnNames.add(ColumnHolder.TIME_COLUMN_NAME); Iterables.addAll(columnNames, index.getColumnNames()); } else { // Remove any provided columns that do not exist in this segment. for (String columnName : ImmutableList.copyOf(columnNames)) { if (index.getColumnHolder(columnName) == null) { columnNames.remove(columnName); } } } return ImmutableList.copyOf(columnNames); }
@Override public Set<String> create(String[] elements) { Set<String> unfiltered = Sets.newLinkedHashSet(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); unfiltered.add("abc"); return Sets.filter( Sets.filter(unfiltered, Collections2Test.LENGTH_1), Collections2Test.NOT_YYY_ZZZ); } })
@Override public void addEventListener(EventType eventType, Consumer<PrimitiveEvent> listener) { eventListeners.computeIfAbsent(eventType.canonicalize(), t -> Sets.newLinkedHashSet()).add(listener); }
/** get all super types of given {@code type}, including, optionally filtered by {@code predicates} * <p> include {@code Object.class} if {@link #includeObject} is true */ public static Set<Class<?>> getAllSuperTypes(final Class<?> type, Predicate<? super Class<?>>... predicates) { Set<Class<?>> result = Sets.newLinkedHashSet(); if (type != null && (includeObject || !type.equals(Object.class))) { result.add(type); for (Class<?> supertype : getSuperTypes(type)) { result.addAll(getAllSuperTypes(supertype)); } } return filter(result, predicates); }
@Override public Set<Map.Entry<String, PersistedData>> entrySet() { Set<Map.Entry<String, PersistedData>> entries = Sets.newLinkedHashSet(); for (Map.Entry<String, JsonElement> element : map.entrySet()) { entries.add(new AbstractMap.SimpleEntry<String, PersistedData>(element.getKey(), new GsonPersistedData(element.getValue()))); } return entries; } }
/** * Recursively builds the paths for the controller class. * * @param controllerClass * @return the paths for the controller */ private Set<String> collectPaths(Class<?> controllerClass) { Set<String> parentPaths = Collections.emptySet(); if (controllerClass.getSuperclass() != null) { parentPaths = collectPaths(controllerClass.getSuperclass()); } Set<String> paths = Sets.newLinkedHashSet(); Path controllerPath = controllerClass.getAnnotation(Path.class); if (controllerPath == null) { return parentPaths; } if (parentPaths.isEmpty()) { // add all controller paths paths.addAll(Arrays.asList(controllerPath.value())); } else { // create controller paths based on the parent paths for (String parentPath : parentPaths) { for (String path : controllerPath.value()) { paths.add(parentPath + path); } } } return paths; }
@Override public Set<String> create(String[] elements) { Set<String> unfiltered = Sets.newLinkedHashSet(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ); } })
continue; Set<Class<? extends Component>> requiredComponents = Sets.newLinkedHashSet(); method.setAccessible(true); Class<?>[] types = method.getParameterTypes(); return; requiredComponents.add((Class<? extends Component>) types[i]); componentParams.add((Class<? extends Component>) types[i]);
@Override public Set<ResourceUrn> getAvailableAssetUrns() { Set<ResourceUrn> result = Sets.newLinkedHashSet(); assetManager.getAvailableAssets(BlockTile.class).stream() .map(urn -> assetManager.getAsset(urn, BlockTile.class).get()) .filter(BlockTile::isAutoBlock) .forEach(tile -> result.add(tile.getUrn())); return result; }
continue; Set<Class<? extends Component>> requiredComponents = Sets.newLinkedHashSet(); method.setAccessible(true); Class<?>[] types = method.getParameterTypes(); return; requiredComponents.add((Class<? extends Component>) types[i]); componentParams.add((Class<? extends Component>) types[i]);
@Override public String toString() { final StringBuilder sb = new StringBuilder(keyword + ": "); if (additionalOK) return sb.append("allowed").toString(); sb.append("none"); if (properties.isEmpty() && patternProperties.isEmpty()) return sb.toString(); sb.append(", unless: "); final Set<String> further = Sets.newLinkedHashSet(); if (!properties.isEmpty()) further.add("one property is any of: " + properties); if (!patternProperties.isEmpty()) further.add("a property matches any regex among: " + patternProperties); sb.append(TOSTRING_JOINER.join(further)); return sb.toString(); } }
/** * Get columns that have dictionary */ public Set<TblColRef> getAllColumnsHaveDictionary() { Set<TblColRef> result = Sets.newLinkedHashSet(); // dictionaries in dimensions result.addAll(getAllDimsHaveDictionary()); // dictionaries in measures for (MeasureDesc measure : measures) { MeasureType<?> aggrType = measure.getFunction().getMeasureType(); result.addAll(aggrType.getColumnsNeedDictionary(measure.getFunction())); } // any additional dictionaries if (dictionaries != null) { for (DictionaryDesc dictDesc : dictionaries) { TblColRef col = dictDesc.getColumnRef(); result.add(col); } } return result; }