本文整理汇总了Java中com.google.common.collect.ImmutableBiMap.of方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableBiMap.of方法的具体用法?Java ImmutableBiMap.of怎么用?Java ImmutableBiMap.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableBiMap
的用法示例。
在下文中一共展示了ImmutableBiMap.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSingleTierStrategy
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
/**
* Used to create a Single Tier Index Strategy. For example, this would be
* used to generate a strategy that has Point type spatial data.
*
* @param dimensionDefs
* an array of SFC Dimension Definition objects
* @param sfc
* the type of space filling curve (e.g. Hilbert)
* @return an Index Strategy object with a single tier
*/
static public TieredSFCIndexStrategy createSingleTierStrategy(
final SFCDimensionDefinition[] dimensionDefs,
final SFCType sfc ) {
final SpaceFillingCurve[] orderedSfcs = new SpaceFillingCurve[] {
SFCFactory.createSpaceFillingCurve(
dimensionDefs,
sfc)
};
// unwrap SFC dimension definitions
final NumericDimensionDefinition[] baseDefinitions = new NumericDimensionDefinition[dimensionDefs.length];
int maxBitsOfPrecision = Integer.MIN_VALUE;
for (int d = 0; d < baseDefinitions.length; d++) {
baseDefinitions[d] = dimensionDefs[d].getDimensionDefinition();
maxBitsOfPrecision = Math.max(
dimensionDefs[d].getBitsOfPrecision(),
maxBitsOfPrecision);
}
return new TieredSFCIndexStrategy(
baseDefinitions,
orderedSfcs,
ImmutableBiMap.of(
0,
(byte) maxBitsOfPrecision));
}
示例2: getProbability
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Test
public void getProbability(){
Node node = new Node()
.setScore("ham");
final
BiMap<String, Node> entityRegistry = ImmutableBiMap.of("1", node);
NodeScoreDistribution<Double> classification = new NodeScoreDistribution<Double>(new ValueMap<String, Double>(), node){
@Override
public BiMap<String, Node> getEntityRegistry(){
return entityRegistry;
}
};
classification.put("ham", new DoubleValue(0.75d));
classification.put("spam", new DoubleValue(0.25d));
assertEquals(ImmutableSet.of("ham", "spam"), classification.getCategoryValues());
assertEquals((Double)0.75d, classification.getProbability("ham"));
assertEquals((Double)0.25d, classification.getProbability("spam"));
}
示例3: testConstantNameMatchesString
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases = ImmutableBiMap.of("ETAG", "ETag",
"X_WEBKIT_CSP", "X-WebKit-CSP", "X_WEBKIT_CSP_REPORT_ONLY", "X-WebKit-CSP-Report-Only");
ImmutableSet<String> uppercaseAcronyms = ImmutableSet.of(
"ID", "DNT", "IP", "MD5", "P3P", "TE", "UID", "URL", "WWW", "XSS");
assertConstantNameMatchesString(HttpHeaders.class, specialCases, uppercaseAcronyms);
}
示例4: CustomSlotDefinition
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
private CustomSlotDefinition(@NonNull Vector2i position, String id, boolean persistent, AffectCustomSlotListener affectCustomSlotListener, GUIFeature defaultFeature, Iterable<GUIFeature> additionalFeatures) {
Preconditions.checkArgument(id != null || !persistent, "The slot ID must be specified, if the slot is supposed to be persistent.");
this.position = position;
this.id = id;
if(defaultFeature == null) {
this.defaultFeatureId = null;
this.features = ImmutableBiMap.of();
} else {
defaultFeatureId = defaultFeature.getId();
features = ImmutableBiMap.<String, GUIFeature>builder()
.put(defaultFeature.getId(), defaultFeature)
.putAll(Util.removeNull(additionalFeatures)
.collect(Collectors.toMap(
GUIFeature::getId,
Function.identity(),
(first, second) -> {
throw new IllegalArgumentException("A CustomSlotDefinition cannot contain two GUIFeatures with the same ID.");
}
)))
.build();
}
this.persistent = persistent;
this.affectCustomSlotListener = affectCustomSlotListener != null ? affectCustomSlotListener
: (customSlot, slotTransaction, affectSlotEvent) -> affectSlotEvent.setCancelled(true);
}
示例5: getFieldAliases
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Override
public ImmutableBiMap<String, String> getFieldAliases() {
return ImmutableBiMap.of(
"TLD", "tldStr",
"dns", "dnsPaused",
"escrow", "escrowEnabled",
"premiumPricing", "premiumPriceAckRequired");
}
示例6: getFieldAliases
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Override
public ImmutableBiMap<String, String> getFieldAliases() {
return ImmutableBiMap.of(
"billingId", "billingIdentifier",
"clientId", "clientIdentifier",
"premiumNames", "blockPremiumNames");
}
示例7: testBlazeStateIsSerializable
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Test
public void testBlazeStateIsSerializable() {
BlazeIdeInterfaceAspectsImpl.State state = new BlazeIdeInterfaceAspectsImpl.State();
state.fileToTargetMapKey =
ImmutableBiMap.of(
new File("fileName"),
TargetIdeInfo.builder().setLabel(Label.create("//test:test")).build().key);
state.fileState = ImmutableMap.of();
state.targetMap =
new TargetMap(ImmutableMap.of()); // Tested separately in testRuleIdeInfoIsSerializable
TestUtils.assertIsSerializable(state);
}
示例8: before
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Before
public void before() {
converter = new QuerySearchConverter() {
@Override
protected Search.Builder getBuilder() {
return new Search.Builder() {
@Override
protected List<String> getSupportedSortAttributes() {
return ImmutableList.of("test:test", "test:test1_abc");
}
@Override
protected Multimap<String, Operator> getSupportedConditions() {
return ImmutableMultimap.of("test:test", Operator.EQ, "test:test1_abc", Operator.EQ);
}
};
}
@Override
protected ImmutableBiMap<String, String> getQueryAttributeMap() {
return ImmutableBiMap.of("test", "test:test", "test1_abc", "test:test1_abc");
}
@Override
protected boolean isDateAttribute(String attribute) {
return false;
}
};
multivaluedMap = new MultivaluedMapImpl<>();
}
示例9: testConstantNameMatchesString
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases = ImmutableBiMap.of("ETAG", "ETag");
ImmutableSet<String> uppercaseAcronyms = ImmutableSet.of(
"ID", "DNT", "IP", "MD5", "P3P", "TE", "UID", "URL", "WWW", "XSS");
assertConstantNameMatchesString(HttpHeaders.class, specialCases, uppercaseAcronyms);
}
示例10: createNameSupplier
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
private NameSupplier createNameSupplier(
RenameStrategy renameStrategy, BiMap<String, String> previousMappings) {
previousMappings = previousMappings != null ?
previousMappings :
ImmutableBiMap.<String, String>of();
if (renameStrategy == RenameStrategy.STABLE) {
return new StableNameSupplier();
} else if (generatePseudoNames) {
return new PseudoNameSuppier(renameStrategy);
} else {
return new ObfuscatedNameSuppier(renameStrategy, previousMappings);
}
}
示例11: testConstantNameMatchesString
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.of(
"ETAG",
"ETag",
"X_WEBKIT_CSP",
"X-WebKit-CSP",
"X_WEBKIT_CSP_REPORT_ONLY",
"X-WebKit-CSP-Report-Only");
ImmutableSet<String> uppercaseAcronyms =
ImmutableSet.of(
"ID", "DNT", "DNS", "HTTP2", "IP", "MD5", "P3P", "TE", "UID", "URL", "WWW", "XSS");
assertConstantNameMatchesString(HttpHeaders.class, specialCases, uppercaseAcronyms);
}
示例12: createNameSupplier
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
private NameSupplier createNameSupplier(
RenameStrategy renameStrategy, BiMap<String, String> previousMappings) {
previousMappings = previousMappings != null ?
previousMappings :
ImmutableBiMap.<String, String>of();
if (renameStrategy == RenameStrategy.STABLE) {
return new StableNameSupplier();
} else if (renameStrategy == RenameStrategy.XID) {
return new XidNameSupplier(this.xidHashFunction);
} else if (generatePseudoNames) {
return new PseudoNameSupplier(renameStrategy);
} else {
return new ObfuscatedNameSupplier(renameStrategy, previousMappings);
}
}
示例13: testFilterStrings
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Test
public void testFilterStrings() throws IOException {
FilteredDirectoryCopier copier = EasyMock.createMock(FilteredDirectoryCopier.class);
Capture<Predicate<Path>> capturedPredicate = new Capture<>();
copier.copyDirs(EasyMock.<ProjectFilesystem>anyObject(),
EasyMock.<Map<Path, Path>>anyObject(),
EasyMock.capture(capturedPredicate));
EasyMock.replay(copier);
FilterResourcesStep step = new FilterResourcesStep(
/* inResDirToOutResDirMap */ ImmutableBiMap.<Path, Path>of(),
/* filterDrawables */ false,
/* filterStrings */ true,
/* whitelistedStringDirs */ ImmutableSet.of(Paths.get("com/whitelisted/res")),
copier,
/* targetDensities */ null,
/* drawableFinder */ null,
/* imageScaler */ null);
assertEquals(0, step.execute(TestExecutionContext.newInstance()));
Predicate<Path> filePredicate = capturedPredicate.getValue();
assertTrue(filePredicate.apply(Paths.get("com/example/res/drawables/image.png")));
assertTrue(filePredicate.apply(Paths.get("com/example/res/values/strings.xml")));
assertTrue(filePredicate.apply(Paths.get("com/whitelisted/res/values-af/strings.xml")));
assertFalse(filePredicate.apply(Paths.get("com/example/res/values-af/strings.xml")));
EasyMock.verify(copier);
}
示例14: generateImmutableBimap
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
@Generates private static <K, V> ImmutableBiMap<K, V> generateImmutableBimap(
K key, V value) {
return ImmutableBiMap.of(key, value);
}
示例15: FMLDeobfuscatingRemapper
import com.google.common.collect.ImmutableBiMap; //导入方法依赖的package包/类
private FMLDeobfuscatingRemapper()
{
classNameBiMap=ImmutableBiMap.of();
}