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:com.sora.util.akatsuki.RetainedStateIntegrationTestBase.java

/**
 * Generates a class for each field, each class extends the previous class;
 * left most spec argument will be the top most class
 *///from  w w w. j  a  v  a2  s . co m
protected RetainedStateTestEnvironment testInheritance(boolean cache, TestField first, TestField... rest) {
    final List<TestField> fields = Lists.asList(first, rest);
    TestSource lastClass = null;
    List<TestSource> sources = new ArrayList<>();
    for (TestField field : fields) {
        final TestSource clazz = new TestSource(TEST_PACKAGE, generateClassName(), Modifier.PUBLIC)
                .appendFields(field.createFieldSpec());
        if (lastClass != null)
            lastClass.superClass(clazz);
        lastClass = clazz;
        sources.add(clazz);
    }
    if (!cache) {
        sources.get(0).appendTransformation((builder, s) -> builder.addAnnotation(
                AnnotationSpec.builder(AkatsukiConfig.class).addMember("optFlags", "{}").build()));
    }
    final RetainedStateTestEnvironment environment = new RetainedStateTestEnvironment(this, sources);
    environment.tester().invokeSaveAndRestore();
    environment.tester().testSaveRestoreInvocation(ALWAYS, BundleRetainerTester.CLASS_EQ,
            fields.stream().filter(tf -> tf instanceof RetainedTestField).map(tf -> (RetainedTestField) tf)
                    .collect(Collectors.toList()),
            f -> 1);
    return environment;
}

From source file:com.analog.lyric.dimple.data.DataStack.java

public DataStack(DataLayer<?> firstLayer, DataLayer<?>... additionalLayers) {
    this(Lists.asList(firstLayer, additionalLayers));
}

From source file:com.b2international.commons.concurrent.equinox.ForkJoinUtils.java

public static void runJobsInParallel(final Job firstJob, final Job... restJobs) {
    runJobsInParallel(Lists.asList(firstJob, restJobs));
}

From source file:com.b2international.snowowl.core.request.ResourceRequestBuilder.java

public final B setFields(String first, String... rest) {
    return setFields(Lists.asList(first, rest));
}

From source file:com.google.android.testing.nativedriver.client.AdbConnectionBuilder.java

private static String joinPath(String root, String[] path) {
    if (root.endsWith(File.separator)) {
        root = root.substring(0, root.length() - 1);
    }//ww  w . j  a v a  2  s .  co m

    return Joiner.on(File.separator).join(Lists.asList(root, path));
}

From source file:com.b2international.snowowl.datastore.server.oplock.AbstractOperationLockManager.java

@Override
public void lock(final C context, final long timeoutMillis, final IOperationLockTarget firstTarget,
        final IOperationLockTarget... restTargets) throws OperationLockException, InterruptedException {
    lock(context, timeoutMillis, Lists.asList(firstTarget, restTargets));
}

From source file:org.vclipse.configscan.views.actions.SearchContributionItem.java

public void fill(Composite parent) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 3;/*from ww w.  jav a 2s.c  o  m*/
    gridLayout.numColumns = 2;
    mainComposite.setLayout(gridLayout);

    new Label(mainComposite, SWT.NONE).setText("Filter: ");

    FontData[] fdata = parent.getDisplay().getSystemFont().getFontData();
    searchTextWidget = new Text(mainComposite, SWT.BORDER);
    searchTextWidget.setFont(new Font(parent.getDisplay(), new FontData(fdata[0].getName(), 8, SWT.NORMAL)));

    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.heightHint = 10;

    searchTextWidget.setLayoutData(gridData);
    searchTextWidget.setTextLimit(50);
    searchTextWidget.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            String text = searchTextWidget.getText();
            if (text.isEmpty()) {
                viewer.removeFilter(textFilter);
            } else {
                textFilter.setSearchText(text);
                List<ViewerFilter> list = Lists.asList(textFilter, viewer.getFilters());
                viewer.setFilters(list.toArray(new ViewerFilter[list.size()]));
            }
        }
    });
}

From source file:com.yahoo.yqlplus.engine.internal.bytecode.types.gambit.BytecodeCatchBuilder.java

@Override
public ScopedBuilder on(String varName, Class<?> exceptionType, Class<?>... moreExceptionTypes) {
    CatchClause catchClause = new CatchClause(source, parent.child());
    TypeWidget unifiedType = source.getValueTypeAdapter().adaptInternal(exceptionType);
    for (Class<?> c : Lists.asList(exceptionType, moreExceptionTypes)) {
        TypeWidget t = source.getValueTypeAdapter().adaptInternal(c);
        catchClause.exceptionInternalNames.add(t.getJVMType().getInternalName());
        unifiedType = source.getValueTypeAdapter().unifyTypes(unifiedType, t);
    }//from w w  w. ja v  a  2 s.c o  m
    AssignableValue local = catchClause.allocate(varName, unifiedType);
    catchClause.body.add(local.write(unifiedType));
    catchClauses.add(catchClause);
    return catchClause;
}

From source file:com.b2international.snowowl.datastore.oplock.OperationLockRunner.java

/**
 * Ensures that the specified locks are acquired for the given context while a {@link Runnable} is executing; cleans
 * up acquired locks if the runnable finishes or an exception is thrown from it.
 * //www. j  av  a 2s .co m
 * @param runnable the runnable to call with the locks held (may not be {@code null})
 * @param context the lock context (may not be {@code null})
 * @param timeoutMillis the maximum allowed time in milliseconds in which this call may block (must be {@link #NO_TIMEOUT}, zero or positive)
 * @param firstTarget the first (or only) target to hold while running (may not be {@code null})
 * @param restTargets subsequent targets to hold while running (may not be {@code null}; individual elements may not be {@code null})
 * @throws OperationLockException when one or more locks for the given targets could not be acquired or released for some reason
 * @throws InterruptedException if waiting for the requested locks to be acquired is interrupted
 * @throws InvocationTargetException if the specified runnable throws an exception
 */
public void run(final Runnable runnable, final C context, final long timeoutMillis,
        final IOperationLockTarget firstTarget, final IOperationLockTarget... restTargets)
        throws OperationLockException, InterruptedException, InvocationTargetException {

    run(runnable, context, timeoutMillis, Lists.asList(firstTarget, restTargets));
}

From source file:org.eclipse.recommenders.internal.codesearch.rcp.views.AbstractEmbeddedEditorWrapper.java

private String[] getExampleQueries() {
    final String[] providedExamples = getExampleQueriesInternal();
    final String[] items = new String[providedExamples.length + 1];
    return Lists.asList("Select Example Query...", providedExamples).toArray(items);
}