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

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

Introduction

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

Prototype

public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements) 

Source Link

Usage

From source file:com.google.template.soy.logging.ValidatedLoggingConfig.java

/**
 * Parses the logging config proto into a {@link ValidatedLoggingConfig}.
 *
 * @throws IllegalArgumentException if there is an error during parsing.
 *//*ww w .j av  a2  s  . c  o  m*/
public static ValidatedLoggingConfig create(LoggingConfig configProto) {
    Map<String, ValidatedLoggableElement> elementsByName = new LinkedHashMap<>();
    Map<Long, ValidatedLoggableElement> elementsById = new LinkedHashMap<>();
    // perfect duplicates are allowed, though not encouraged.
    for (LoggableElement element : ImmutableSet.copyOf(configProto.getElementList())) {
        String name = element.getName();
        checkArgument(BaseUtils.isDottedIdentifier(name), "'%s' is not a valid identifier", name);
        ValidatedLoggableElement elementConfig = ValidatedLoggableElement.create(element);
        ValidatedLoggableElement oldWithSameId = elementsById.put(elementConfig.getId(), elementConfig);
        if (oldWithSameId != null) {
            throw new IllegalArgumentException(
                    String.format("Found 2 LoggableElements with the same id %d: %s and %s",
                            elementConfig.getId(), oldWithSameId.getName(), elementConfig.getName()));
        }
        ValidatedLoggableElement oldWithSameName = elementsByName.put(elementConfig.getName(), elementConfig);
        if (oldWithSameName != null) {
            throw new IllegalArgumentException(
                    String.format("Found 2 LoggableElements with the same name %s, their ids are %d and %d",
                            elementConfig.getName(), oldWithSameName.getId(), elementConfig.getId()));
        }
    }
    return new ValidatedLoggingConfig(ImmutableMap.copyOf(elementsByName));
}

From source file:org.chaston.oakfunds.security.ActionType.java

ActionType(ActionType... impliedActions) {
    this.impliedActions = ImmutableSet.copyOf(impliedActions);
}

From source file:org.springframework.ide.eclipse.editor.support.util.EnumValueParser.java

public EnumValueParser(String typeName, String... values) {
    this(typeName, ImmutableSet.copyOf(values));
}

From source file:co.cask.cdap.data2.metadata.lineage.Lineage.java

public Lineage(Set<Relation> relations) {
    this.relations = ImmutableSet.copyOf(relations);
}

From source file:com.forgerock.elasticsearch.changes.Source.java

public Source(String source) {
    String[] parts = source.split("/");

    indices = parts[0].equals("*") ? null : ImmutableSet.copyOf(parts[0].split(","));

    if (parts.length > 1) {
        types = parts[1].equals("*") ? null : ImmutableSet.copyOf(parts[1].split(","));
    } else {/* w ww .j  a v a 2 s  .c  o  m*/
        types = null;
    }

    if (parts.length > 2) {
        ids = parts[2].equals("*") ? null : ImmutableSet.copyOf(parts[2].split(","));
    } else {
        ids = null;
    }
}

From source file:com.axemblr.service.cm.models.cm.RoleTypeList.java

@JsonCreator
public RoleTypeList(@JsonProperty("items") Set<RoleType> items) {
    this.items = (items == null) ? ImmutableSet.<RoleType>of() : ImmutableSet.copyOf(items);
}

From source file:org.rf.ide.core.executor.EnvironmentSearchPaths.java

public Collection<String> getClassPaths() {
    return ImmutableSet.copyOf(classPaths);
}

From source file:com.google.devtools.build.lib.actions.ChangedArtifactsMessage.java

public ChangedArtifactsMessage(Set<Artifact> changedArtifacts) {
    this.artifacts = ImmutableSet.copyOf(changedArtifacts);
}

From source file:com.b2international.snowowl.snomed.datastore.id.domain.SnomedComponentIds.java

public SnomedComponentIds(final Set<String> componentIds) {
    super(ImmutableSet.copyOf(componentIds).asList());
}

From source file:com.tomtom.speedtools.objects.Immutables.java

/**
 * Returns the immutable version of given collection. When given collection was already immutable, this collection
 * is simply returned./*from w w w .  j av a 2  s.c  o  m*/
 *
 * @param <T>  Element type.
 * @param elts Elements for the list.
 * @return Immutable list.
 */
@Nonnull
public static <T> Collection<T> copyOf(@Nonnull final Collection<? extends T> elts) {
    assert elts != null;
    if (elts instanceof Set) {
        return ImmutableSet.copyOf(elts);
    } else {
        return ImmutableList.copyOf(elts);
    }
}