List of usage examples for com.google.common.collect Sets newHashSet
public static <E> HashSet<E> newHashSet()
From source file:org.sonar.flex.checks.utils.Modifiers.java
public static Set<AstNodeType> getModifiers(AstNode attributes) { Set<AstNodeType> modifiersSet = Sets.newHashSet(); if (attributes != null && attributes.is(FlexGrammar.ATTRIBUTES)) { for (AstNode attribute : attributes.getChildren(FlexGrammar.ATTRIBUTE)) { if (attribute.getFirstChild().is(FlexGrammar.RESERVED_NAMESPACE)) { modifiersSet/*from w ww .jav a2 s . c o m*/ .add(attribute.getFirstChild(FlexGrammar.RESERVED_NAMESPACE).getFirstChild().getType()); } else if (attribute.getFirstChild().is(FlexGrammar.ATTRIBUTE_EXPR) && attribute.getFirstChild().getNumberOfChildren() == 1) { modifiersSet.add(attribute.getFirstChild().getFirstChild(FlexGrammar.IDENTIFIER).getFirstChild() .getType()); } } } return modifiersSet; }
From source file:org.terasology.utilities.CamelCaseMatcher.java
/** * @param commandName/*from www . j a v a 2s.c om*/ * @param commands * @return */ public static Set<String> getMatches(String queryStr, Collection<String> commands) { Set<String> matches = Sets.newHashSet(); String query = queryStr.replaceAll("\\*", ".*?"); query = query.replaceFirst("\\b([a-z]+)", "$1[a-z]*"); String re = "\\b(" + query.replaceAll("([A-Z][^A-Z]*)", "$1[^A-Z]*") + ".*?)\\b"; Pattern regex = Pattern.compile(re); for (String cmd : commands) { Matcher m = regex.matcher(cmd); if (m.find()) { matches.add(m.group()); } } return matches; }
From source file:net.diogobohm.timed.api.domain.Tag.java
public static Set<Tag> parseTagsFromString(String tagExpression) { String cleanTags = cleanExpression(tagExpression); Set<Tag> tagSet = Sets.newHashSet(); for (String tagName : cleanTags.split("#")) { if (!tagName.isEmpty()) { tagSet.add(new Tag(tagName)); }/* w w w .j a v a 2 s . co m*/ } return tagSet; }
From source file:io.druid.query.Queries.java
public static void verifyAggregations(List<AggregatorFactory> aggFactories, List<PostAggregator> postAggs) { Preconditions.checkNotNull(aggFactories, "aggregations cannot be null"); Preconditions.checkArgument(aggFactories.size() > 0, "Must have at least one AggregatorFactory"); final Set<String> aggNames = Sets.newHashSet(); for (AggregatorFactory aggFactory : aggFactories) { Preconditions.checkArgument(aggNames.add(aggFactory.getName()), "[%s] already defined", aggFactory.getName());//from ww w . j av a2 s. com } if (postAggs != null && !postAggs.isEmpty()) { final Set<String> combinedAggNames = Sets.newHashSet(aggNames); for (PostAggregator postAgg : postAggs) { final Set<String> dependencies = postAgg.getDependentFields(); final Set<String> missing = Sets.difference(dependencies, combinedAggNames); Preconditions.checkArgument(missing.isEmpty(), "Missing fields [%s] for postAggregator [%s]", missing, postAgg.getName()); Preconditions.checkArgument(combinedAggNames.add(postAgg.getName()), "[%s] already defined"); } } }
From source file:org.apache.kylin.common.util.ValueIterators.java
public static <T> T checkSame(Iterator<T> iterator) { Set<T> values = Sets.newHashSet(); while (iterator.hasNext()) { T element = iterator.next();/*from w ww .j a v a2s. c o m*/ values.add(element); } if (values.size() > 1) { throw new IllegalStateException("more than one distinct values exist in the collection:" + values); } return values.iterator().next(); }
From source file:org.apache.kylin.common.util.NumberIterators.java
public static <T extends Number> long checkSame(Iterator<T> iterator) { Set<Long> values = Sets.newHashSet(); while (iterator.hasNext()) { Number element = iterator.next(); values.add(element.longValue()); }/*from ww w . j a v a2 s . c o m*/ if (values.size() > 1) { throw new IllegalStateException("more than one distinct values exist in the collection:" + values); } return values.iterator().next(); }
From source file:com.demigodsrpg.util.ZoneUtil.java
public static int init(Plugin plugin) { // Get the plugin config PLUGIN_CONFIG = plugin.getConfig();/*ww w. j av a2 s . co m*/ // Load disabled worlds Set<String> enabledWorlds = Sets.newHashSet(); int erroredWorlds = 0; for (String world : PLUGIN_CONFIG.getStringList("active_worlds")) { enabledWorlds.add(world); erroredWorlds += Bukkit.getServer().getWorld(world) == null ? 1 : 0; } ENABLED_WORLDS.addAll(enabledWorlds); // Init WorldGuard stuff WorldGuardUtil.setWhenToOverridePVP(plugin, event -> event instanceof EntityDamageByEntityEvent && !inNoDGZone(((EntityDamageByEntityEvent) event).getEntity().getLocation())); return erroredWorlds; }
From source file:com.android.builder.internal.packaging.PackagedFileUpdates.java
/** * Creates a set of updates based on a map of update. This set will * contain one entry per entry in the set in a 1-1 match. * * @param set the set with updates//from ww w .j a v a 2s . c om * @return the transform set */ @NonNull static Set<PackagedFileUpdate> fromIncrementalRelativeFileSet(@NonNull Map<RelativeFile, FileStatus> set) { Set<PackagedFileUpdate> r = Sets.newHashSet(); for (Map.Entry<RelativeFile, FileStatus> entry : set.entrySet()) { r.add(new PackagedFileUpdate(entry.getKey(), entry.getKey().getOsIndependentRelativePath(), entry.getValue())); } return r; }
From source file:configuration.AuraUtilTestConfig.java
@Impl public static TestFilter auraTestFilter() { Collection<Class<? extends Annotation>> annotations = Sets.newHashSet(); annotations.add(Ignore.class); return new AnnotationTestFilter(annotations); }
From source file:org.elasticsearch.plugins.PluginsHelper.java
/** * Build a list of existing site plugins for a given environment * @param environment We look into Environment#pluginsFile() * @return A Set of existing site plugins *//* w ww. j av a 2 s. c o m*/ public static Set<String> sitePlugins(Environment environment) { File pluginsFile = environment.pluginsFile(); Set<String> sitePlugins = Sets.newHashSet(); if (!pluginsFile.exists() || !pluginsFile.isDirectory()) { return sitePlugins; } for (File pluginFile : pluginsFile.listFiles()) { if (new File(pluginFile, "_site").exists()) { sitePlugins.add(pluginFile.getName()); } } return sitePlugins; }