List of usage examples for com.google.common.collect ImmutableSet toArray
<T> T[] toArray(T[] a);
From source file:com.github.jsdossier.tools.Compile.java
public static void main(String[] args) throws Exception { Flags flags = new Flags(); CmdLineParser parser = new CmdLineParser(flags); parser.setUsageWidth(79);//from ww w.j a v a 2 s.co m parser.parseArgument(args); FileSystem fs = FileSystems.getDefault(); final Path closure = fs.getPath(flags.closure).toAbsolutePath(); ErrorManager errorManager = new PrintStreamErrorManager(System.err); JsFileParser jsFileParser = new JsFileParser(errorManager); List<DependencyInfo> info = new ArrayList<>(flags.inputs.size()); for (String path : flags.inputs) { Path absPath = fs.getPath(path).toAbsolutePath(); Path closureRelativePath = closure.relativize(absPath); info.add(jsFileParser.parseFile(absPath.toString(), closureRelativePath.toString(), new String(Files.readAllBytes(absPath), UTF_8))); } List<DependencyInfo> allDeps = new LinkedList<>(info); allDeps.addAll(new DepsFileParser(errorManager).parseFile(closure.resolve("deps.js").toString())); List<DependencyInfo> sortedDeps = new SortedDependencies<>(allDeps).getSortedDependenciesOf(info); ImmutableSet<String> compilerFlags = FluentIterable.from(sortedDeps) .transform(new Function<DependencyInfo, String>() { @Override public String apply(DependencyInfo input) { return "--js=" + closure.resolve(input.getPathRelativeToClosureBase()).toAbsolutePath() .normalize().toString(); } }).append("--js=" + closure.resolve("base.js")).append(flags.flags).toSet(); CommandLineRunner.main(compilerFlags.toArray(new String[compilerFlags.size()])); }
From source file:com.google.javascript.jscomp.newtypes.ObjectType.java
static ImmutableSet<ObjectType> joinSets(ImmutableSet<ObjectType> objs1, ImmutableSet<ObjectType> objs2) { if (objs1.isEmpty()) { return objs2; } else if (objs2.isEmpty()) { return objs1; }//from w ww.j a va2 s .co m ObjectType[] objs1Arr = objs1.toArray(new ObjectType[0]); ObjectType[] keptFrom1 = Arrays.copyOf(objs1Arr, objs1Arr.length); ImmutableSet.Builder<ObjectType> newObjs = ImmutableSet.builder(); for (ObjectType obj2 : objs2) { boolean addedObj2 = false; for (int i = 0; i < objs1Arr.length; i++) { ObjectType obj1 = objs1Arr[i]; NominalType nominalType1 = obj1.nominalType; NominalType nominalType2 = obj2.nominalType; if (areRelatedClasses(nominalType1, nominalType2)) { if (nominalType2 == null && nominalType1 != null && !obj1.isSubtypeOf(obj2) || nominalType1 == null && nominalType2 != null && !obj2.isSubtypeOf(obj1)) { // Don't merge other classes with record types break; } keptFrom1[i] = null; addedObj2 = true; // obj1 and obj2 may be in a subtype relation. // Even then, we want to join them because we don't want to forget // any extra properties in the subtype object. newObjs.add(join(obj1, obj2)); break; } } if (!addedObj2) { newObjs.add(obj2); } } for (ObjectType o : keptFrom1) { if (o != null) { newObjs.add(o); } } return newObjs.build(); }
From source file:net.tsquery.data.hbase.IDMap.java
public String[] getMetrics() throws IOException { ImmutableBiMap<String, ID> metricsMap = syncMetricsLoader.get(); ImmutableSet<String> strings = metricsMap.keySet(); return strings.toArray(new String[strings.size()]); }
From source file:org.n52.movingcode.runtime.coderepository.AbstractRepository.java
@Override public PID[] getPackageIDs() { ImmutableSet<PID> s = inventory.getPackageIDs(); return s.toArray(new PID[s.size()]); }
From source file:org.n52.movingcode.runtime.coderepository.AbstractRepository.java
@Override public String[] getFunctionIDs() { ImmutableSet<String> s = inventory.getFunctionIDs(); return s.toArray(new String[s.size()]); }
From source file:org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ImmutableModuleExclusionSet.java
ImmutableModuleExclusionSet(ImmutableSet<AbstractModuleExclusion> delegate) { this.delegate = delegate; this.elements = delegate.toArray(new AbstractModuleExclusion[0]); this.hashCode = delegate.hashCode(); }
From source file:org.graylog2.indexer.MongoIndexSetRegistry.java
@Override public String[] getManagedIndices() { final ImmutableSet.Builder<String> indexNamesBuilder = ImmutableSet.builder(); for (MongoIndexSet indexSet : findAllMongoIndexSets()) { indexNamesBuilder.add(indexSet.getManagedIndices()); }/*from w w w . j a v a 2 s. c om*/ final ImmutableSet<String> indexNames = indexNamesBuilder.build(); return indexNames.toArray(new String[0]); }
From source file:org.graylog2.indexer.MongoIndexSetRegistry.java
@Override public String[] getIndexWildcards() { final ImmutableSet.Builder<String> wildcardsBuilder = ImmutableSet.builder(); for (MongoIndexSet indexSet : findAllMongoIndexSets()) { if (indexSet.getConfig().isWritable()) { wildcardsBuilder.add(indexSet.getIndexWildcard()); }/*from www.j a va 2 s .c o m*/ } final ImmutableSet<String> wildcards = wildcardsBuilder.build(); return wildcards.toArray(new String[0]); }
From source file:org.graylog2.indexer.MongoIndexSetRegistry.java
@Override public String[] getWriteIndexAliases() { final ImmutableSet.Builder<String> indexNamesBuilder = ImmutableSet.builder(); for (MongoIndexSet indexSet : findAllMongoIndexSets()) { if (indexSet.getConfig().isWritable()) { indexNamesBuilder.add(indexSet.getWriteIndexAlias()); }/* ww w .ja v a 2 s. co m*/ } final ImmutableSet<String> indexNames = indexNamesBuilder.build(); return indexNames.toArray(new String[0]); }
From source file:es.upm.dit.xsdinferencer.conversion.converterimpl.automatontoregex.ChareConverter.java
/** * Given an equivalence class and an automaton, it creates a factor, which is correctly wrapped depending on the source words info of the given automaton. * @param eqClass the equivalence class. * @param automaton the automaton./*from w w w .ja v a 2s. co m*/ * @return a wrapped factor. */ protected RegularExpression generateWrappedFactorRegularExpression(EquivalenceClass eqClass, ExtendedAutomaton automaton) { RegularExpression unwrappedFactor; if (eqClass.size() == 1) { unwrappedFactor = eqClass.iterator().next(); } else { ImmutableSet<SchemaElement> elementsOfFactor = ImmutableSet.copyOf(eqClass); unwrappedFactor = new Choice(elementsOfFactor.toArray(new RegularExpression[elementsOfFactor.size()])); } Map<String, Integer> factorMinMaxOccurrences = automaton.getFactorMinMaxOccurrences(eqClass); int max = factorMinMaxOccurrences.get("max"); int min = factorMinMaxOccurrences.get("min"); RegularExpression factor = unwrappedFactor; if (min == 1 && max == 1) { factor = unwrappedFactor; } else if (min == 0 && max == 1) { factor = new Optional(unwrappedFactor); } else if (min == 0 && max > 1) { factor = new Repeated(unwrappedFactor); } else if (min > 0 && max > 1) { factor = new RepeatedAtLeastOnce(unwrappedFactor); } else { throw new IllegalArgumentException("For the equivalence class: " + eqClass.toString() + " getFactorMinMaxOccurrences() method has returned min=" + min + " max=" + max + " which does not make sense.\n" + "The only way that this may have happened is that an automaton with invalid sources word info had been provided."); } return factor; }