List of usage examples for com.google.common.collect Sets newHashSet
public static <E> HashSet<E> newHashSet()
From source file:org.graylog2.indexer.IndexHelper.java
public static Set<String> getOldestIndices(Set<String> indexNames, int count) { Set<String> r = Sets.newHashSet(); if (count < 0 || indexNames.size() <= count) { return r; }// w w w . jav a 2 s.c o m Set<Integer> numbers = Sets.newHashSet(); for (String indexName : indexNames) { numbers.add(Deflector.extractIndexNumber(indexName)); } List<String> sorted = prependPrefixes(getPrefix(indexNames), Tools.asSortedList(numbers)); // Add last x entries to return set. r.addAll(sorted.subList(0, count)); return r; }
From source file:com.android.tools.idea.editors.theme.ThemeEditorTestUtils.java
/** * Returns the attributes that were defined in the theme itself and not its parents. *///from w w w. j ava 2s . c o m public static Collection<EditedStyleItem> getStyleLocalValues(@NotNull final ConfiguredThemeEditorStyle style) { final Set<String> localAttributes = Sets.newHashSet(); for (ConfiguredElement<ItemResourceValue> value : style.getConfiguredValues()) { localAttributes.add(ResolutionUtils.getQualifiedItemName(value.getElement())); } return Collections2.filter( ThemeAttributeResolver.resolveAll(style, style.getConfiguration().getConfigurationManager()), new Predicate<EditedStyleItem>() { @Override public boolean apply(@Nullable EditedStyleItem input) { assert input != null; return localAttributes.contains(input.getQualifiedName()); } }); }
From source file:fr.putnami.pwt.core.widget.client.util.WidgetUtils.java
public static Set<Widget> listChildren(Widget w) { Set<Widget> children = Sets.newHashSet(); WidgetUtils.collectChildren(w, children); return children; }
From source file:net.roddrim.number5.tools.collect.FluentSet.java
public static <E> FluentSet<E> ofNewHashSet() { return of(Sets.newHashSet()); }
From source file:com.github.steveash.jg2p.align.FilterWalkerDecorator.java
public static Set<Pair<String, String>> readFromFile(File file) throws IOException { Splitter splitter = Splitter.on('^').trimResults(); List<String> lines = Files.readLines(file, Charsets.UTF_8); HashSet<Pair<String, String>> result = Sets.newHashSet(); for (String line : lines) { if (isBlank(line)) { continue; }//from www .ja va 2s . c o m Iterator<String> fields = splitter.split(line).iterator(); String x = fields.next(); String y = fields.next(); result.add(Pair.of(x, y)); } return result; }
From source file:net.diogobohm.timed.impl.codec.TagCodecImpl.java
@Override public Set<Tag> decode(Set<DBTag> tags) { Set<Tag> decodedTags = Sets.newHashSet(); for (DBTag tag : tags) { decodedTags.add(decode(tag));/* w w w . j a v a 2s .c om*/ } return decodedTags; }
From source file:org.dswarm.graph.utils.GraphUtils.java
public static NodeType determineNodeType(final Node node) throws DMPGraphException { final Iterable<Label> nodeLabels = node.getLabels(); if (nodeLabels == null) { throw new DMPGraphException( String.format("couldn't determine node type; there are no labels at node '%d'", node.getId())); }/*from w ww . j ava 2 s . c om*/ final Set<String> labels = Sets.newHashSet(); for (final Label label : nodeLabels) { labels.add(label.name()); } if (labels.isEmpty()) { throw new DMPGraphException( String.format("couldn't determine node type; there are no labels at node '%d'", node.getId())); } if (labels.contains(NodeType.TypeResource.getName())) { return NodeType.TypeResource; } if (labels.contains(NodeType.TypeBNode.getName())) { return NodeType.TypeBNode; } if (labels.contains(NodeType.Resource.getName())) { return NodeType.Resource; } if (labels.contains(NodeType.BNode.getName())) { return NodeType.BNode; } if (labels.contains(NodeType.Literal.getName())) { return NodeType.Literal; } throw new DMPGraphException( String.format("couldn't determine node type; there only other labels at node '%d'", node.getId())); }
From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.Stores.java
/** * The method that creates stores given the supplied collection. * * <p>It ensures each store has unique name and id</p> * @param stores carries individual stores * @return the matching stores/*from www. j a v a 2 s . c o m*/ */ public static Stores create(ImmutableSet<Store> stores) { Set<String> ids = Sets.newHashSet(); Set<String> names = Sets.newHashSet(); for (Store store : stores) { Preconditions.checkArgument(ids.add(store.id), "duplicate store id found for store %s", store); Preconditions.checkArgument(names.add(store.name), "duplicate store name found for store %s", store); } return new Stores(stores); }
From source file:org.onosproject.incubator.protobuf.models.core.ApplicationProtoTranslator.java
/** * Translates gRPC Application to {@link Application}. * * @param app gRPC message//from ww w . ja va2 s .c o m * @return {@link Application} */ public static Application translate(ApplicationProto app) { Set<Permission> permissions = Sets.newHashSet(); app.getPermissionsList().forEach(p -> permissions.add(PermissionProtoTranslator.translate(p))); return DefaultApplication.builder().withAppId(ApplicationIdProtoTranslator.translate(app.getAppId())) .withVersion(VersionProtoTranslator.translate(app.getVersion())).withTitle(app.getTitle()) .withDescription(app.getDescription()).withOrigin(app.getOrigin()).withCategory(app.getCategory()) .withUrl(app.getUrl()).withReadme(app.getReadme()).withIcon(app.toByteArray()) .withRole(ApplicationEnumsProtoTranslator.translate(app.getRole()).get()) .withPermissions(permissions).withFeatures(app.getFeaturesList()).withFeaturesRepo(Optional.empty()) // TODO: need to add features repo .withRequiredApps(app.getRequiredAppsList()).build(); }
From source file:org.apache.hadoop.hbase.monitoring.LogMonitoring.java
public static Set<File> getActiveLogFiles() throws IOException { Set<File> ret = Sets.newHashSet(); Appender a;/*from w w w . ja va2 s . com*/ @SuppressWarnings("unchecked") Enumeration<Appender> e = Logger.getRootLogger().getAllAppenders(); while (e.hasMoreElements()) { a = e.nextElement(); if (a instanceof FileAppender) { FileAppender fa = (FileAppender) a; String filename = fa.getFile(); ret.add(new File(filename)); } } return ret; }