mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-22 14:22:45 +01:00
convert ImmutableMap to unmodifiable map
This converts all remaining instances of ImmutableMap to JDK unmodifiable map.
This commit is contained in:
parent
fb9b6f16b3
commit
64e07b6b9d
3 changed files with 14 additions and 12 deletions
|
@ -32,7 +32,6 @@ import org.bitcoinj.wallet.Wallet;
|
|||
import org.bitcoinj.wallet.WalletTransaction.Pool;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.math.IntMath;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -376,7 +375,7 @@ public class Transaction extends ChildMessage {
|
|||
*/
|
||||
@Nullable
|
||||
public Map<Sha256Hash, Integer> getAppearsInHashes() {
|
||||
return appearsInHashes != null ? ImmutableMap.copyOf(appearsInHashes) : null;
|
||||
return appearsInHashes != null ? Collections.unmodifiableMap(new HashMap<>(appearsInHashes)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,8 +18,9 @@ package org.bitcoinj.script;
|
|||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -279,13 +280,16 @@ public class ScriptOpCodes {
|
|||
.put(OP_NOP9, "NOP9")
|
||||
.put(OP_NOP10, "NOP10").build();
|
||||
|
||||
private static final Map<String, Integer> opCodeNameMap = ImmutableMap.<String, Integer>builder()
|
||||
.putAll(opCodeMap.inverse())
|
||||
.put("OP_FALSE", OP_FALSE)
|
||||
.put("OP_TRUE", OP_TRUE)
|
||||
.put("NOP2", OP_NOP2)
|
||||
.put("NOP3", OP_NOP3)
|
||||
.build();
|
||||
private static final Map<String, Integer> opCodeNameMap = createOpCodeNameMap();
|
||||
|
||||
private static Map<String, Integer> createOpCodeNameMap() {
|
||||
Map<String, Integer> map = new HashMap<>(opCodeMap.inverse());
|
||||
map.put("OP_FALSE", OP_FALSE);
|
||||
map.put("OP_TRUE", OP_TRUE);
|
||||
map.put("NOP2", OP_NOP2);
|
||||
map.put("NOP3", OP_NOP3);
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given OpCode into a string (eg "0", "PUSHDATA", or "NON_OP(10)")
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.bitcoinj.wallet;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.math.IntMath;
|
||||
|
@ -4938,7 +4937,7 @@ public class Wallet extends BaseTaggableObject
|
|||
public Map<String, WalletExtension> getExtensions() {
|
||||
lock.lock();
|
||||
try {
|
||||
return ImmutableMap.copyOf(extensions);
|
||||
return Collections.unmodifiableMap(new HashMap<>(extensions));
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue