项目:guava-mock
文件:MapsTest.java
public void testSortedMapTransformEntries() {
SortedMap<String,String> map =
sortednotNavigable(ImmutableSortedMap.of("a","4","b","9"));
EntryTransformer<String,String,String> concat =
new EntryTransformer<String,String>() {
@Override
public String transformEntry(String key,String value) {
return key + value;
}
};
SortedMap<String,String> transformed = transformEntries(map,concat);
/*
* We'd like to sanity check that we didn't get a NavigableMap out,but we
* can't easily do so while maintaining GWT compatibility.
*/
assertEquals(ImmutableSortedMap.of("a","a4","b9"),transformed);
}
public void testSortedMapTransformEntries() {
SortedMap<String,transformed);
}
项目:maker
文件:CommonRepositoryImpl.java
@Override
public <ID> int updateFields(String tableName,ID id,Map<String,Object> valueMap) {
StringBuilder sqlSb = new StringBuilder();
sqlSb.append("UPDATE `");
sqlSb.append(tableName);
sqlSb.append("` SET ");
EntryTransformer<String,Object,String> transformer = new EntryTransformer<String,Object value) {
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERscore,key);
return "`" + column + "`='" + value + "'";
}
};
Map<String,String> transformed = Maps.transformEntries(valueMap,transformer);
sqlSb.append(Joiner.on(",").join(transformed.values()));
sqlSb.append(" WHERE `id`='" + id + "';");
return jdbcTemplate.update(sqlSb.toString());
}
项目:VarJ
文件:Multimaps.java
TransformedEntries(
final EntryTransformer<? super K,? super V1,V2> transformer) {
super(fromMultimap.entries(),new Function<Entry<K,V1>,Entry<K,V2>>() {
@Override public Entry<K,V2> apply(final Entry<K,V1> entry) {
return new AbstractMapEntry<K,V2>() {
@Override public K getKey() {
return entry.getKey();
}
@Override public V2 getValue() {
return transformer.transformEntry(
entry.getKey(),entry.getValue());
}
};
}
});
}
项目:guava-libraries
文件:MapsTest.java
public void testSortedMapTransformEntries() {
SortedMap<String,transformed);
}
项目:guava-libraries
文件:MapsTest.java
@GwtIncompatible("NavigableMap")
public void testTransformEntriesSecretlyNavigable() {
Map<String,String> map = ImmutableSortedMap.of("a","9");
EntryTransformer<String,String value) {
return key + value;
}
};
Map<String,String> transformed;
transformed = transformEntries(map,concat);
assertEquals(ImmutableMap.of("a",transformed);
assertTrue(transformed instanceof NavigableMap);
transformed = transformEntries((SortedMap<String,String>) map,transformed);
assertTrue(transformed instanceof NavigableMap);
}
项目:My-Wallet-Android
文件:Multimaps.java
TransformedEntries(
final EntryTransformer<? super K,entry.getValue());
}
};
}
});
}
项目:My-Wallet-Android
文件:Multimaps.java
Map<K,Collection<V>> createAsMap() {
// Select the values that satisify the predicate.
EntryTransformer<K,Collection<V>,Collection<V>> transformer
= new EntryTransformer<K,Collection<V>>() {
@Override public Collection<V> transformEntry(K key,Collection<V> collection) {
return filterCollection(collection,new ValuePredicate(key));
}
};
Map<K,Collection<V>> transformed
= Maps.transformEntries(unfiltered.asMap(),transformer);
// Select the keys that have at least one value remaining.
Map<K,Collection<V>> filtered = Maps.filterValues(transformed,NOT_EMPTY);
// Override the removal methods,since removing a map entry should not
// affect values that don't satisfy the filter.
return new AsMap(filtered);
}
项目:guava
文件:MapsTest.java
public void testSortedMapTransformEntries() {
SortedMap<String,String> map = sortednotNavigable(ImmutableSortedMap.of("a",transformed);
}
项目:epubcheck-web
文件:EnumVocab.java
/**
* Creates a new vocabulary backed by the given {@link Enum} class and with
* properties having the common URI stem <code>base</code> and prefix
* <code>prefix</code>
*
* @param clazz
* the enumeration backing this vocabulary.
* @param base
* the common stem URI of properties in this vocabulary.
* @param prefix
* the common prefix of properties in this vocabulary.
*/
public EnumVocab(final Class<P> clazz,final String base,final String prefix)
{
this.uri = Strings.nullToEmpty(base);
this.index = ImmutableMap
.copyOf(Maps.transformEntries(Maps.uniqueIndex(EnumSet.allOf(clazz),ENUM_TO_NAME),new EntryTransformer<String,P,Property>()
{
@Override
public Property transformEntry(String name,P enumee)
{
return Property.newFrom(name,base,prefix,enumee);
}
}));
}
/**
* Scopes the given callable inside a request scope. This is not the same
* as the HTTP request scope,but is used if no HTTP request scope is in
* progress. In this way,keys can be scoped as @RequestScoped and exist
* in non-HTTP requests (for example: RPC requests) as well as in HTTP
* request threads.
*
* <p>The returned callable will throw a {@link scopingException} when called
* if there is a request scope already active on the current thread.
*
* @param callable code to be executed which depends on the request scope.
* Typically in another thread,but not necessarily so.
* @param seedMap the initial set of scoped instances for Guice to seed the
* request scope with. To seed a key with null,use {@code null} as
* the value.
* @return a callable that when called will run inside the a request scope
* that exposes the instances in the {@code seedMap} as scoped keys.
* @since 3.0
*/
public static <T> Callable<T> scopeRequest(final Callable<T> callable,Map<Key<?>,Object> seedMap) {
Preconditions.checkArgument(null != seedMap,"Seed map cannot be null,try passing in Collections.emptyMap() instead.");
// copy the seed values into our local scope map.
final Context context = new Context();
Map<Key<?>,Object> validatedAndCanonicalizedMap =
Maps.transformEntries(seedMap,new EntryTransformer<Key<?>,Object>() {
@Override public Object transformEntry(Key<?> key,Object value) {
return validateAndCanonicalizeValue(key,value);
}
});
context.map.putAll(validatedAndCanonicalizedMap);
return new Callable<T>() {
public T call() throws Exception {
checkscopingState(null == GuiceFilter.localContext.get(),"An HTTP request is already in progress,cannot scope a new request in this thread.");
checkscopingState(null == requestScopeContext.get(),"A request scope is already in progress,cannot scope a new request in this thread.");
return context.call(callable);
}
};
}
项目:guava-mock
文件:Multimaps.java
@Override
Map<K,Collection<V2>> createAsMap() {
return Maps.transformEntries(
fromMultimap.asMap(),new EntryTransformer<K,Collection<V1>,Collection<V2>>() {
@Override
public Collection<V2> transformEntry(K key,Collection<V1> value) {
return transform(key,value);
}
});
}
项目:guava-mock
文件:MapsTest.java
public void testTransformEntries() {
Map<String,String> map = ImmutableMap.of("a",concat);
assertEquals(ImmutableMap.of("a",transformed);
}
项目:guava-mock
文件:MapsTest.java
public void testTransformEntriesExample() {
Map<String,Boolean> options =
ImmutableMap.of("verbose",true,"sort",false);
EntryTransformer<String,Boolean,String> flagPrefixer =
new EntryTransformer<String,Boolean value) {
return value ? key : "no" + key;
}
};
Map<String,String> transformed = transformEntries(options,flagPrefixer);
assertEquals("{verbose=verbose,sort=nosort}",transformed.toString());
}
项目:guava-mock
文件:MapsTest.java
@GwtIncompatible // NavigableMap
public void testNavigableMapTransformEntries() {
NavigableMap<String,String> map =
ImmutableSortedMap.of("a",String value) {
return key + value;
}
};
NavigableMap<String,concat);
assertEquals(ImmutableSortedMap.of("a",transformed);
}
@Override
Map<K,value);
}
});
}
public void testTransformEntries() {
Map<String,transformed);
}
public void testTransformEntriesExample() {
Map<String,transformed.toString());
}
@GwtIncompatible // NavigableMap
public void testNavigableMapTransformEntries() {
NavigableMap<String,transformed);
}
项目:codebuff
文件:Multimaps.java
@Override
Map<K,Collection<V2>> createAsMap() {
return Maps.transformEntries(fromMultimap.asMap(),Collection<V2>>() {
@Override
public Collection<V2> transformEntry(K key,Collection<V1> value) {
return transform(key,value);
}
});
}
项目:codebuff
文件:Multimaps.java
@Override
Map<K,value);
}
});
}
项目:nexus-public
文件:ExtDirectServlet.java
@Override
protected RequestRouter createRequestRouter(final Registry registry,final GlobalConfiguration globalConfiguration) {
final dispatcher dispatcher = createdispatcher(globalConfiguration.getdispatcherClass());
return new RequestRouter(registry,globalConfiguration,dispatcher)
{
@Override
public void processpollRequest(final Reader reader,final Writer writer,final String pathInfo)
throws IOException
{
new PollRequestProcessor(registry,dispatcher,globalConfiguration)
{
@Override
// HACK: we determine parameters from request not by reading request content as request content Could had
// been already read exactly for getting the params,case when request content is already empty
protected Object[] getParameters()
{
if (reader instanceof RequestBoundReader) {
ServletRequest request = ((RequestBoundReader) reader).getRequest();
Map<String,String[]> parameterMap = request.getParameterMap();
Map<String,String> parameters = Maps.newHashMap();
if (parameterMap != null) {
parameters = Maps.transformEntries(parameterMap,String[],String>()
{
@Override
public String transformEntry(@Nullable final String key,@Nullable final String[] values) {
return values == null || values.length == 0 ? null : values[0];
}
});
}
return new Object[]{parameters};
}
return super.getParameters();
}
}.process(reader,writer,pathInfo);
}
};
}
/**
* @param brokers in multiple clusters,keyed by cluster id
* @param topic
* @return Get the partition Metadata list for the specific topic via the brokers
* null if topic is not found
*/
public static Map<String,List<PartitionMetadata>> getPartitionsForTopic(SetMultimap<String,String> brokers,final String topic)
{
return Maps.transformEntries(brokers.asMap(),Collection<String>,List<PartitionMetadata>>()
{
@Override
public List<PartitionMetadata> transformEntry(String key,Collection<String> bs)
{
return getPartitionsForTopic(new HashSet<String>(bs),topic);
}
});
}
private EntryTransformer<String,PropertyValue> toPropertyValue() {
return new EntryTransformer<String,PropertyValue>() {
@Override
public PropertyValue transformEntry(String paramName,Object value) {
return propertyValues.containsKey(paramName) ? propertyValues.get(paramName) : createPropertyValue(getParameterType(paramName),value);
}
};
}
项目:bts
文件:Multimaps.java
@Override
Map<K,Collection<V2>>() {
@Override public Collection<V2> transformEntry(
K key,Collection<V1> value) {
return transform(key,value);
}
});
}
项目:bts
文件:Platform.java
static <K,V1,V2> SortedMap<K,V2> mapsTransformEntriesSortedMap(
SortedMap<K,V1> fromMap,EntryTransformer<? super K,V2> transformer) {
return (fromMap instanceof NavigableMap)
? Maps.transformEntries((NavigableMap<K,V1>) fromMap,transformer)
: Maps.transformEntriesIgnoreNavigable(fromMap,transformer);
}
项目:j2objc
文件:Multimaps.java
@Override
Map<K,Collection<V2>>() {
@Override public Collection<V2> transformEntry(
K key,value);
}
});
}
项目:j2objc
文件:Platform.java
static <K,transformer);
}
项目:VarJ
文件:Multimaps.java
@Override public Map<K,Collection<V2>> asMap() {
if (asMap == null) {
Map<K,Collection<V2>> aM = Maps.transformEntries(fromMultimap.asMap(),Collection<V2>>() {
@Override public Collection<V2> transformEntry(
K key,Collection<V1> value) {
return transform(key,value);
}
});
asMap = aM;
return aM;
}
return asMap;
}
项目:guava-libraries
文件:Multimaps.java
@Override
Map<K,value);
}
});
}
项目:guava-libraries
文件:Platform.java
static <K,transformer);
}
项目:guava-libraries
文件:MapsTest.java
public void testTransformEntries() {
Map<String,transformed);
}
项目:guava-libraries
文件:MapsTest.java
public void testTransformEntriesSecretlySorted() {
Map<String,transformed);
assertTrue(transformed instanceof SortedMap);
}
项目:guava-libraries
文件:MapsTest.java
public void testTransformEntriesExample() {
Map<String,transformed.toString());
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。