Example usage for com.google.common.collect Maps uniqueIndex

List of usage examples for com.google.common.collect Maps uniqueIndex

Introduction

In this page you can find the example usage for com.google.common.collect Maps uniqueIndex.

Prototype

public static <K, V> ImmutableMap<K, V> uniqueIndex(Iterator<V> values, Function<? super V, K> keyFunction) 

Source Link

Document

Returns a map with the given values , indexed by keys derived from those values.

Usage

From source file:com.reprezen.kaizen.oasparser.jsonoverlay.gen.TypeData.java

public void init() {
    typeMap = Maps.uniqueIndex(types, new Function<Type, String>() {
        @Override/*  w  w  w  .j a v  a 2s.  c o  m*/
        public String apply(Type type) {
            return type.getName();
        }
    });
    for (Type type : types) {
        type.init(this);
    }
}

From source file:ext.deployit.community.cli.plainarchive.config.RuleParser.java

public RuleParser(Collection<MatcherFactory> matcherFactories) {
    this.matcherFactories = Maps.uniqueIndex(matcherFactories, new Function<MatcherFactory, String>() {
        @Override/* w ww.ja  v a2s  . c o m*/
        public String apply(MatcherFactory input) {
            return input.getMatcherType();
        }
    });
}

From source file:org.ambraproject.wombat.model.TaxonomyCountTable.java

public TaxonomyCountTable(Collection<SubjectCount> counts) {
    this.counts = ImmutableSortedMap.copyOf(Maps.uniqueIndex(counts, SubjectCount::getSubject),
            String.CASE_INSENSITIVE_ORDER);
}

From source file:ext.deployit.community.cli.mustachify.config.TransformParser.java

public TransformParser(Collection<TransformerFactory> transformerFactories) {
    this.transformerFactories = Maps.uniqueIndex(transformerFactories,
            new Function<TransformerFactory, String>() {
                @Override//  w w  w .j av  a  2  s.c o m
                public String apply(TransformerFactory input) {
                    return input.getTransformerType();
                }
            });
}

From source file:org.apache.aurora.scheduler.http.Locks.java

/**
 * Dumps existing locks./* w w w .  j  a  v  a2 s.  c  o m*/
 *
 * @return HTTP response.
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getLocks() {
    return Response.ok(Maps.transformValues(Maps.uniqueIndex(lockManager.getLocks(), TO_LOCK_KEY), TO_BEAN))
            .build();
}

From source file:org.opendaylight.netconf.sal.connect.netconf.util.NodeContainerProxy.java

private static Map<QName, DataSchemaNode> asMap(final Collection<DataSchemaNode> childNodes) {
    return Maps.uniqueIndex(childNodes, new Function<DataSchemaNode, QName>() {
        @Override/*from   w  w  w .  j  a  v a2 s  .  c  o  m*/
        public QName apply(final DataSchemaNode input) {
            return input.getQName();
        }
    });
}

From source file:de.metas.ui.web.pickingV2.packageable.PackageableRowsIndex.java

private PackageableRowsIndex(final Collection<PackageableRow> rows) {
    rowsById = Maps.uniqueIndex(rows, PackageableRow::getId);
    rowsByShipmentScheduleId = rows.stream()
            .flatMap(row -> row.getShipmentScheduleIds().stream()
                    .map(shipmentScheduleId -> GuavaCollectors.entry(shipmentScheduleId, row)))
            .collect(GuavaCollectors.toImmutableListMultimap());
}

From source file:com.b2international.snowowl.snomed.datastore.request.SnomedComponentUpdateRequest.java

static String getLatestReleaseBranch(TransactionContext context) {
    final String branch = context.branch().path();
    final CodeSystems codeSystems = CodeSystemRequests.prepareSearchCodeSystem().all().build().execute(context);
    final Map<String, CodeSystemEntry> codeSystemsByMainBranch = Maps.uniqueIndex(codeSystems,
            CodeSystemEntry::getBranchPath);

    CodeSystemEntry relativeCodeSystem = null;
    Iterator<IBranchPath> bottomToTop = BranchPathUtils.bottomToTopIterator(BranchPathUtils.createPath(branch));
    while (bottomToTop.hasNext()) {
        final IBranchPath candidate = bottomToTop.next();
        relativeCodeSystem = codeSystemsByMainBranch.get(candidate.getPath());
        if (relativeCodeSystem != null) {
            break;
        }/*from  w w  w.  j a  v a  2 s . com*/
    }
    if (relativeCodeSystem == null) {
        throw new BadRequestException("No relative code system has been found for branch '%s'", branch);
    }
    return CodeSystemRequests.prepareSearchCodeSystemVersion().one()
            .filterByCodeSystemShortName(relativeCodeSystem.getShortName())
            .sortBy(SearchResourceRequest.SortField.descending(CodeSystemVersionEntry.Fields.EFFECTIVE_DATE))
            .build().execute(context).first().map(CodeSystemVersionEntry::getPath).orElse(null);
}

From source file:org.jclouds.sqs.binders.BindSendMessageBatchRequestEntryWithDelaysToIndexedFormParams.java

public Map<String, String> idMessageBody(Iterable<String> input) {
    return Maps.uniqueIndex(input, new Function<String, String>() {
        int index = 1;

        @Override/*from   w  w  w .j a v a 2s  .  c  o  m*/
        public String apply(String input) {
            return index++ + "";
        }
    });
}

From source file:org.polarsys.reqcycle.traceability.ui.LinkPropertySource.java

public LinkPropertySource(Link link, Callable<?> callback) {
    attributes = Maps.uniqueIndex(attributesManager.getAttributes(link.getId()),
            new Function<EditableAttribute, String>() {

                @Override//from  w  w w . j  a v a  2  s.  c  o m
                public String apply(EditableAttribute arg0) {
                    return arg0.getName();
                }
            });
    this.callback = callback;
}