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:edu.mit.streamjit.util.bytecode.methodhandles.ProxyFactory.java

public <T> T createProxy(String name, Map<String, MethodHandle> methods, Class<T> iface,
        Class<?>... moreIfaces) {
    return iface.cast(createProxy(name, methods, Lists.asList(iface, moreIfaces)));
}

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

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

From source file:io.github.whiskeysierra.archer.Compiling.java

default List<IMessage> compile(Class<?> unit, Class<?>[] classes) throws IOException {
    return compile(toArray(Lists.asList(unit, classes), Class.class));
}

From source file:org.sonar.db.metric.MetricDao.java

public void insert(DbSession session, MetricDto item, MetricDto... others) {
    insert(session, Lists.asList(item, others));
}

From source file:uk.jamierocks.zinc.CommandService.java

/**
 * Registers all the commands from the given holder.
 *
 * @param plugin the owning plugin./*  w w w. j  a  va 2  s.co m*/
 * @param holder the command holder.
 */
public void registerCommands(Object plugin, Object holder) {
    Map<CommandCallable, Command> subCommands = Maps.newHashMap();
    Logger pluginLogger = LoggerFactory.getLogger(plugin.getClass());
    for (Method method : holder.getClass().getDeclaredMethods()) {
        if (method.isAnnotationPresent(Command.class)) {
            Command command = method.getAnnotation(Command.class);

            if (method.getParameterTypes().length == 2 && method.getParameterTypes()[0] == CommandSource.class
                    && method.getParameterTypes()[1] == CommandArgs.class
                    && method.getReturnType() == CommandResult.class) {

                CommandCallable commandCallable = new ZincCommandCallable(pluginLogger, command, holder,
                        method);
                if (StringUtils.isEmpty(command.parent())) {
                    this.game.getCommandManager().register(plugin, new ZincDispatcher(commandCallable),
                            Lists.asList(command.name(), command.aliases()));
                } else {
                    subCommands.put(commandCallable, command);
                }
            } else {
                if (method.getReturnType() != CommandResult.class) {
                    ZINC_LOGGER.error(String.format("Command has wrong return type: %s#%s Should be %s",
                            holder.getClass().getName(), method.getName(), CommandResult.class.getName()));
                }
                if (method.getParameterTypes().length != 2
                        || method.getParameterTypes()[0] != CommandSource.class
                        || method.getParameterTypes()[1] != CommandArgs.class) {
                    ZINC_LOGGER.error(
                            String.format("Command has wrong argument types: %s#%s Should have %s and %s",
                                    holder.getClass().getName(), method.getName(),
                                    CommandSource.class.getName(), CommandArgs.class.getName()));
                }
            }
        } else if (method.isAnnotationPresent(TabComplete.class)) {
            TabComplete tabComplete = method.getAnnotation(TabComplete.class);

            if (method.getParameterTypes().length == 2 && method.getParameterTypes()[0] == CommandSource.class
                    && method.getParameterTypes()[1] == String.class && method.getReturnType() == List.class) {

                final ZincDispatcher.SuggestionHandler suggestionHandler = (src, arguments) -> {
                    try {
                        return (List<String>) method.invoke(holder, src, arguments);
                    } catch (IllegalAccessException e) {
                        pluginLogger.error("Failed to invoke instance", e);
                    } catch (InvocationTargetException e) {
                        pluginLogger.error("Failed to invoke instance", e);
                    }
                    return Lists.newArrayList();
                };
                if (this.game.getCommandManager().get(tabComplete.name()).isPresent()
                        && this.game.getCommandManager().get(tabComplete.name()).get()
                                .getCallable() instanceof ZincDispatcher) {
                    ZincDispatcher dispatcher = (ZincDispatcher) this.game.getCommandManager()
                            .get(tabComplete.name()).get().getCallable();
                    dispatcher.setSuggestionHandler(suggestionHandler);
                } else {
                    ZINC_LOGGER.error(String.format(
                            "Tab complete attempted to register, but parent command wasn't found: %s",
                            tabComplete.name()));
                }
            } else {
                if (method.getReturnType() != List.class) {
                    ZINC_LOGGER.error(String.format("Tab complete has wrong return type: %s#%s Should be %s",
                            holder.getClass().getName(), method.getName(), List.class.getName()));
                }
                if (method.getParameterTypes().length != 2
                        || method.getParameterTypes()[0] != CommandSource.class
                        || method.getParameterTypes()[1] != String.class) {
                    ZINC_LOGGER.error(
                            String.format("Tab complete has wrong argument types: %s#%s Should have %s and %s",
                                    holder.getClass().getName(), method.getName(),
                                    CommandSource.class.getName(), String.class.getName()));
                }
            }
        }
    }
    for (CommandCallable commandCallable : subCommands.keySet()) {
        Command command = subCommands.get(commandCallable);
        if (this.game.getCommandManager().get(command.parent()).isPresent() && this.game.getCommandManager()
                .get(command.parent()).get().getCallable() instanceof ZincDispatcher) {
            ZincDispatcher dispatcher = (ZincDispatcher) this.game.getCommandManager().get(command.parent())
                    .get().getCallable();
            dispatcher.register(commandCallable, Lists.asList(command.name(), command.aliases()));
        } else {
            ZINC_LOGGER.error(String.format("Sub command was registered, but parent command wasn't found: %s",
                    command.parent()));
        }
    }
}

From source file:edu.mit.streamjit.impl.common.ParallelCompositeStreamVisitor.java

public ParallelCompositeStreamVisitor(StreamVisitor firstVisitor, StreamVisitor... moreVisitors) {
    this(ImmutableSet.copyOf(Lists.asList(firstVisitor, moreVisitors)));
}

From source file:com.viadeo.kasper.core.id.DefaultIDTransformer.java

@Override
public Map<ID, ID> to(final Format format, final ID firstId, final ID... restIds) {
    checkNotNull(format);//from  w w  w .ja va 2  s .  c o  m
    List<ID> ids = Lists.asList(firstId, restIds);
    checkArgument(Iterables.all(ids, Predicates.notNull()), "Each specified ids must be not null");

    return doConvertAll(format, ids);
}

From source file:com.yahoo.elide.core.filter.FilterPredicate.java

/**
 * Create a copy of this filter that is scoped by scope. This is used in calculating page totals, we need to
 * scope this filter in the context of it's parent.
 *
 * @param scope the path element to add to the head of the path
 * @return the scoped filter expression.
 *//* ww w .  j  a  v  a  2  s . co m*/
public FilterPredicate scopedBy(PathElement scope) {
    List<PathElement> pathElements = Lists.asList(scope, path.getPathElements().toArray(ELEMENT_ARRAY));
    return new FilterPredicate(new Path(pathElements), operator, values);
}

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

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

From source file:com.google.testing.compile.JavaSourcesSubject.java

@Override
public CompileTester processedWith(Processor first, Processor... rest) {
    return processedWith(Lists.asList(first, rest));
}