List of usage examples for com.google.common.collect Maps uniqueIndex
public static <K, V> ImmutableMap<K, V> uniqueIndex(Iterator<V> values, Function<? super V, K> keyFunction)
From source file:org.deephacks.confit.model.BeanUtils.java
public static final Map<BeanId, Bean> uniqueIndex(Collection<Bean> beans) { return Maps.uniqueIndex(beans, new Function<Bean, BeanId>() { @Override/*from w w w. j a v a 2s.c o m*/ public BeanId apply(Bean input) { return input.getId(); } }); }
From source file:org.deephacks.tools4j.config.model.BeanUtils.java
public static final Map<BeanId, Bean> uniqueIndex(Collection<Bean> beans) { return Maps.uniqueIndex(beans, new Function<Bean, BeanId>() { @Override/* ww w. j a va 2 s . c om*/ public BeanId apply(Bean input) { return input.getId(); } }); }
From source file:com.atlassian.jira.rest.client.api.domain.input.IssueInput.java
public static IssueInput createWithFields(FieldInput... fields) { return new IssueInput( Maps.uniqueIndex(ImmutableList.copyOf(fields), EntityHelper.GET_ENTITY_STRING_ID_FUNCTION)); }
From source file:com.eharmony.matching.seeking.query.criterion.SymbolicLookup.java
public static <T extends Symbolic> ImmutableMap<String, T> map(T[] values) { return Maps.uniqueIndex(Arrays.asList(values), new SymbolicLookup()); }
From source file:org.eclipse.xtext.parser.antlr.TokenDefProvider.java
public static ITokenDefProvider from(String[] tokens) { List<String> interestingTokens = Arrays.asList(tokens).subList(4, tokens.length); ImmutableMap<Integer, String> index = Maps.uniqueIndex(interestingTokens, new Function<String, Integer>() { private int current = 4; @Override//from w w w .j ava 2 s. c om public Integer apply(String from) { Integer result = current; current++; return result; } }); return new TokenDefProvider(index); }
From source file:org.jclouds.rackspace.clouddns.v1.functions.DomainFunctions.java
/** * Take a Set of Domains and return a Map of domain name to the Domain. *///from ww w. j av a 2 s. com public static Map<String, Domain> toDomainMap(Set<Domain> domains) { return Maps.uniqueIndex(domains, DomainFunctions.GET_DOMAIN_NAME); }
From source file:com.github.tomakehurst.wiremock.extension.ExtensionLoader.java
public static Map<String, Extension> asMap(Iterable<Extension> extensions) { return Maps.uniqueIndex(extensions, new Function<Extension, String>() { public String apply(Extension extension) { return extension.getName(); }// www . j a v a 2 s .c o m }); }
From source file:org.jclouds.rackspace.clouddns.v1.functions.RecordFunctions.java
/** * Take a Set of RecordDetails and return a Map of record id to the Record. *//*from w ww . j a v a 2 s. c om*/ public static Map<String, Record> toRecordMap(Set<RecordDetail> recordDetails) { Map<String, RecordDetail> idsToRecordDetails = Maps.uniqueIndex(recordDetails, RecordFunctions.GET_RECORD_ID); return Maps.transformValues(idsToRecordDetails, RecordFunctions.GET_RECORD); }
From source file:org.trancecode.xml.saxon.SaxonMaps.java
public static Map<QName, String> attributes(final Iterable<XdmNode> attributes) { assert Iterables.all(attributes, SaxonPredicates.isAttribute()); final Map<QName, XdmNode> nodeMap = Maps.uniqueIndex(attributes, SaxonFunctions.getNodeName()); return Maps.transformValues(nodeMap, SaxonFunctions.getStringValue()); }
From source file:de.metas.ui.web.process.view.ViewActionDescriptorsList.java
public static final ViewActionDescriptorsList of(final List<ViewActionDescriptor> actions) { if (actions.isEmpty()) { return ViewActionDescriptorsList.EMPTY; }//from www . j av a 2s . com final ImmutableMap<String, ViewActionDescriptor> viewActionsByActionId = Maps.uniqueIndex(actions, ViewActionDescriptor::getActionId); return new ViewActionDescriptorsList(viewActionsByActionId); }