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

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

Introduction

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

Prototype

@SuppressWarnings({ "unchecked" })
    public static <E> ImmutableSet<E> of() 

Source Link

Usage

From source file:io.sidecar.util.CollectionUtils.java

public static <T> ImmutableSet<T> filterNulls(Set<T> orig) {
    if (orig == null) {
        return ImmutableSet.of();
    }/*from  ww  w . j a v a2  s . c  o m*/
    return ImmutableSet.copyOf(Iterables.filter(orig, new Predicate<T>() {
        @Override
        public boolean apply(T t) {
            return t != null;
        }
    }));
}

From source file:com.spotify.heroic.metadata.FindSeriesStream.java

public static FindSeriesStream of() {
    return new FindSeriesStream(ImmutableSet.of());
}

From source file:org.jclouds.util.Modules2.java

public static Iterable<Module> modulesFromCommaDelimitedString(String moduleClasses) {
    Iterable<Module> modules = ImmutableSet.of();
    if (moduleClasses != null) {
        Iterable<String> transformer = ImmutableList.copyOf(on(',').split(moduleClasses));
        modules = transform(transformer, new Function<String, Module>() {

            @Override/*w  ww. j  av a  2 s.  c  o m*/
            public Module apply(String from) {
                try {
                    return (Module) Class.forName(from).newInstance();
                } catch (InstantiationException e) {
                    throw new RuntimeException("error instantiating " + from, e);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException("error instantiating " + from, e);
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException("error instantiating " + from, e);
                }
            }

        });
    }
    return modules;
}

From source file:com.facebook.buck.rules.visibility.VisibilityPatterns.java

@SuppressWarnings("unchecked")
public static ImmutableSet<VisibilityPattern> createFromStringList(CellPathResolver cellNames, String paramName,
        @Nullable Object value, UnconfiguredBuildTarget target) {
    if (value == null) {
        return ImmutableSet.of();
    }/*from   w  ww  .  ja  v  a 2s .c  o m*/
    if (!(value instanceof List)) {
        throw new RuntimeException(String.format("Expected an array for %s but was %s", paramName, value));
    }
    List<String> originalPatterns = (List<String>) value;
    ImmutableSet.Builder<VisibilityPattern> patterns = ImmutableSet
            .builderWithExpectedSize(originalPatterns.size());
    for (String visibility : originalPatterns) {
        try {
            patterns.add(VisibilityPatternParser.parse(cellNames, visibility));
        } catch (IllegalArgumentException e) {
            throw new HumanReadableException(e,
                    "Bad visibility expression: %s listed %s in its %s argument, but only %s "
                            + "or fully qualified target patterns are allowed (i.e. those starting with "
                            + "// or a cell).",
                    target.getFullyQualifiedName(), visibility, paramName,
                    VisibilityPatternParser.VISIBILITY_PUBLIC);
        }
    }
    return patterns.build();
}

From source file:com.querydsl.sql.RelationalPathExtractor.java

public static Set<RelationalPath<?>> extract(QueryMetadata md) {
    Set<RelationalPath<?>> known = ImmutableSet.of();
    known = DEFAULT.visitJoins(md.getJoins(), known);
    if (md.getProjection() != null) {
        known = md.getProjection().accept(DEFAULT, known);
    }/*from w ww  .  j  a v a2  s. com*/
    for (OrderSpecifier<?> o : md.getOrderBy()) {
        known = o.getTarget().accept(DEFAULT, known);
    }
    for (Expression<?> g : md.getGroupBy()) {
        known = g.accept(DEFAULT, known);
    }
    if (md.getHaving() != null) {
        known = md.getHaving().accept(DEFAULT, known);
    }
    if (md.getWhere() != null) {
        known = md.getWhere().accept(DEFAULT, known);
    }
    return known;
}

From source file:com.isotrol.impe3.pms.core.obj.Builders.java

static <T> ImmutableSet<T> build(ImmutableSet.Builder<T> builder) {
    if (builder == null) {
        return ImmutableSet.of();
    }/* www .j  a  va2s  .c  om*/
    return builder.build();
}

From source file:com.facebook.buck.core.model.targetgraph.TargetGraphFactory.java

public static TargetGraph newInstance(Iterable<TargetNode<?>> nodes) {
    Map<BuildTarget, TargetNode<?>> builder = new HashMap<>();
    for (TargetNode<?> node : nodes) {
        builder.put(node.getBuildTarget(), node);
        BuildTarget unflavoredTarget = node.getBuildTarget().withoutFlavors();
        if (node.getBuildTarget().isFlavored() && !builder.containsKey(unflavoredTarget)) {
            builder.put(unflavoredTarget, node.withFlavors(ImmutableSet.of()));
        }/*from w w  w.j a  v a  2  s .c  o  m*/
    }
    ImmutableMap<BuildTarget, TargetNode<?>> map = ImmutableMap.copyOf(builder);

    MutableDirectedGraph<TargetNode<?>> graph = new MutableDirectedGraph<>();
    for (TargetNode<?> node : map.values()) {
        graph.addNode(node);
        for (BuildTarget dep : node.getBuildDeps()) {
            graph.addEdge(node, Objects.requireNonNull(map.get(dep), dep::toString));
        }
    }
    return new TargetGraph(graph, map);
}

From source file:org.auraframework.impl.util.AuraUtil.java

/**
 * Accepts a Set, or null, and always returns an immutable Set. If set was
 * null, return will be an empty ImmutableSet
 * /*from   w w w .  j av  a2  s. c o  m*/
 * @param <T> Any Object type
 * @param set any set, or null
 * @return An ImmutableSet that is a copy of set, or an empty ImmutableSet
 *         if set was null
 */
public static <T> Set<T> immutableSet(Set<T> set) {
    if (set == null) {
        return ImmutableSet.of();
    }
    return ImmutableSet.copyOf(set);
}

From source file:com.spectralogic.ds3autogen.utils.ArgumentsUtil.java

/**
 * Retrieves the set of all types within a list of Arguments
 */// w w  w .j  av a  2 s  . c o m
public static ImmutableSet<String> getAllArgumentTypes(final ImmutableList<Arguments> args) {
    if (isEmpty(args)) {
        return ImmutableSet.of();
    }
    final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    for (final Arguments arg : args) {
        builder.add(arg.getType());
    }
    return builder.build();
}

From source file:com.facebook.swift.codec.IsSetBean.java

public static IsSetBean createFull() {
    IsSetBean isSetBean = new IsSetBean();
    isSetBean.aBoolean = false;/*from w w w.  j  a v a 2  s.co m*/
    isSetBean.aByte = 0;
    isSetBean.aShort = 0;
    isSetBean.aInteger = 0;
    isSetBean.aLong = 0L;
    isSetBean.aDouble = 0.0d;
    isSetBean.aString = "";
    isSetBean.aStruct = new BonkField();
    isSetBean.aSet = ImmutableSet.of();
    isSetBean.aList = ImmutableList.of();
    isSetBean.aMap = ImmutableMap.of();

    return isSetBean;
}