本文整理汇总了Java中com.google.common.collect.ImmutableBiMap.Builder.put方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.put方法的具体用法?Java Builder.put怎么用?Java Builder.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableBiMap.Builder
的用法示例。
在下文中一共展示了Builder.put方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveShardForPath
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
Long resolveShardForPath(final YangInstanceIdentifier path) {
final String shardName = actorContext.getShardStrategyFactory().getStrategy(path).findShard(path);
Long cookie = shards.get(shardName);
if (cookie == null) {
synchronized (this) {
cookie = shards.get(shardName);
if (cookie == null) {
cookie = nextShard++;
Builder<String, Long> builder = ImmutableBiMap.builder();
builder.putAll(shards);
builder.put(shardName, cookie);
shards = builder.build();
}
}
}
return cookie;
}
示例2: create
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
/**
* Create a prefix {@link Converter} for {@link XPathExpressionException} defined in a particular YANG
* {@link Module} .Instantiation requires establishing how a module's imports are mapped to actual modules
* and their namespaces. This information is cached and used for improved lookups.
*
* @param ctx A SchemaContext
* @param module Module in which the XPath is defined
* @return A new Converter
*/
public static @Nonnull Converter<String, QNameModule> create(final SchemaContext ctx, final Module module) {
// Always check for null ctx
requireNonNull(ctx, "Schema context may not be null");
// Use immutable map builder for detection of duplicates (which should never occur)
final Builder<String, QNameModule> b = ImmutableBiMap.builder();
b.put(module.getPrefix(), module.getQNameModule());
for (ModuleImport i : module.getImports()) {
final Optional<Module> mod = ctx.findModule(i.getModuleName(), i.getRevision());
checkArgument(mod.isPresent(), "Unsatisfied import of %s by module %s", i, module);
b.put(i.getPrefix(), mod.get().getQNameModule());
}
return Maps.asConverter(b.build());
}
示例3: testBuilderPutNullKey
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testBuilderPutNullKey() {
Builder<String, Integer> builder = new Builder<String, Integer>();
try {
builder.put(null, 1);
fail();
} catch (NullPointerException expected) {
}
}
示例4: testBuilderPutNullValue
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testBuilderPutNullValue() {
Builder<String, Integer> builder = new Builder<String, Integer>();
try {
builder.put("one", null);
fail();
} catch (NullPointerException expected) {
}
}
示例5: SecurityTypesDescriptionProvider
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
/**
* Restricted constructor
*/
private SecurityTypesDescriptionProvider() {
Builder<String, String> builder = ImmutableBiMap.builder();
AnnotationReflector reflector = AnnotationReflector.getDefaultReflector();
Set<Class<?>> securityClasses = reflector.getReflector().getTypesAnnotatedWith(SecurityDescription.class);
for (Class<?> securityClass : securityClasses) {
SecurityDescription securityDescriptionAnnotation = securityClass.getAnnotation(SecurityDescription.class);
if (securityDescriptionAnnotation != null) {
// extract type
String type = StringUtils.trimToNull(securityDescriptionAnnotation.type());
if (type == null) {
if (ManageableSecurity.class.isAssignableFrom(securityClass)) {
MetaBean metaBean = JodaBeanUtils.metaBean(securityClass);
ManageableSecurity bareSecurity = (ManageableSecurity) metaBean.builder().build();
type = bareSecurity.getSecurityType();
} else {
s_logger.warn("{} anotated with {}, but not subtype of {}", securityClass, SecurityDescription.class, ManageableSecurity.class);
}
}
// extract description
String description = StringUtils.trimToNull(securityDescriptionAnnotation.description());
if (description == null) {
description = securityClass.getSimpleName();
}
builder.put(type, description);
}
}
_type2Description = builder.build();
}
示例6: testBuilderPutNullKey
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testBuilderPutNullKey() {
Builder<String, Integer> builder = new Builder<>();
try {
builder.put(null, 1);
fail();
} catch (NullPointerException expected) {
}
}
示例7: testBuilderPutNullValue
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testBuilderPutNullValue() {
Builder<String, Integer> builder = new Builder<>();
try {
builder.put("one", null);
fail();
} catch (NullPointerException expected) {
}
}
示例8: fromBinary
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
@Override
public void fromBinary(
final byte[] bytes ) {
final ByteBuffer buf = ByteBuffer.wrap(bytes);
final int numSfcs = buf.getInt();
final int numDimensions = buf.getInt();
final int mappingSize = buf.getInt();
maxEstimatedDuplicateIdsPerDimension = buf.getLong();
orderedSfcs = new SpaceFillingCurve[numSfcs];
baseDefinitions = new NumericDimensionDefinition[numDimensions];
for (int i = 0; i < numSfcs; i++) {
final byte[] sfc = new byte[buf.getInt()];
buf.get(sfc);
orderedSfcs[i] = (SpaceFillingCurve) PersistenceUtils.fromBinary(sfc);
}
for (int i = 0; i < numDimensions; i++) {
final byte[] dim = new byte[buf.getInt()];
buf.get(dim);
baseDefinitions[i] = (NumericDimensionDefinition) PersistenceUtils.fromBinary(dim);
}
final Builder<Integer, Byte> bimapBuilder = ImmutableBiMap.builder();
for (int i = 0; i < mappingSize; i++) {
bimapBuilder.put(
Byte.valueOf(
buf.get()).intValue(),
buf.get());
}
orderedSfcIndexToTierId = bimapBuilder.build();
initDuplicateIdLookup();
}
示例9: parseClass
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
private void parseClass(Builder<String, String> builder, String[] parts)
{
builder.put(parts[1],parts[2]);
}
示例10: ParallelFloydWarshallJung
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public ParallelFloydWarshallJung(DirectedGraph<V,E> graph, Transformer<? super E,? extends Number> edgeWeights,
Optional<FixedThreadPool> threadPool){
this.threadPool = threadPool;
this.graph = graph;
this.edgeWeights = edgeWeights;
int numNodes = graph.getVertexCount();
double[][] costs = new double[numNodes][numNodes];
Builder<Pair<V>,E> edgesUsedBuilder = ImmutableBiMap.builder();
{
Builder<V,Integer> nodeIndexBuilder = ImmutableBiMap.builder();
int i = 0;
for(V v: graph.getVertices()){
nodeIndexBuilder.put(v,i++);
}
this.nodeIndex = nodeIndexBuilder.build();
}
for(V source: nodeIndex.keySet()){
for(V sink : nodeIndex.keySet()){
Collection<E> edges = graph.findEdgeSet(source, sink);
double bestEdgeVal = Double.POSITIVE_INFINITY;
E bestEdge = null;
for(E edge: edges){
double newEdgeVal = edgeWeights.transform(edge).doubleValue();
if(newEdgeVal < bestEdgeVal){
bestEdgeVal = newEdgeVal;
bestEdge = edge;
}
}
if(bestEdge != null){
edgesUsedBuilder.put(new Pair<V>(source,sink),bestEdge);
costs[nodeIndex.get(source)][nodeIndex.get(sink)] = bestEdgeVal;
}
else{
costs[nodeIndex.get(source)][nodeIndex.get(sink)] = Double.POSITIVE_INFINITY;
}
}
}
this.edgesUsed = edgesUsedBuilder.build();
this.floydWarshall = new ParallelFloydWarshall(numNodes,costs,threadPool);
}
示例11: setupLoadOnly
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void setupLoadOnly(String deobfFileName, boolean loadAll)
{
try
{
File mapData = new File(deobfFileName);
LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
List<String> srgList = CharStreams.readLines(srgSupplier);
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.<String,String>builder();
Builder<String, String> mcpBuilder = ImmutableBiMap.<String,String>builder();
Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
for (String line : srgList)
{
String[] parts = Iterables.toArray(splitter.split(line),String.class);
String typ = parts[0];
if ("CL".equals(typ))
{
parseClass(builder, parts);
parseMCPClass(mcpBuilder,parts);
}
else if ("MD".equals(typ) && loadAll)
{
parseMethod(parts);
}
else if ("FD".equals(typ) && loadAll)
{
parseField(parts);
}
}
classNameBiMap = builder.build();
// Special case some mappings for modloader mods
mcpBuilder.put("BaseMod","net/minecraft/src/BaseMod");
mcpBuilder.put("ModLoader","net/minecraft/src/ModLoader");
mcpBuilder.put("EntityRendererProxy","net/minecraft/src/EntityRendererProxy");
mcpBuilder.put("MLProp","net/minecraft/src/MLProp");
mcpBuilder.put("TradeEntry","net/minecraft/src/TradeEntry");
mcpNameBiMap = mcpBuilder.build();
}
catch (IOException ioe)
{
Logger.getLogger("FML").log(Level.SEVERE, "An error occurred loading the deobfuscation map data", ioe);
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
示例12: setup
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName)
{
this.classLoader = classLoader;
try
{
InputStream classData = getClass().getResourceAsStream(deobfFileName);
LZMAInputSupplier zis = new LZMAInputSupplier(classData);
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
List<String> srgList = CharStreams.readLines(srgSupplier);
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.<String,String>builder();
Builder<String, String> mcpBuilder = ImmutableBiMap.<String,String>builder();
Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
for (String line : srgList)
{
String[] parts = Iterables.toArray(splitter.split(line),String.class);
String typ = parts[0];
if ("CL".equals(typ))
{
parseClass(builder, parts);
parseMCPClass(mcpBuilder,parts);
}
else if ("MD".equals(typ))
{
parseMethod(parts);
}
else if ("FD".equals(typ))
{
parseField(parts);
}
}
classNameBiMap = builder.build();
// Special case some mappings for modloader mods
mcpBuilder.put("BaseMod","net/minecraft/src/BaseMod");
mcpBuilder.put("ModLoader","net/minecraft/src/ModLoader");
mcpBuilder.put("EntityRendererProxy","net/minecraft/src/EntityRendererProxy");
mcpBuilder.put("MLProp","net/minecraft/src/MLProp");
mcpBuilder.put("TradeEntry","net/minecraft/src/TradeEntry");
mcpNameBiMap = mcpBuilder.build();
}
catch (IOException ioe)
{
FMLRelaunchLog.log(Level.SEVERE, ioe, "An error occurred loading the deobfuscation map data");
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
示例13: parseMCPClass
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
private void parseMCPClass(Builder<String, String> builder, String[] parts)
{
int clIdx = parts[2].lastIndexOf('/');
builder.put("net/minecraft/src/"+parts[2].substring(clIdx+1),parts[2]);
}
示例14: makeBinaryVariables
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
/**
*
* @param cplex
* @param set
* must contain no duplicates according to T.equals(), a duplicate
* causes an illegal argument exception
* @return
* @throws IloException
*/
public static <T> ImmutableBiMap<T, IloIntVar> makeBinaryVariables(
IloCplex cplex, Iterable<T> set) throws IloException {
Builder<T, IloIntVar> ans = ImmutableBiMap.builder();
for (T t : set) {
ans.put(t, cplex.boolVar());
}
return ans.build();
}