@SuppressWarnings("unchecked")
@Override
public void onCreate(Map<ResourceLocation, ?> slaveset, BiMap<ResourceLocation, ? extends IForgeRegistry<?>> registries)
{
final ClearableObjectIntIdentityMap<IBlockState> idMap = new ClearableObjectIntIdentityMap<IBlockState>()
{
@SuppressWarnings("deprecation")
@Override
public int get(IBlockState key)
{
Integer integer = (Integer)this.identityMap.get(key);
// There are some cases where this map is queried to serialize a state that is valid,
//but somehow not in this list, so attempt to get real metadata. Doing this hear saves us 7 patches
if (integer == null && key != null)
integer = this.identityMap.get(key.getBlock().getStateFromMeta(key.getBlock().getMetaFromState(key)));
return integer == null ? -1 : integer.intValue();
}
};
((Map<ResourceLocation,Object>)slaveset).put(BLOCKSTATE_TO_ID, idMap);
final HashBiMap<Block, Item> map = HashBiMap.create();
((Map<ResourceLocation,Object>)slaveset).put(BLOCK_TO_ITEM, map);
}
java类com.google.common.collect.BiMap的实例源码
GameData.java 文件源码
项目:CustomWorldGen
阅读 29
收藏 0
点赞 0
评论 0
SoundManager.java 文件源码
项目:BaseClient
阅读 39
收藏 0
点赞 0
评论 0
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
this.playingSoundPoolEntries = Maps.<ISound, SoundPoolEntry>newHashMap();
this.categorySounds = HashMultimap.<SoundCategory, String>create();
this.tickableSounds = Lists.<ITickableSound>newArrayList();
this.delayedSounds = Maps.<ISound, Integer>newHashMap();
this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
this.sndHandler = p_i45119_1_;
this.options = p_i45119_2_;
try
{
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
}
catch (SoundSystemException soundsystemexception)
{
logger.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
}
}
N4HeadlessCompiler.java 文件源码
项目:n4js
阅读 33
收藏 0
点赞 0
评论 0
private void configureResourceSetContainerState(final List<N4JSProject> allProjects) {
// a container is a project.
List<String> containers = new LinkedList<>();
BiMap<String, N4JSProject> container2project = HashBiMap.create();
// the URIs of all resources directly contained in a project/container.
Multimap<String, URI> container2Uris = HashMultimap.create();
for (N4JSProject project : allProjects) {
String container = FileBasedWorkspace.N4FBPRJ + project.getLocation();
container2project.put(container, project);
containers.add(container);
for (IN4JSSourceContainer sourceContainer : project.getSourceContainers()) {
Iterables.addAll(container2Uris.get(container), sourceContainer);
}
}
// Define the Mapping of Resources (URIs to Container === Projects),
rsbAcs.configure(containers, container2Uris);
}
HashBiMapDemo.java 文件源码
项目:cakes
阅读 38
收藏 0
点赞 0
评论 0
/**
* BiMap存储数据时出现冲突
* 存储时,如果key相同,则会覆盖,则逆转后不会有问题
* 存储时,如果key不同,value有相同,则逆转时会抛出异常IllegalArgumentException
*/
@Test
public void testConflictInsertKV() {
// 存储相同key数据,此时会覆盖k1=v1
BiMap<String, String> biMap1 = HashBiMap.create();
biMap1.put("k1", "v1");
biMap1.put("k1", "v2");
System.out.println("biMap1: " + biMap1);
// 获取的只有 v2=k1
BiMap<String, String> inverseBiMap1 = biMap1.inverse();
System.out.println("inverseBiMap1: " + inverseBiMap1);
System.out.println("--------------------------------------");
// 存储相同的value数据
BiMap<String, String> biMap2 = HashBiMap.create();
biMap2.put("k1", "v1");
// 此时抛出异常 java.lang.IllegalArgumentException: value already present: v1
biMap2.put("k2", "v1");
System.out.println("biMap2: " + biMap2);
BiMap<String, String> inverseBiMap2 = biMap2.inverse();
System.out.println("inverseBiMap2: " + inverseBiMap2);
}
SoundManager.java 文件源码
项目:DecompiledMinecraft
阅读 51
收藏 0
点赞 0
评论 0
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
this.playingSoundPoolEntries = Maps.<ISound, SoundPoolEntry>newHashMap();
this.categorySounds = HashMultimap.<SoundCategory, String>create();
this.tickableSounds = Lists.<ITickableSound>newArrayList();
this.delayedSounds = Maps.<ISound, Integer>newHashMap();
this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
this.sndHandler = p_i45119_1_;
this.options = p_i45119_2_;
try
{
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
}
catch (SoundSystemException soundsystemexception)
{
logger.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
}
}
IfcModel.java 文件源码
项目:BIMplatform
阅读 41
收藏 0
点赞 0
评论 0
@SuppressWarnings("rawtypes")
private void fixOids(IdEObject idEObject, OidProvider oidProvider, BiMap<Long, IdEObject> temp) {
if (idEObject == null) {
return;
}
if (temp.containsValue(idEObject)) {
return;
}
((IdEObjectImpl) idEObject).setOid(oidProvider.newOid(idEObject.eClass()));
if (objects.containsValue(idEObject)) {
temp.put(idEObject.getOid(), idEObject);
}
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
Object val = idEObject.eGet(eReference);
if (eReference.isMany()) {
List list = (List) val;
for (Object o : list) {
fixOids((IdEObject) o, oidProvider, temp);
}
} else {
fixOids((IdEObject) val, oidProvider, temp);
}
}
}
GameData.java 文件源码
项目:CustomWorldGen
阅读 47
收藏 0
点赞 0
评论 0
@Override
public void onSubstituteActivated(Map<ResourceLocation, ?> slaveset, Block original, Block replacement, ResourceLocation name)
{
final BiMap<Block, Item> blockItemMap = (BiMap<Block, Item>)slaveset.get(BLOCK_TO_ITEM);
if (blockItemMap.containsKey(original))
{
Item i = blockItemMap.get(original);
if (i instanceof ItemBlock)
{
try
{
FinalFieldHelper.setField(blockField, i, replacement);
}
catch (Exception e)
{
throw Throwables.propagate(e);
}
}
blockItemMap.forcePut(replacement,i);
}
}
Mappings.java 文件源码
项目:Mixinite
阅读 54
收藏 0
点赞 0
评论 0
public Optional<MethodRef> getUnmappedMethodMapping(CtClass targetClass, CtMethod
handleMethod) {
BiMap<MethodRef, MethodRef> methodsInverted = methodRefs.inverse();
String descriptor = InjectorPlugin.removeCallbackDescriptor(handleMethod.getMethodInfo2()
.getDescriptor());
for (Map.Entry<MethodRef, MethodRef> mapping : methodsInverted.entrySet()) {
MethodRef key = mapping.getKey();
if (targetClass.getName().replace('.', '/').equals(key.getOwner()) && handleMethod
.getName
().equals
(key
.getName()) && descriptor.equals(key.getDesc())) {
return Optional.of(mapping.getValue());
}
}
return Optional.empty();
}
ProtoRegistry.java 文件源码
项目:rejoiner
阅读 53
收藏 0
点赞 0
评论 0
/** Applies the supplied modifications to the GraphQLTypes. */
private static BiMap<String, GraphQLType> modifyTypes(
BiMap<String, GraphQLType> mapping,
ImmutableListMultimap<String, TypeModification> modifications) {
BiMap<String, GraphQLType> result = HashBiMap.create(mapping.size());
for (String key : mapping.keySet()) {
if (mapping.get(key) instanceof GraphQLObjectType) {
GraphQLObjectType val = (GraphQLObjectType) mapping.get(key);
if (modifications.containsKey(key)) {
for (TypeModification modification : modifications.get(key)) {
val = modification.apply(val);
}
}
result.put(key, val);
} else {
result.put(key, mapping.get(key));
}
}
return result;
}
AbstractBiMapTester.java 文件源码
项目:googles-monorepo-demo
阅读 42
收藏 0
点赞 0
评论 0
@Override
protected void expectMissing(Entry<K, V>... entries) {
super.expectMissing(entries);
for (Entry<K, V> entry : entries) {
Entry<V, K> reversed = reverseEntry(entry);
BiMap<V, K> inv = getMap().inverse();
assertFalse(
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
assertFalse(
"Inverse should not contain value " + reversed.getValue(),
inv.containsValue(reversed.getValue()));
/*
* TODO(cpovirk): This is a bit stronger than super.expectMissing(), which permits a <key,
* someOtherValue> pair.
*/
assertNull(
"Inverse should not return a mapping for key " + reversed.getKey(),
inv.get(reversed.getKey()));
}
}
SoundManager.java 文件源码
项目:CustomWorldGen
阅读 36
收藏 0
点赞 0
评论 0
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
this.categorySounds = HashMultimap.<SoundCategory, String>create();
this.tickableSounds = Lists.<ITickableSound>newArrayList();
this.delayedSounds = Maps.<ISound, Integer>newHashMap();
this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
this.listeners = Lists.<ISoundEventListener>newArrayList();
this.pausedChannels = Lists.<String>newArrayList();
this.sndHandler = p_i45119_1_;
this.options = p_i45119_2_;
try
{
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.SoundSetupEvent(this));
}
catch (SoundSystemException soundsystemexception)
{
LOGGER.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
}
}
JourneyHelper.java 文件源码
项目:train-simulator
阅读 37
收藏 0
点赞 0
评论 0
public BiMap<Train, Train> getTrainsFollowingEachOther() {
if (false && trailingTrains.size() + 1 == world.getTrains().size()) {
return trailingTrains;
}
trailingTrains.clear();
Map<Journey, Journey> journeyTrail = getJourneysFollowingEachOther();
journeyTrail.forEach((key, value) -> trailingTrains.put(key.getTrain(), value.getTrain()));
return trailingTrains;
}
IsoMatcherJena.java 文件源码
项目:SubgraphIsomorphismIndex
阅读 26
收藏 0
点赞 0
评论 0
@Override
public Iterable<BiMap<V, V>> match(BiMap<V, V> baseIso, G viewGraph, G insertGraph) {
ProblemNeighborhoodAware<BiMap<V, V>, V> problem = toProblem(baseIso, viewGraph, insertGraph);
Iterable<BiMap<V, V>> result = () -> problem.generateSolutions().iterator();
return result;
}
GameData.java 文件源码
项目:CustomWorldGen
阅读 40
收藏 0
点赞 0
评论 0
void registerSubstitutionAlias(String name, GameRegistry.Type type, Object toReplace) throws ExistingSubstitutionException
{
ResourceLocation nameToSubstitute = new ResourceLocation(name);
final BiMap<Block, Item> blockItemMap = getBlockItemMap();
if (type == GameRegistry.Type.BLOCK)
{
iBlockRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Block)toReplace);
iBlockRegistry.activateSubstitution(nameToSubstitute);
}
else if (type == GameRegistry.Type.ITEM)
{
iItemRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Item)toReplace);
iItemRegistry.activateSubstitution(nameToSubstitute);
}
}
WorkflowNode.java 文件源码
项目:Equella
阅读 48
收藏 0
点赞 0
评论 0
public static BiMap<String, Integer> getTypeMap()
{
BiMap<String, Integer> typeMap = HashBiMap.create();
typeMap.put(ITEM_NODE_TYPE, ITEM_TYPE);
typeMap.put(PARALLEL_NODE_TYPE, PARALLEL_TYPE);
typeMap.put(SERIAL_NODE_TYPE, SERIAL_TYPE);
typeMap.put(DECISION_NODE_TYPE, DECISION_TYPE);
return typeMap;
}
StringToIntMapper.java 文件源码
项目:powsybl-core
阅读 38
收藏 0
点赞 0
评论 0
public synchronized void dump(Writer writer) throws IOException {
for (Map.Entry<S, BiMap<String, Integer>> entry : id2num.entrySet()) {
S subset = entry.getKey();
for (Map.Entry<String, Integer> entry1 : entry.getValue().entrySet()) {
String id = entry1.getKey();
Integer num = entry1.getValue();
writer.write(subset + ";" + id + ";" + num + System.lineSeparator());
}
}
}
IsoMatcherJena.java 文件源码
项目:SubgraphIsomorphismIndex
阅读 32
收藏 0
点赞 0
评论 0
public ProblemNeighborhoodAware<BiMap<V, V>, V> toProblem(BiMap<V, V> baseIso, G viewGraph, G insertGraph) {
ProblemNeighborhoodAware<BiMap<V, V>, V> result = new ProblemNodeMappingGraph<V, E, G, V>(
baseIso, viewGraph, insertGraph,
createVertexComparator, createEdgeComparator);
//Stream<BiMap<V, V>> result = tmp.generateSolutions();
return result;
}
DerivedGoogleCollectionGenerators.java 文件源码
项目:googles-monorepo-demo
阅读 32
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
@Override
public BiMap<V, K> create(Object... elements) {
Entry<?, ?>[] entries = new Entry<?, ?>[elements.length];
for (int i = 0; i < elements.length; i++) {
entries[i] = reverse((Entry<K, V>) elements[i]);
}
return generator.create((Object[]) entries).inverse();
}
BiMapClearTester.java 文件源码
项目:googles-monorepo-demo
阅读 31
收藏 0
点赞 0
评论 0
@MapFeature.Require(SUPPORTS_REMOVE)
public void testClearClearsInverse() {
BiMap<V, K> inv = getMap().inverse();
getMap().clear();
assertTrue(getMap().isEmpty());
assertTrue(inv.isEmpty());
}
ShellBasedIdMapping.java 文件源码
项目:hadoop-oss
阅读 31
收藏 0
点赞 0
评论 0
synchronized private void loadFullGroupMap() throws IOException {
BiMap<Integer, String> gMap = HashBiMap.create();
if (OS.startsWith("Mac")) {
updateMapInternal(gMap, "group", MAC_GET_ALL_GROUPS_CMD, "\\s+",
staticMapping.gidMapping);
} else {
updateMapInternal(gMap, "group", GET_ALL_GROUPS_CMD, ":",
staticMapping.gidMapping);
}
gidNameMap = gMap;
lastUpdateTime = Time.monotonicNow();
}
RecommendMgr.java 文件源码
项目:librec-to-movies
阅读 40
收藏 0
点赞 0
评论 0
public void initData(SparseMatrix dataMatrix) throws LibrecException {
Table<Integer, Integer, Double> dataTable = dataMatrix.getDataTable();
BiMap<String, Integer> userIds = dataModel.getUserMappingData();
BiMap<String, Integer> itemIds = dataModel.getItemMappingData();
SparseMatrix dateTimeDataSet = (SparseMatrix) dataModel.getDatetimeDataSet();
Table<Integer, Integer, Double> dateTimeTable = dateTimeDataSet.getDataTable();
for (Map.Entry<String, Integer> userId : userIds.entrySet()) {
for (Map.Entry<String, Integer> itemId : itemIds.entrySet()) {
Object scValue = dataTable.get(userId.getValue(), itemId.getValue());
Object dtValue = dateTimeTable.get(userId.getValue(), itemId.getValue());
if (scValue != null && dtValue != null) {
Long user_id = Long.parseLong(userId.getKey());
Long movie_id = Long.parseLong(itemId.getKey());
Double score = (Double)scValue;
Double datetime = (Double)dtValue;
Rating rating = new Rating(user_id, movie_id, score);
User user = User.findUser(user_id);
if (user == null) continue;
MovieEx movie = (MovieEx) MovieEx.findMovie(movie_id);
if (movie == null) continue;
try {
user.addMovie(movie, score, datetime);
movie.addUser(user, score, datetime);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
throw new LibrecException("load rating set error");
}
//rating.save();
Rating.allRatings.add(rating);
}
}
}
}
BiMapClearTester.java 文件源码
项目:googles-monorepo-demo
阅读 31
收藏 0
点赞 0
评论 0
@MapFeature.Require(SUPPORTS_REMOVE)
public void testClearInverseKeySetClears() {
BiMap<V, K> inv = getMap().inverse();
inv.keySet().clear();
assertTrue(getMap().isEmpty());
assertTrue(inv.isEmpty());
}
GameData.java 文件源码
项目:CustomWorldGen
阅读 42
收藏 0
点赞 0
评论 0
@Override
public void onAdd(Item item, int blockId, Map<ResourceLocation, ?> slaves)
{
if (item instanceof ItemBlock)
{
ItemBlock itemBlock = (ItemBlock)item;
@SuppressWarnings("unchecked") BiMap<Block, Item> blockToItem = (BiMap<Block, Item>)slaves.get(BLOCK_TO_ITEM);
final Block block = itemBlock.getBlock().delegate.get();
blockToItem.forcePut(block, item);
}
}
BiMapClearTester.java 文件源码
项目:googles-monorepo-demo
阅读 36
收藏 0
点赞 0
评论 0
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetClearClearsInverse() {
BiMap<V, K> inv = getMap().inverse();
getMap().keySet().clear();
assertTrue(getMap().isEmpty());
assertTrue(inv.isEmpty());
}
CategoricalValueEncodings.java 文件源码
项目:oryx2
阅读 38
收藏 0
点赞 0
评论 0
private static <T> BiMap<T,Integer> mapDistinctValues(Collection<T> distinct) {
BiMap<T,Integer> mapping = HashBiMap.create(distinct.size());
int encoding = 0;
for (T t : distinct) {
mapping.put(t, encoding);
encoding++;
}
return mapping;
}
ProtocolUnificationHandler.java 文件源码
项目:neto
阅读 41
收藏 0
点赞 0
评论 0
private ProtocolUnificationHandler(boolean isUnificationMode, BiMap<Integer, Class<? extends NetoJsonMessage>> opcodeMap, SslContext sslCtx, boolean detectSsl, int maxFrameLength, String charset) {
this.isUnificationMode = isUnificationMode;
this.opcodeMap = opcodeMap;
this.sslCtx = sslCtx;
this.detectSsl = detectSsl;
this.maxFrameLength = maxFrameLength;
this.charset = charset;
}
YangStoreSnapshot.java 文件源码
项目:hashsdn-controller
阅读 32
收藏 0
点赞 0
评论 0
@Override
public String fromYang(final String enumClass, final String enumYangValue) {
Preconditions.checkState(this.bindingContextProvider != null, "Binding context provider was not set yet");
final BiMap<String, String> enumMapping = this.bindingContextProvider.getEnumMapping(enumClass);
final String javaName = enumMapping.get(enumYangValue);
return Preconditions.checkNotNull(javaName,
"Unable to resolve enum value %s for enum class %s with assumed enum mapping: %s", enumYangValue,
enumClass, enumMapping);
}
ProtoRegistry.java 文件源码
项目:rejoiner
阅读 39
收藏 0
点赞 0
评论 0
ProtoRegistry build() {
ImmutableListMultimap<String, TypeModification> modificationsMap =
ImmutableListMultimap.copyOf(
this.typeModifications
.stream()
.map(
modification ->
new SimpleImmutableEntry<>(modification.getTypeName(), modification))
.collect(Collectors.toList()));
final BiMap<String, GraphQLType> mapping = HashBiMap.create();
GraphQLInterfaceType nodeInterface =
new Relay()
.nodeInterface(
env -> {
Relay.ResolvedGlobalId resolvedGlobalId =
new Relay().fromGlobalId(env.getArguments().get("id").toString());
return (GraphQLObjectType) mapping.get(resolvedGlobalId.getType());
});
mapping.putAll(
modifyTypes(
getMap(fileDescriptors, descriptors, enumDescriptors, nodeInterface),
modificationsMap));
return new ProtoRegistry(mapping, nodeInterface);
}
ProtoRegistry.java 文件源码
项目:rejoiner
阅读 38
收藏 0
点赞 0
评论 0
private static BiMap<String, GraphQLType> getMap(
List<FileDescriptor> fileDescriptors,
List<Descriptor> descriptors,
List<EnumDescriptor> enumDescriptors,
GraphQLInterfaceType nodeInterface) {
HashBiMap<String, GraphQLType> mapping = HashBiMap.create(getEnumMap(enumDescriptors));
LinkedList<Descriptor> loop = new LinkedList<>(descriptors);
Set<FileDescriptor> fileDescriptorSet = extractDependencies(fileDescriptors);
for (FileDescriptor fileDescriptor : fileDescriptorSet) {
loop.addAll(fileDescriptor.getMessageTypes());
mapping.putAll(getEnumMap(fileDescriptor.getEnumTypes()));
}
while (!loop.isEmpty()) {
Descriptor descriptor = loop.pop();
if (!mapping.containsKey(descriptor.getFullName())) {
mapping.put(
ProtoToGql.getReferenceName(descriptor),
ProtoToGql.convert(descriptor, nodeInterface));
GqlInputConverter inputConverter =
GqlInputConverter.newBuilder().add(descriptor.getFile()).build();
mapping.put(
GqlInputConverter.getReferenceName(descriptor),
inputConverter.getInputType(descriptor));
loop.addAll(descriptor.getNestedTypes());
mapping.putAll(getEnumMap(descriptor.getEnumTypes()));
}
}
return ImmutableBiMap.copyOf(mapping);
}
MappingsConverter.java 文件源码
项目:enigma-vk
阅读 33
收藏 0
点赞 0
评论 0
private static Signature translate(Signature signature, final BiMap<ClassEntry,ClassEntry> map) {
if (signature == null) {
return null;
}
return new Signature(signature, new ClassNameReplacer() {
@Override
public String replace(String inClassName) {
ClassEntry outClassEntry = map.get(new ClassEntry(inClassName));
if (outClassEntry == null) {
return null;
}
return outClassEntry.getName();
}
});
}