当前位置: 首页>>代码示例>>Java>>正文


Java ForwardingMap类代码示例

本文整理汇总了Java中com.google.common.collect.ForwardingMap的典型用法代码示例。如果您正苦于以下问题:Java ForwardingMap类的具体用法?Java ForwardingMap怎么用?Java ForwardingMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ForwardingMap类属于com.google.common.collect包,在下文中一共展示了ForwardingMap类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUserData

import com.google.common.collect.ForwardingMap; //导入依赖的package包/类
private Map<String, String> createUserData(final TModule module) {
	// TODO GH-230 consider disallowing serializing reconciled modules to index with fail-safe behavior:
	// if (module.isPreLinkingPhase() || module.isReconciled()) {
	if (module.isPreLinkingPhase()) {
		return UserdataMapper.createTimestampUserData(module);
	}
	return new ForwardingMap<String, String>() {

		private Map<String, String> delegate;

		@Override
		protected Map<String, String> delegate() {
			if (delegate == null) {
				try {
					delegate = UserdataMapper.createUserData(module);
					N4JSResource resource = (N4JSResource) module.eResource();
					UserdataMapper.writeDependenciesToUserData(resource, delegate);
				} catch (Exception e) {
					throw new IllegalStateException(e);
				}
			}
			return delegate;
		}
	};

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:N4JSResourceDescriptionStrategy.java

示例2: createLazyUserData

import com.google.common.collect.ForwardingMap; //导入依赖的package包/类
protected Map<String, String> createLazyUserData(final EObject eObject) { 
	return new ForwardingMap<String, String>() {
		private Map<String,String> delegate; 
		
		@Override
		protected Map<String, String> delegate() {
			if(delegate == null) {
				Builder<String, String> userData = ImmutableMap.builder();
				createUserData(eObject, userData);
				delegate = userData.build();
			} 
			return delegate;
		}
	};
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:JvmTypesResourceDescriptionStrategy.java

示例3: getValues

import com.google.common.collect.ForwardingMap; //导入依赖的package包/类
public Map<String, String> getValues()
{
    return new ForwardingMap<String, String>() {
        @Override
        protected Map<String, String> delegate()
        {
            return values;
        }

        @Override
        public String remove(Object object) {
            dirty();
            return super.remove(object);
        }

        @Override
        public void clear() {
            dirty();
            super.clear();
        }

        @Override
        public String put(String key, String value) {
            final String oldValue = super.put(key, value);
            if (!Objects.equal(value, oldValue)) {
                dirty();
            }
            return oldValue;
        }

        @Override
        public void putAll(Map<? extends String, ? extends String> map) {
            dirty();
            super.putAll(map);
        }


    };
}
 
开发者ID:basepom,项目名称:property-helper-maven-plugin,代码行数:40,代码来源:ValueCache.java

示例4: init

import com.google.common.collect.ForwardingMap; //导入依赖的package包/类
private void init(final Map<String, String> map) {
	data = new ForwardingMap<String, String>() {
		@Override
		protected Map<String, String> delegate() {
			return map;
		}

		@Override
		public String get(final Object key) {
			String ov = fixedValues.get(key);
			return ov == null ? delegate().get(key) : ov;
		}

		@Override
		public boolean containsKey(final Object key) {
			return fixedValues.containsKey(key) || delegate().containsKey(key);
		}

		@Override
		public Set<Entry<String, String>> entrySet() {
			Set<String> fixedValueKeys = fixedValues.keySet();
			Set<Entry<String, String>> result = Sets.newHashSet(fixedValues.entrySet());
			for (Entry<String, String> entry : delegate().entrySet()) {
				if (!fixedValueKeys.contains(entry.getKey())) {
					result.add(entry);
				}
			}
			return result;
		}

		@Override
		public Set<String> keySet() {
			Set<String> keys = Sets.newHashSet(fixedValues.keySet());
			keys.addAll(delegate().keySet());
			return keys;
		}
	};
}
 
开发者ID:mgm-tp,项目名称:jfunk,代码行数:39,代码来源:DefaultDataSet.java

示例5: superClassTypeArguments

import com.google.common.collect.ForwardingMap; //导入依赖的package包/类
/**
 * Test super-class type argument determination.
 */
@Test
public void superClassTypeArguments()
{
	final Class<MapLongString> childClass = MapLongString.class;
	final List<Class<?>> typeArguments = getSuperclassTypeArguments(ForwardingMap.class,
			childClass);
	log.debug("Class " + childClass + " typeArguments = " + typeArguments);
	assertEquals(asList(Long.class, String.class), typeArguments);
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:13,代码来源:UTestReflectionParameters.java


注:本文中的com.google.common.collect.ForwardingMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。