本文整理汇总了Java中com.google.common.collect.Maps.newLinkedHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newLinkedHashMap方法的具体用法?Java Maps.newLinkedHashMap怎么用?Java Maps.newLinkedHashMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Maps
的用法示例。
在下文中一共展示了Maps.newLinkedHashMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAddressesForNsIds
import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
* Returns the configured address for all NameNodes in the cluster.
* @param conf configuration
* @param nsIds
*@param defaultAddress default address to return in case key is not found.
* @param keys Set of keys to look for in the order of preference @return a map(nameserviceId to map(namenodeId to InetSocketAddress))
*/
private static Map<String, Map<String, InetSocketAddress>>
getAddressesForNsIds(Configuration conf, Collection<String> nsIds,
String defaultAddress, String... keys) {
// Look for configurations of the form <key>[.<nameserviceId>][.<namenodeId>]
// across all of the configured nameservices and namenodes.
Map<String, Map<String, InetSocketAddress>> ret = Maps.newLinkedHashMap();
for (String nsId : emptyAsSingletonNull(nsIds)) {
Map<String, InetSocketAddress> isas =
getAddressesForNameserviceId(conf, nsId, defaultAddress, keys);
if (!isas.isEmpty()) {
ret.put(nsId, isas);
}
}
return ret;
}
示例2: getEnchantments
import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static Map<Integer, Integer> getEnchantments(ItemStack stack)
{
Map<Integer, Integer> map = Maps.<Integer, Integer>newLinkedHashMap();
NBTTagList nbttaglist = stack.getItem() == Items.enchanted_book ? Items.enchanted_book.getEnchantments(stack) : stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
map.put(Integer.valueOf(j), Integer.valueOf(k));
}
}
return map;
}
示例3: getModelResourceLocation
import com.google.common.collect.Maps; //导入方法依赖的package包/类
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
Map<IProperty, Comparable> map = Maps.<IProperty, Comparable>newLinkedHashMap(state.getProperties());
String s;
if (this.name == null)
{
s = ((ResourceLocation)Block.blockRegistry.getNameForObject(state.getBlock())).toString();
}
else
{
s = ((IProperty)this.name).getName((Comparable)map.remove(this.name));
}
if (this.suffix != null)
{
s = s + this.suffix;
}
for (IProperty<?> iproperty : this.ignored)
{
map.remove(iproperty);
}
return new ModelResourceLocation(s, this.getPropertyString(map));
}
示例4: difference
import com.google.common.collect.Maps; //导入方法依赖的package包/类
public Map<String, Difference> difference() {
Map<String, Difference> result = Maps.newLinkedHashMap();
if (expectedUrlAccepted != actualUrlAccepted) {
result.put(URL_ACCEPTED,
new Difference(String.valueOf(actualUrlAccepted), String.valueOf(expectedUrlAccepted)));
}
if (!expectedTitle.equals(actualTitle)) {
result.put(TITLE, new Difference(actualTitle, expectedTitle));
}
if (!expectedText.equals(actualText)) {
result.put(TEXT, new Difference(actualText, expectedText));
}
if (!expectedDate.equals(actualDate)) {
result.put(DATE, new Difference(actualDate, expectedDate));
}
return result;
}
示例5: getClassPathEntries
import com.google.common.collect.Maps; //导入方法依赖的package包/类
@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
// Search parent first, since it's the order ClassLoader#loadClass() uses.
ClassLoader parent = classloader.getParent();
if (parent != null) {
entries.putAll(getClassPathEntries(parent));
}
if (classloader instanceof URLClassLoader) {
URLClassLoader urlClassLoader = (URLClassLoader) classloader;
for (URL entry : urlClassLoader.getURLs()) {
if (entry.getProtocol().equals("file")) {
File file = toFile(entry);
if (!entries.containsKey(file)) {
entries.put(file, classloader);
}
}
}
}
return ImmutableMap.copyOf(entries);
}
示例6: getColTypeMap
import com.google.common.collect.Maps; //导入方法依赖的package包/类
private Map<String, OdpsType> getColTypeMap() {
Map colTypeMap = Maps.newLinkedHashMap();
Properties userMapping = options.getMapColumnOdps();
String[] columnNames = options.getColumns();
for(Object column : userMapping.keySet()) {
boolean found = false;
for(String c : columnNames) {
if (c.equals(column)) {
found = true;
break;
}
}
if (!found) {
throw new IllegalArgumentException("No column by the name " + column
+ "found while importing data");
}
}
for(String col: columnNames) {
String userType = userMapping.getProperty(col);
if(userType != null) {
colTypeMap.put(col, OdpsType.valueOf(userType.toUpperCase()));
} else {
LOG.warn("Column " + col
+ " type not specified, defaulting to STRING.");
colTypeMap.put(col, OdpsType.STRING);
}
}
return colTypeMap;
}
示例7: MetricsSystemImpl
import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
* Construct the metrics system
* @param prefix for the system
*/
public MetricsSystemImpl(String prefix) {
this.prefix = prefix;
allSources = Maps.newHashMap();
sources = Maps.newLinkedHashMap();
allSinks = Maps.newHashMap();
sinks = Maps.newLinkedHashMap();
sourceConfigs = Maps.newHashMap();
sinkConfigs = Maps.newHashMap();
callbacks = Lists.newArrayList();
namedCallbacks = Maps.newHashMap();
injectedTags = Lists.newArrayList();
collector = new MetricsCollectorImpl();
if (prefix != null) {
// prefix could be null for default ctor, which requires init later
initSystemMBean();
}
}
示例8: renderProject
import com.google.common.collect.Maps; //导入方法依赖的package包/类
private void renderProject(Project project, JsonBuilder json) {
Map<String, Object> overall = Maps.newLinkedHashMap();
overall.put("gradleVersion", GradleVersion.current().toString());
overall.put("generationDate", new Date().toString());
Map<String, Object> projectOut = Maps.newLinkedHashMap();
projectOut.put("name", project.getName());
projectOut.put("description", project.getDescription());
projectOut.put("configurations", createConfigurations(project));
overall.put("project", projectOut);
json.call(overall);
}
示例9: getCurrentStats
import com.google.common.collect.Maps; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public Map<String, String> getCurrentStats()
{
Map<String, String> map = Maps.<String, String>newLinkedHashMap();
synchronized (this.syncLock)
{
this.addMemoryStatsToSnooper();
for (Entry<String, Object> entry : this.snooperStats.entrySet())
{
map.put(entry.getKey(), entry.getValue().toString());
}
for (Entry<String, Object> entry1 : this.clientStats.entrySet())
{
map.put(entry1.getKey(), entry1.getValue().toString());
}
return map;
}
}
示例10: getMappedInstances
import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static Map<String, Map<String, Collection<ObjectName>>> getMappedInstances(
final Set<ObjectName> instancesToMap, final Map<String, Map<String, ModuleConfig>> configs) {
Multimap<String, ObjectName> moduleToInstances = mapInstancesToModules(instancesToMap);
Map<String, Map<String, Collection<ObjectName>>> retVal = Maps.newLinkedHashMap();
for (Entry<String, Map<String, ModuleConfig>> namespaceToModuleToConfigEntry : configs.entrySet()) {
Map<String, Collection<ObjectName>> innerRetVal = Maps.newHashMap();
for (Entry<String, ModuleConfig> mbeEntry : namespaceToModuleToConfigEntry.getValue().entrySet()) {
String moduleName = mbeEntry.getKey();
Collection<ObjectName> instances = moduleToInstances.get(moduleName);
// TODO, this code does not support same module names from different namespaces
// Namespace should be present in ObjectName
if (instances == null) {
continue;
}
innerRetVal.put(moduleName, instances);
}
retVal.put(namespaceToModuleToConfigEntry.getKey(), innerRetVal);
}
return retVal;
}
示例11: convertMappings
import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static void convertMappings(Mappings mappings, BiMap<ClassEntry,ClassEntry> changes) {
// sort the changes so classes are renamed in the correct order
// ie. if we have the mappings a->b, b->c, we have to apply b->c before a->b
LinkedHashMap<ClassEntry,ClassEntry> sortedChanges = Maps.newLinkedHashMap();
int numChangesLeft = changes.size();
while (!changes.isEmpty()) {
Iterator<Map.Entry<ClassEntry,ClassEntry>> iter = changes.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<ClassEntry,ClassEntry> change = iter.next();
if (changes.containsKey(change.getValue())) {
sortedChanges.put(change.getKey(), change.getValue());
iter.remove();
}
}
// did we remove any changes?
if (numChangesLeft - changes.size() > 0) {
// keep going
numChangesLeft = changes.size();
} else {
// can't sort anymore. There must be a loop
break;
}
}
if (!changes.isEmpty()) {
throw new Error("Unable to sort class changes! There must be a cycle.");
}
// convert the mappings in the correct class order
for (Map.Entry<ClassEntry,ClassEntry> entry : sortedChanges.entrySet()) {
mappings.renameObfClass(entry.getKey().getName(), entry.getValue().getName());
}
}
示例12: BlockStateContainer
import com.google.common.collect.Maps; //导入方法依赖的package包/类
protected BlockStateContainer(Block p_i9_1_, IProperty<?>[] p_i9_2_, ImmutableMap < IUnlistedProperty<?>, Optional<? >> p_i9_3_)
{
this.block = p_i9_1_;
Map < String, IProperty<? >> map = Maps. < String, IProperty<? >> newHashMap();
for (IProperty<?> iproperty : p_i9_2_)
{
validateProperty(p_i9_1_, iproperty);
map.put(iproperty.getName(), iproperty);
}
this.properties = ImmutableSortedMap. < String, IProperty<? >> copyOf(map);
Map < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > map2 = Maps. < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > newLinkedHashMap();
List<BlockStateContainer.StateImplementation> list = Lists.<BlockStateContainer.StateImplementation>newArrayList();
for (List < Comparable<? >> list1 : Cartesian.cartesianProduct(this.getAllowedValues()))
{
Map < IProperty<?>, Comparable<? >> map1 = MapPopulator. < IProperty<?>, Comparable<? >> createMap(this.properties.values(), list1);
BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation = this.createState(p_i9_1_, ImmutableMap. < IProperty<?>, Comparable<? >> copyOf(map1), p_i9_3_);
map2.put(map1, blockstatecontainer$stateimplementation);
list.add(blockstatecontainer$stateimplementation);
}
for (BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation1 : list)
{
blockstatecontainer$stateimplementation1.buildPropertyValueTable(map2);
}
this.validStates = ImmutableList.copyOf(list);
}
示例13: getAll
import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
Map<K, V> result = Maps.newLinkedHashMap();
for (K key : keys) {
if (!result.containsKey(key)) {
result.put(key, get(key));
}
}
return ImmutableMap.copyOf(result);
}
示例14: testEvictEntries
import com.google.common.collect.Maps; //导入方法依赖的package包/类
public void testEvictEntries() {
int maxSize = 10;
LocalCache<Object, Object> map =
makeLocalCache(createCacheBuilder().concurrencyLevel(1).maximumSize(maxSize));
Segment<Object, Object> segment = map.segments[0];
// manually add elements to avoid eviction
int originalCount = 1024;
ReferenceEntry<Object, Object> entry = null;
LinkedHashMap<Object, Object> originalMap = Maps.newLinkedHashMap();
for (int i = 0; i < originalCount; i++) {
Object key = new Object();
Object value = new Object();
AtomicReferenceArray<ReferenceEntry<Object, Object>> table = segment.table;
int hash = map.hash(key);
int index = hash & (table.length() - 1);
ReferenceEntry<Object, Object> first = table.get(index);
entry = map.newEntry(key, hash, first);
ValueReference<Object, Object> valueRef = map.newValueReference(entry, value, 1);
entry.setValueReference(valueRef);
segment.recordWrite(entry, 1, map.ticker.read());
table.set(index, entry);
originalMap.put(key, value);
}
segment.count = originalCount;
segment.totalWeight = originalCount;
assertEquals(originalCount, map.size());
assertEquals(originalMap, map);
Iterator<Object> it = originalMap.keySet().iterator();
for (int i = 0; i < originalCount - maxSize; i++) {
it.next();
it.remove();
}
segment.evictEntries(entry);
assertEquals(maxSize, map.size());
assertEquals(originalMap, map);
}
示例15: getProperties
import com.google.common.collect.Maps; //导入方法依赖的package包/类
private Map<String, ExecutableElement> getProperties(TypeElement targetClass) {
Map<String, ExecutableElement> elements = Maps.newLinkedHashMap();
for (ExecutableElement method : ElementFilter.methodsIn(targetClass.getEnclosedElements())) {
if (!method.getModifiers()
.contains(PRIVATE) && !method.getModifiers()
.contains(STATIC) && method.getAnnotation(InspectorIgnored.class) == null) {
elements.put(method.getSimpleName()
.toString(), method);
}
}
return elements;
}