Example usage for com.google.common.collect ImmutableList of

List of usage examples for com.google.common.collect ImmutableList of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList of.

Prototype

@SuppressWarnings("unchecked")
    public static <E> ImmutableList<E> of() 

Source Link

Usage

From source file:de.metas.ui.web.window.datatypes.json.filters.JSONDocumentFilterDescriptor.java

public static List<JSONDocumentFilterDescriptor> ofCollection(
        @Nullable final Collection<DocumentFilterDescriptor> filters, final JSONOptions jsonOpts) {
    if (filters == null || filters.isEmpty()) {
        return ImmutableList.of();
    }//from   w ww.  j  av a 2s  .  c o m

    return filters.stream().map(filter -> new JSONDocumentFilterDescriptor(filter, jsonOpts))
            .collect(GuavaCollectors.toImmutableList());
}

From source file:com.facebook.presto.split.EmptySplitSource.java

@Override
public List<Split> getNextBatch(int maxSize) throws InterruptedException {
    return ImmutableList.of();
}

From source file:com.wrmsr.wava.compile.module.ModuleCompilationParticipant.java

default List<JDeclaration> createInterfaceDeclarations() {
    return ImmutableList.of();
}

From source file:org.ambraproject.wombat.freemarker.TemplateModelUtil.java

static ImmutableList<TemplateModel> getAsList(TemplateModel value) throws TemplateModelException {
    if (value == null)
        return ImmutableList.of();
    if (value instanceof TemplateSequenceModel) {
        ImmutableList.Builder<TemplateModel> builder = ImmutableList.builder();
        TemplateSequenceModel sequenceModel = (TemplateSequenceModel) value;
        int size = sequenceModel.size();
        for (int i = 0; i < size; i++) {
            builder.add(sequenceModel.get(i));
        }// w  w  w  .  java  2  s  .  co  m
        return builder.build();
    } else {
        return ImmutableList.of(value);
    }
}

From source file:org.apache.james.transport.mailets.remote.delivery.AddressesArrayToMailAddressListConverter.java

public static List<MailAddress> getAddressesAsMailAddress(Address[] addresses) {
    if (addresses == null) {
        return ImmutableList.of();
    }/*from   w  ww  .jav a  2 s  .c  o m*/
    return Arrays.asList(addresses).stream().map(address -> toMailAddress(address))
            .flatMap(OptionalUtils::toStream).collect(Guavate.toImmutableList());
}

From source file:org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider.java

@Nonnull
public static QueryIndexProvider compose(@Nonnull Collection<QueryIndexProvider> providers) {
    if (providers.isEmpty()) {
        return new QueryIndexProvider() {
            @Override//w  w w.ja  v  a  2  s .c  o m
            public List<QueryIndex> getQueryIndexes(NodeState nodeState) {
                return ImmutableList.of();
            }
        };
    } else if (providers.size() == 1) {
        return providers.iterator().next();
    } else {
        return new CompositeQueryIndexProvider(ImmutableList.copyOf(providers));
    }
}

From source file:com.b2international.index.compat.Highlighting.java

/**
 * Splits a string to a list of tokens using the specified Lucene analyzer.
 * /*w ww .j  a  v a2  s. co m*/
 * @param analyzer the analyzer determining token boundaries (may not be {@code null})
 * @param s the string to split
 * @return a list of tokens, or an empty list if {@code s} is {@code null} or empty
 */
public static List<String> split(Analyzer analyzer, final String s) {

    checkNotNull(analyzer, "analyzer");

    if (Strings.isNullOrEmpty(s)) {
        return ImmutableList.of();
    }

    final List<String> tokens = Lists.newArrayList();
    TokenStream stream = null;

    try {

        stream = analyzer.tokenStream(null, new StringReader(s));
        stream.reset();

        while (stream.incrementToken()) {
            tokens.add(stream.getAttribute(CharTermAttribute.class).toString());
        }

    } catch (final IOException ignored) {
        // Should not be thrown when using a string reader
    } finally {
        endAndCloseQuietly(stream);
    }

    return tokens;
}

From source file:io.prestosql.execution.scheduler.LegacyNetworkTopology.java

@Override
public List<String> getLocationSegmentNames() {
    return ImmutableList.of();
}

From source file:org.opendaylight.yangtools.yang.model.util.type.AbstractBaseType.java

AbstractBaseType(final QName qname) {
    this(SchemaPath.create(true, qname), ImmutableList.of());
}

From source file:com.spectralogic.ds3contractcomparator.print.utils.HtmlRowGeneratorUtils.java

/**
 * Retrieves the specified property of type {@link ImmutableList}
 *//*from  w ww .ja  va  2  s.c  om*/
public static <T, N> ImmutableList<N> getListPropertyFromObject(final Field field, final T object) {
    if (object == null) {
        return ImmutableList.of();
    }
    try {
        field.setAccessible(true);
        final Object objectField = field.get(object);
        if (objectField == null) {
            return ImmutableList.of();
        }
        if (objectField instanceof ImmutableList) {
            return (ImmutableList<N>) objectField;
        }
        throw new IllegalArgumentException(
                "Object should be of type ImmutableList, but was: " + object.getClass().toString());
    } catch (final IllegalAccessException e) {
        LOG.error("Could not retrieve list element " + field.getName() + " from object of class "
                + object.getClass().toString() + ": " + e.getMessage(), e);

        return ImmutableList.of();
    }
}