本文整理汇总了Java中com.google.common.collect.ImmutableBiMap.Builder.build方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.build方法的具体用法?Java Builder.build怎么用?Java Builder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableBiMap.Builder
的用法示例。
在下文中一共展示了Builder.build方法的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: testPuttingTheSameKeyTwiceThrowsOnBuild
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
Builder<String, Integer> builder = new Builder<String, Integer>()
.put("one", 1)
.put("one", 1); // throwing on this line would be even better
try {
builder.build();
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).contains("one");
}
}
示例3: 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));
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
List<String> srgList = srgSource.readLines();
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.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);
}
else if ("MD".equals(typ) && loadAll)
{
parseMethod(parts);
}
else if ("FD".equals(typ) && loadAll)
{
parseField(parts);
}
}
classNameBiMap = builder.build();
}
catch (IOException ioe)
{
FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
示例4: 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));
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
List<String> srgList = srgSource.readLines();
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = 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);
}
else if ("MD".equals(typ) && loadAll)
{
parseMethod(parts);
}
else if ("FD".equals(typ) && loadAll)
{
parseField(parts);
}
}
classNameBiMap = builder.build();
}
catch (IOException ioe)
{
FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
示例5: 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);
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
List<String> srgList = srgSource.readLines();
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = 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);
}
else if ("MD".equals(typ))
{
parseMethod(parts);
}
else if ("FD".equals(typ))
{
parseField(parts);
}
}
classNameBiMap = builder.build();
}
catch (IOException ioe)
{
FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data");
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
示例6: 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();
}
示例7: testPuttingTheSameKeyTwiceThrowsOnBuild
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
Builder<String, Integer> builder = new Builder<String, Integer>()
.put("one", 1)
.put("one", 1); // throwing on this line would be even better
try {
builder.build();
fail();
} catch (IllegalArgumentException expected) {
assertTrue(expected.getMessage().contains("one"));
}
}
示例8: testPuttingTheSameKeyTwiceThrowsOnBuild
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
Builder<String, Integer> builder =
new Builder<String, Integer>()
.put("one", 1)
.put("one", 1); // throwing on this line would be even better
try {
builder.build();
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).contains("one");
}
}
示例9: 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();
}
示例10: setup
import com.google.common.collect.ImmutableBiMap.Builder; //导入方法依赖的package包/类
public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName)
{
this.classLoader = classLoader;
try
{
List<String> srgList;
final String gradleStartProp = System.getProperty("net.minecraftforge.gradle.GradleStart.srg.srg-mcp");
if (Strings.isNullOrEmpty(gradleStartProp))
{
// get as a resource
InputStream classData = getClass().getResourceAsStream(deobfFileName);
LZMAInputSupplier zis = new LZMAInputSupplier(classData);
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
srgList = srgSource.readLines();
FMLRelaunchLog.fine("Loading deobfuscation resource %s with %d records", deobfFileName, srgList.size());
}
else
{
srgList = Files.readLines(new File(gradleStartProp), Charsets.UTF_8);
FMLRelaunchLog.fine("Loading deobfuscation resource %s with %d records", gradleStartProp, srgList.size());
}
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.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);
}
else if ("MD".equals(typ))
{
parseMethod(parts);
}
else if ("FD".equals(typ))
{
parseField(parts);
}
}
classNameBiMap = builder.build();
}
catch (IOException ioe)
{
FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data");
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
示例11: 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);
}
示例12: 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());
}
示例13: 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());
}
示例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();
}