本文整理匯總了Java中com.google.common.collect.ImmutableBiMap.builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableBiMap.builder方法的具體用法?Java ImmutableBiMap.builder怎麽用?Java ImmutableBiMap.builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.ImmutableBiMap
的用法示例。
在下文中一共展示了ImmutableBiMap.builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildModObjectList
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例2: from
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public static ClassRenamingMapper from(ClassNameMapper originalMap, ClassNameMapper targetMap) {
ImmutableBiMap.Builder<String, String> translationBuilder = ImmutableBiMap.builder();
ImmutableSet.Builder<String> newClasses = ImmutableSet.builder();
BiMap<String, String> sourceObfuscatedToOriginal = originalMap.getObfuscatedToOriginalMapping();
BiMap<String, String> sourceOriginalToObfuscated = sourceObfuscatedToOriginal.inverse();
BiMap<String, String> targetObfuscatedToOriginal = targetMap.getObfuscatedToOriginalMapping();
BiMap<String, String> targetOriginalToObfuscated = targetObfuscatedToOriginal.inverse();
for (String originalName : sourceOriginalToObfuscated.keySet()) {
String sourceObfuscatedName = sourceOriginalToObfuscated.get(originalName);
String targetObfuscatedName = targetOriginalToObfuscated.get(originalName);
if (targetObfuscatedName == null) {
newClasses.add(originalName);
continue;
}
translationBuilder.put(sourceObfuscatedName, targetObfuscatedName);
}
ImmutableBiMap<String, String> translation = translationBuilder.build();
ImmutableSet<String> unusedNames = ImmutableSet
.copyOf(Sets.difference(targetObfuscatedToOriginal.keySet(), translation.values()));
return new ClassRenamingMapper(translation, newClasses.build(), unusedNames);
}
示例3: buildModObjectList
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例4: resolveShardForPath
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的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;
}
示例5: LanternBlockState
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) {
this.traitValues = traitValues;
this.baseState = baseState;
ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder();
for (BlockTrait trait : traitValues.keySet()) {
builder.put(((LanternBlockTrait) trait).getKey(), trait);
}
this.keyToBlockTrait = builder.build();
final StringBuilder idBuilder = new StringBuilder();
idBuilder.append(baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1));
if (!traitValues.isEmpty()) {
idBuilder.append('[');
final Joiner joiner = Joiner.on(',');
final List<String> propertyValues = new ArrayList<>();
for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) {
propertyValues.add(entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH));
}
idBuilder.append(joiner.join(propertyValues));
idBuilder.append(']');
}
this.name = idBuilder.toString();
this.id = baseState.getBlockType().getPluginId() + ':' + this.name;
}
示例6: transform
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
/**
* Transform all the original data in the specified mapping, using this mapping.
*
* This is useful for {@link #createRenamingMappings(UnaryOperator, Function, Function)},
* since renaming mappings have no 'original' data of their own, and so can't be directly output to a file.
* The returned mapping data is guaranteed to have the same originals as the data of the old mapping data.
*
* @return the transformed data
*/
default Mappings transform(Mappings original) {
ImmutableBiMap.Builder<JavaType, JavaType> types = ImmutableBiMap.builder();
ImmutableBiMap.Builder<MethodData, MethodData> methods = ImmutableBiMap.builder();
ImmutableBiMap.Builder<FieldData, FieldData> fields = ImmutableBiMap.builder();
original.classes().forEach(originalType -> {
JavaType newType = this.getNewType(originalType);
types.put(originalType, newType);
});
original.methods().forEach(originalMethodData -> {
MethodData newMethodData = this.getNewMethod(originalMethodData);
methods.put(originalMethodData, newMethodData);
});
original.fields().forEach(originalFieldData -> {
FieldData newFieldData = this.getNewField(originalFieldData);
fields.put(originalFieldData, newFieldData);
});
return ImmutableMappings.create(types.build(), methods.build(), fields.build());
}
示例7: buildModObjectList
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例8: getHeaderColumns
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
private ImmutableBiMap<UnosDataHeader, Integer> getHeaderColumns(
CSVRecord headerRow) {
ImmutableBiMap.Builder<UnosDataHeader, Integer> ans = ImmutableBiMap
.builder();
for (int i = 0; i < headerRow.size(); i++) {
String header = headerRow.get(i);
if (dataHeaderNames.inverse().containsKey(header)) {
ans.put(dataHeaderNames.inverse().get(header), i);
}
}
ImmutableBiMap<UnosDataHeader, Integer> ansBuilt = ans.build();
if (ansBuilt.size() != dataHeaderNames.size()) {
throw new RuntimeException("Expected "
+ dataHeaderNames.size()
+ " headers but found: "
+ ansBuilt.size()
+ ". Values: "
+ ansBuilt
+ ", Missing: "
+ Sets.difference(EnumSet.allOf(UnosDataHeader.class),
ansBuilt.keySet()));
}
return ansBuilt;
}
示例9: UnosData
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public UnosData(
ImmutableSet<UnosExchangeUnit> altruisticDonors,
ImmutableSet<UnosExchangeUnit> pairs,
DirectedSparseMultigraph<UnosExchangeUnit, UnosDonorEdge> feasibleTransplants) {
super();
this.altruisticDonors = altruisticDonors;
this.pairs = pairs;
this.feasibleTransplants = feasibleTransplants;
ImmutableBiMap.Builder<String, UnosExchangeUnit> nodeIdBuilder = ImmutableBiMap
.builder();
for (UnosExchangeUnit alt : altruisticDonors) {
nodeIdBuilder.put("a" + alt.getDonors().get(0).getId(), alt);
}
for (UnosExchangeUnit paired : pairs) {
nodeIdBuilder.put("p" + paired.getPatient().getId(), paired);
}
this.nodeIds = nodeIdBuilder.build();
ImmutableBiMap.Builder<String, UnosDonorEdge> edgeIdBuilder = ImmutableBiMap
.builder();
for (UnosDonorEdge edge : feasibleTransplants.getEdges()) {
String id = "e" + edge.getDonor().getId() + "-"
+ feasibleTransplants.getDest(edge).getPatient().getId();
edgeIdBuilder.put(id, edge);
}
this.edgeIds = edgeIdBuilder.build();
}
示例10: CompiledTemplateRegistry
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
CompiledTemplateRegistry(TemplateRegistry registry) {
Map<String, Optional<SanitizedContentKind>> deltemplateNameToContentKind = new HashMap<>();
ImmutableBiMap.Builder<String, CompiledTemplateMetadata> templateToMetadata =
ImmutableBiMap.builder();
ImmutableBiMap.Builder<String, CompiledTemplateMetadata> classToMetadata =
ImmutableBiMap.builder();
ImmutableSet.Builder<String> delegateTemplateNames = ImmutableSet.builder();
for (TemplateNode template : registry.getAllTemplates()) {
CompiledTemplateMetadata metadata =
CompiledTemplateMetadata.create(template.getTemplateName(), template);
templateToMetadata.put(template.getTemplateName(), metadata);
classToMetadata.put(metadata.typeInfo().className(), metadata);
if (template instanceof TemplateDelegateNode) {
delegateTemplateNames.add(template.getTemplateName());
// all delegates are guaranteed to have the same content kind by the
// checkdelegatesvisitor
deltemplateNameToContentKind.put(
((TemplateDelegateNode) template).getDelTemplateName(),
Optional.fromNullable(template.getContentKind()));
}
}
this.templateNameToMetadata = templateToMetadata.build();
this.classNameToMetadata = classToMetadata.build();
this.deltemplateNameToContentKind = ImmutableMap.copyOf(deltemplateNameToContentKind);
this.delegateTemplateNames = delegateTemplateNames.build();
}
示例11: getObfuscatedToOriginalMapping
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public BiMap<String, String> getObfuscatedToOriginalMapping() {
if (nameMapping == null) {
ImmutableBiMap.Builder<String, String> builder = ImmutableBiMap.builder();
for (String name : classNameMappings.keySet()) {
builder.put(name, classNameMappings.get(name).originalName);
}
nameMapping = builder.build();
}
return nameMapping;
}
示例12: copyWithFilteredResponses
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ResponseLinking copyWithFilteredResponses(final Predicate<Response> toKeepCondition) {
final Set<Response> newIncompletes = Sets.filter(incompleteResponses(), toKeepCondition);
final ImmutableSet.Builder<ResponseSet> newResponseSetsB = ImmutableSet.builder();
final ImmutableBiMap.Builder<String, ResponseSet> responseSetsIdB = ImmutableBiMap.builder();
// to account for ResponseSets merging due to lost annotation
final Set<ResponseSet> alreadyAdded = Sets.newHashSet();
for (final ResponseSet responseSet : responseSets()) {
final ImmutableSet<Response> okResponses = FluentIterable.from(responseSet.asSet())
.filter(toKeepCondition).toSet();
if (!okResponses.isEmpty()) {
final ResponseSet newResponseSet = ResponseSet.from(okResponses);
if(alreadyAdded.contains(newResponseSet)) {
continue;
}
alreadyAdded.add(newResponseSet);
newResponseSetsB.add(newResponseSet);
if (responseSetIds().isPresent()) {
responseSetsIdB.put(responseSetIds().get().inverse().get(responseSet), newResponseSet);
}
}
}
final ImmutableSet<ResponseSet> newResponseSets = newResponseSetsB.build();
final ResponseLinking.Builder ret = ResponseLinking.builder().docID(docID())
.responseSets(newResponseSets).incompleteResponses(newIncompletes);
if (responseSetIds().isPresent()) {
ret.responseSetIds(responseSetsIdB.build());
}
return ret.build();
}
示例13: create
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
ImmutableBiMap.Builder<String, String> builder = ImmutableBiMap.builder();
for (Entry<String, String> entry : entries) {
builder.put(entry.getKey(), entry.getValue());
}
return builder.build();
}
示例14: setupLoadOnly
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的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());
}
示例15: getRpcMethodToSchemaPath
import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
final Module module = getModuleBlocking(key);
final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder();
try {
for (final RpcDefinition rpcDef : module.getRpcs()) {
final Method method = findRpcMethod(key, rpcDef);
ret.put(method, rpcDef.getPath());
}
} catch (final NoSuchMethodException e) {
throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e);
}
return ret.build();
}