Example usage for com.google.common.collect Lists asList

List of usage examples for com.google.common.collect Lists asList

Introduction

In this page you can find the example usage for com.google.common.collect Lists asList.

Prototype

public static <E> List<E> asList(@Nullable E first, E[] rest) 

Source Link

Document

Returns an unmodifiable list containing the specified first element and backed by the specified array of additional elements.

Usage

From source file:brooklyn.test.HttpTestUtils.java

public static void assertContentNotContainsText(final String url, final String phrase,
        final String... additionalPhrases) {
    try {//from   ww  w  .ja  v a2  s.co m
        String contents = getContent(url);
        Assert.assertTrue(contents != null);
        for (String text : Lists.asList(phrase, additionalPhrases)) {
            if (contents.contains(text)) {
                LOG.warn("CONTENTS OF URL " + url + " HAS TEXT: " + text + "\n" + contents);
                Assert.fail("URL " + url + " contain text: " + text);
            }
        }
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}

From source file:org.sonar.sslr.grammar.LexerfulGrammarBuilder.java

/**
 * Creates parsing expression - "exclusive till".
 * Equivalent of expression {@code zeroOrMore(nextNot(firstOf(e, rest)), anyToken())}.
 * Do not overuse this method.// w  ww . j  a va2 s .c  o m
 *
 * @param e1  first sub-expression
 * @param rest  rest of sub-expressions
 * @throws IllegalArgumentException if any of given arguments is not a parsing expression
 */
public Object exclusiveTill(Object e1, Object... rest) {
    return exclusiveTill(new FirstOfExpression(convertToExpressions(Lists.asList(e1, rest))));
}

From source file:org.splevo.jamopp.diffing.JaMoPPDiffer.java

/**
 * Get the ignore file configuration for the provided options.
 *
 * @param diffingOptions/*from   ww w .j a  v  a  2 s.  c  o  m*/
 *            The options map.
 * @return The list of file names to ignore.
 */
private List<String> loadIgnoreFileConfiguration(Map<String, String> diffingOptions) {
    final List<String> ignoreFiles;
    if (diffingOptions.containsKey(OPTION_JAMOPP_IGNORE_FILES)) {
        final String diffingRuleRaw = diffingOptions.get(OPTION_JAMOPP_IGNORE_FILES);
        final String[] parts = diffingRuleRaw.split(LINE_SEPARATOR);
        ignoreFiles = Lists.newArrayList();
        for (final String rule : parts) {
            ignoreFiles.add(rule);
        }
    } else {
        ignoreFiles = Lists.asList("package-info.java", new String[] {});
    }
    return ignoreFiles;
}

From source file:com.sora.util.akatsuki.compiler.CodeGenerationTestBase.java

protected TestEnvironment testInheritance(boolean cache, Field first, Field... rest) {
    final List<Field> fields = Lists.asList(first, rest);
    JavaSource lastClass = null;//from   ww  w . ja  v  a 2  s .co m
    List<JavaSource> sources = new ArrayList<>();
    for (Field field : fields) {
        final JavaSource clazz = new JavaSource(TEST_PACKAGE, generateClassName(), Modifier.PUBLIC)
                .fields(field.createFieldSpec());
        if (lastClass != null)
            lastClass.superClass(clazz);
        lastClass = clazz;
        sources.add(clazz);
    }
    if (!cache) {
        sources.get(0).builderTransformer(
                (builder, s) -> builder.addAnnotation(AnnotationSpec.builder(RetainConfig.class)
                        .addMember("optimisation", "$T.$L", Optimisation.class, Optimisation.NONE).build()));
    }
    final TestEnvironment environment = new TestEnvironment(this, sources);
    environment.invokeSaveAndRestore();
    environment.testSaveRestoreInvocation(n -> true, TestEnvironment.CLASS, fields);
    return environment;
}

From source file:org.apache.brooklyn.util.http.HttpAsserts.java

public static void assertErrorContentNotContainsText(final String url, final String phrase,
        final String... additionalPhrases) {
    try {/*from  w ww . j a  va  2  s .co m*/
        String err = HttpTool.getErrorContent(url);
        Asserts.assertTrue(err != null);
        for (String text : Lists.asList(phrase, additionalPhrases)) {
            if (err.contains(text)) {
                LOG.warn("CONTENTS OF URL " + url + " HAS TEXT: " + text + "\n" + err);
                Asserts.fail("URL " + url + " contain text: " + text);
            }
        }
    } catch (Exception e) {
        throw propagateAsAssertionError(e);
    }
}

From source file:org.apache.streams.datasift.serializer.DatasiftTwitterActivitySerializer.java

public static String formatId(String... idparts) {
    return Joiner.on(":").join(Lists.asList("id:twitter", idparts));
}

From source file:org.sonar.sslr.grammar.GrammarBuilder.java

/**
 * Creates parsing expression - "next"./* w w  w  .j a  v a 2  s.  c o  m*/
 * Convenience method equivalent to calling {@code next(sequence(e1, rest))}.
 *
 * @param e1  first sub-expression
 * @param rest  rest of sub-expressions
 * @throws IllegalArgumentException if any of given arguments is not a parsing expression
 * @see #next(Object)
 * @see #sequence(Object, Object)
 */
public final Object next(Object e1, Object... rest) {
    return new NextExpression(new SequenceExpression(convertToExpressions(Lists.asList(e1, rest))));
}

From source file:com.b2international.snowowl.datastore.server.ServerDbUtils.java

/**
 * Creates an index for the CDO_CREATED DB column for all tables mapped to the specified package.
 * <br>This method, first, tried to drop the existing CDO_CREATED index, if any.
 * @param nsUri the unique namespace URI for the package containing all classifiers that are mapped to an ORM backend.
 * @param otherNsUris additional packages.
 *///from   ww  w  . ja  v  a 2  s .c  o  m
public static void createCdoCreatedIndexOnTables(final String nsUri, final String... otherNsUris) {
    Preconditions.checkNotNull(nsUri, "Namespace URI argument cannot be null.");

    final Set<ICDORepository> repositories = Sets.newHashSet(
            Iterables.transform(Lists.asList(nsUri, otherNsUris), new Function<String, ICDORepository>() {
                @Override
                public ICDORepository apply(final String _nsUri) {
                    return getRepository(_nsUri);
                }
            }));

    Collections3.forEach(repositories, new Procedure<ICDORepository>() {
        @Override
        protected void doApply(final ICDORepository repository) {
            createCdoCreatedIndexOnTables(repository);
        }
    });
}

From source file:brooklyn.test.HttpTestUtils.java

public static void assertErrorContentContainsText(final String url, final String phrase,
        final String... additionalPhrases) {
    try {/*from w  w  w.ja va  2  s  . c o  m*/
        String contents = getErrorContent(url);
        Assert.assertTrue(contents != null && contents.length() > 0);
        for (String text : Lists.asList(phrase, additionalPhrases)) {
            if (!contents.contains(text)) {
                LOG.warn("CONTENTS OF URL " + url + " MISSING TEXT: " + text + "\n" + contents);
                Assert.fail("URL " + url + " does not contain text: " + text);
            }
        }
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}

From source file:org.apache.calcite.plan.RelOptRule.java

/**
 * Creates a list of child operands that matches child relational
 * expressions in any order./*from w  ww .j  a va  2  s . com*/
 *
 * <p>This is useful when matching a relational expression which
 * can have a variable number of children. For example, the rule to
 * eliminate empty children of a Union would have operands</p>
 *
 * <blockquote>Operand(Union, true, Operand(Empty))</blockquote>
 *
 * <p>and given the relational expressions</p>
 *
 * <blockquote>Union(LogicalFilter, Empty, LogicalProject)</blockquote>
 *
 * <p>would fire the rule with arguments</p>
 *
 * <blockquote>{Union, Empty}</blockquote>
 *
 * <p>It is up to the rule to deduce the other children, or indeed the
 * position of the matched child.</p>
 *
 * @param first First child operand
 * @param rest  Remaining child operands (may be empty)
 * @return List of child operands that matches child relational
 *   expressions in any order
 */
public static RelOptRuleOperandChildren unordered(RelOptRuleOperand first, RelOptRuleOperand... rest) {
    return new RelOptRuleOperandChildren(RelOptRuleOperandChildPolicy.UNORDERED, Lists.asList(first, rest));
}