List of usage examples for com.google.common.collect ImmutableList get
E get(int index);
From source file:io.leishvl.core.util.LocaleUtils.java
/** * Obtains the locale that best-matches with the specified string. * @param str input string./* w w w. ja v a2 s . c om*/ * @return the locale that best-matches with the specified string, or {@code null}. */ public static @Nullable Locale getLocale(final @Nullable String str) { Locale locale = null; if (isNotBlank(str)) { final ImmutableList<Locale> locales = availableLocaleList(); for (int i = 0; i < locales.size() && locale == null; i++) { final Locale item = locales.get(i); if (containsIgnoreCase(str, item.getDisplayCountry())) { locale = item; } } } return locale; }
From source file:eu.eubrazilcc.lvl.core.util.LocaleUtils.java
/** * Obtains the locale that best-matches with the specified string. * @param str input string.// w w w . j a v a 2 s. c om * @return the locale that best-matches with the specified string, or {@code null}. */ public static @Nullable Locale getLocale(final @Nullable String str) { Locale locale = null; if (isNotBlank(str)) { final ImmutableList<Locale> locales = availableLocaleList(); for (int i = 0; i < locales.size() && locale == null; i++) { final Locale item = locales.get(i); if (StringUtils.containsIgnoreCase(str, item.getDisplayCountry())) { locale = item; } } } return locale; }
From source file:com.mycompany.mavenproject3.Interpreter.java
public static Cons makeListHelp(ImmutableList<Sexpression> list) { // ImmutableList<Sexpression> list = ImmutableList.copyOf(sexpressions); if (list.isEmpty()) { return new Nil(); }// w ww .java 2s.c om if (list.size() == 1) { return new Cons(list.get(0), new Nil()); } else { return new Cons(list.get(0), makeListHelp(list.subList(1, list.size() - 1))); } }
From source file:com.facebook.buck.features.rust.RustAssumptions.java
public static void assumeNightly(ProjectWorkspace workspace) throws IOException, InterruptedException { BuildRuleResolver resolver = new TestActionGraphBuilder(); SourcePathResolver pathResolver = DefaultSourcePathResolver.from(new SourcePathRuleFinder(resolver)); RustPlatform rustPlatform = RustPlatformFactory.of(FakeBuckConfig.builder().build(), new ExecutableFinder()) .getPlatform("rust", CxxPlatformUtils.DEFAULT_PLATFORM); ImmutableList<String> rustc = rustPlatform.getRustCompiler().resolve(resolver) .getCommandPrefix(pathResolver); Result res = workspace.runCommand(rustc.get(0), "-Zhelp"); assumeTrue("Requires nightly Rust", res.getExitCode() == 0); }
From source file:com.facebook.presto.metadata.QualifiedObjectName.java
@JsonCreator public static QualifiedObjectName valueOf(String name) { requireNonNull(name, "name is null"); ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(name)); checkArgument(ids.size() == 3, "Invalid name %s", name); return new QualifiedObjectName(ids.get(0), ids.get(1), ids.get(2)); }
From source file:com.tarvon.fractala.util.Point3D.java
/** * Converts the provided spherical coordinate to a Cartesian point using the * provided sine/cosine tables.//w w w.ja v a2s. c o m * <p> * This method uses the cached tables to improve speed of translation. The * provided x,y coordinate indicates the relative phi/theta values in the * sin/cos tables, which should be of the form generated in * {@link ProjectionPool}. * <p> * The result will be a point in 3D Cartesian space represented by an * instance of this class. * <p> * For details of the method used for conversion see <a * href="http://en.wikipedia.org/wiki/Spherical_coordinate_system" * >http://en.wikipedia.org/wiki/Spherical_coordinate_system</a> * * @param sin * the sine table. * @param cos * the cosine table. * @param r * the distance from the origin point. * @param x * the phi coordinate location within the provided arrays. * @param y * the theta coordinate location within the provided arrays. * @return the created point. */ public static Point3D ofSpherical(ImmutableList<Double> sin, ImmutableList<Double> cos, double r, int x, int y) { double nx = r * cos.get(x) * sin.get(y); double ny = r * sin.get(x) * sin.get(y); double nz = r * cos.get(y); return new Point3D(nx, ny, nz); }
From source file:com.facebook.presto.metadata.QualifiedTableName.java
@JsonCreator public static QualifiedTableName valueOf(String tableName) { requireNonNull(tableName, "tableName is null"); ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(tableName)); checkArgument(ids.size() == 3, "Invalid tableName %s", tableName); return new QualifiedTableName(ids.get(0), ids.get(1), ids.get(2)); }
From source file:grakn.core.graql.reasoner.plan.GraqlTraversalPlanner.java
/** * @param query top level query for which the plan is constructed * @param atoms list of current atoms of interest * @param subs extra substitutions/* ww w . ja v a2 s .com*/ * @return an optimally ordered list of provided atoms */ private static List<Atom> refinePlan(ReasonerQueryImpl query, List<Atom> atoms, Set<IdPredicate> subs) { List<Atom> candidates = subs.isEmpty() ? atoms : atoms.stream().filter(at -> at.getPredicates(IdPredicate.class).findFirst().isPresent()) .collect(Collectors.toList()); ImmutableList<Atom> initialPlan = planFromTraversal(atoms, atomsToPattern(atoms, subs), query.tx()); if (candidates.contains(initialPlan.get(0)) || candidates.isEmpty()) { return initialPlan; } else { Atom first = optimalCandidate(candidates); List<Atom> atomsToPlan = new ArrayList<>(atoms); if (first != null) { atomsToPlan.remove(first); Set<IdPredicate> extraSubs = first.getVarNames().stream() .filter(v -> subs.stream().noneMatch(s -> s.getVarName().equals(v))) .map(v -> IdPredicate.create(v, ConceptId.of(PLACEHOLDER_ID), query)) .collect(Collectors.toSet()); return Stream .concat(Stream.of(first), refinePlan(query, atomsToPlan, Sets.union(subs, extraSubs)).stream()) .collect(Collectors.toList()); } else { return refinePlan(query, atomsToPlan, subs); } } }
From source file:com.google.api.tools.framework.aspects.http.RestAnalyzer.java
static RestMethod createCustomMethod(Method method, HttpAttribute httpConfig, String customNamePrefix) { ImmutableList<PathSegment> path = httpConfig.getFlatPath(); PathSegment lastSegment = path.get(path.size() - 1); // Determine base name. String customName = ""; if (lastSegment instanceof LiteralSegment) { customName = ((LiteralSegment) lastSegment).getLiteral(); path = path.subList(0, path.size() - 1); } else {/*from ww w.j a v a2s . c om*/ if (method.getModel().getConfigVersion() > 1) { // From version 2 on, we generate a meaningful name here. customName = method.getSimpleName(); } else if (customNamePrefix.isEmpty()) { // Older versions use the prefix or derive from the http method. customName = httpConfig.getMethodKind().toString().toLowerCase(); } } // Prepend prefix. if (!customNamePrefix.isEmpty() && !customName.toLowerCase().startsWith(customNamePrefix.toLowerCase())) { customName = customNamePrefix + ensureUpperCase(customName); } // Ensure effective start is lower case. customName = ensureLowerCase(customName); return RestMethod.create(method, RestKind.CUSTOM, buildCollectionName(path), customName); }
From source file:net.techcable.pineapple.collect.ImmutableLists.java
@Nonnull public static <T, U> ImmutableList<U> transform(ImmutableList<T> list, Function<T, U> transformer) { ImmutableList.Builder<U> resultBuilder = builder(checkNotNull(list, "Null list").size()); for (int i = 0; i < list.size(); i++) { T oldElement = list.get(i); U newElement = checkNotNull(transformer, "Null transformer").apply(oldElement); if (newElement == null) throw new NullPointerException( "Transformer " + transformer.getClass().getTypeName() + " returned null."); resultBuilder.add(newElement);//from www .j av a 2 s. com } return resultBuilder.build(); }