Cleanup from code inspection

This commit is contained in:
Manfred Karrer 2015-03-28 15:34:28 +01:00
parent fa1fdc3f12
commit 0008202037
67 changed files with 177 additions and 210 deletions

1
.gitignore vendored
View File

@ -7,7 +7,6 @@
!.idea/copyright/profiles_settings.xml
!.idea/codeStyleSettings.xml
*.iml
*/*.iml
*.spvchain
*.wallet
*.ser

View File

@ -40,7 +40,6 @@ public class BootstrapNode {
private static final Logger log = LoggerFactory.getLogger(BootstrapNode.class);
private static Peer peer = null;
private static boolean running = true;
private final Environment env;
private boolean noPeersInfoPrinted;
@ -97,7 +96,7 @@ public class BootstrapNode {
log.info("Bootstrap node started with name " + name + " and port " + port);
new Thread(() -> {
while (running) {
while (true) {
if (peer.peerBean().peerMap().all().size() > 0) {
noPeersInfoPrinted = false;
log.info("Number of peers online = " + peer.peerBean().peerMap().all().size());

View File

@ -96,7 +96,7 @@ public class Notification {
// ******************** Constructor ***************************************
private Notifier() {
Notifier() {
init();
initGraphics();
}

View File

@ -20,6 +20,8 @@ package io.bitsquare;
@SuppressWarnings("serializable")
public class BitsquareException extends RuntimeException {
private static final long serialVersionUID = 556191645860856173L;
public BitsquareException(Throwable cause) {
super(cause);
}

View File

@ -34,7 +34,7 @@ public abstract class BitsquareModule extends AbstractModule {
private static final Logger log = LoggerFactory.getLogger(BitsquareModule.class);
protected final Environment env;
private final List<BitsquareModule> modules = new ArrayList();
private final List<BitsquareModule> modules = new ArrayList<>();
protected BitsquareModule(Environment env) {
checkNotNull(env, "Environment must not be null");

View File

@ -121,8 +121,11 @@ public class BitsquareEnvironment extends StandardEnvironment {
return new ResourcePropertySource(BITSQUARE_CLASSPATH_PROPERTY_SOURCE_NAME, resource);
}
PropertySource<?> defaultProperties() throws Exception {
return new PropertiesPropertySource(BITSQUARE_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {{
PropertySource<?> defaultProperties() {
return new PropertiesPropertySource(BITSQUARE_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {
private static final long serialVersionUID = -8478089705207326165L;
{
setProperty(APP_DATA_DIR_KEY, appDataDir);
setProperty(APP_DATA_DIR_CLEAN_KEY, DEFAULT_APP_DATA_DIR_CLEAN);

View File

@ -26,13 +26,10 @@ import java.io.File;
import java.nio.file.Path;
import java.util.List;
import java.util.function.Function;
import javafx.animation.AnimationTimer;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -62,7 +59,7 @@ public class UpdateProcess {
return BUILD_VERSION;
}
private Environment environment;
private final Environment environment;
public enum State {
CHECK_FOR_UPDATES,
@ -98,12 +95,9 @@ public class UpdateProcess {
log.info("UpdateFX current version " + BUILD_VERSION);
// process.timeout() will cause an error state back but we don't want to break startup in case of an timeout
timeoutTimer = Utilities.setTimeout(10000, new Function<AnimationTimer, Void>() {
@Override
public Void apply(AnimationTimer animationTimer) {
process.onCompleted();
return null;
}
timeoutTimer = Utilities.setTimeout(10000, animationTimer -> {
process.onCompleted();
return null;
});
timeoutTimer.start();
@ -118,11 +112,8 @@ public class UpdateProcess {
}
};
updater.progressProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
log.trace("progressProperty newValue = " + newValue);
}
updater.progressProperty().addListener((observableValue, oldValue, newValue) -> {
log.trace("progressProperty newValue = " + newValue);
});
log.info("Checking for updates!");

View File

@ -28,7 +28,9 @@ import com.google.inject.Inject;
import java.io.Serializable;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
import java.util.HashMap;
@ -48,7 +50,6 @@ public class ArbitrationRepository implements Serializable {
private static final long serialVersionUID = 1L;
transient private static final Logger log = LoggerFactory.getLogger(ArbitrationRepository.class);
transient private final Storage<ArbitrationRepository> storage;
transient private final ArbitratorService arbitratorService;
transient private final Arbitrator defaultArbitrator;
transient private final ObservableMap<String, Arbitrator> arbitratorsObservableMap = FXCollections.observableHashMap();
@ -61,14 +62,14 @@ public class ArbitrationRepository implements Serializable {
@Inject
public ArbitrationRepository(Storage<ArbitrationRepository> storage,
Storage<Arbitrator> arbitratorStorage,
ArbitratorService arbitratorService) {
this.storage = storage;
ArbitratorService arbitratorService) throws InvalidKeySpecException, NoSuchAlgorithmException {
Storage<ArbitrationRepository> storage1 = storage;
this.arbitratorService = arbitratorService;
byte[] walletPubKey = Utils.HEX.decode("03a418bf0cb60a35ce217c7f80a2db08a4f5efbe56a0e7602fbc392dea6b63f840");
PublicKey p2pSigPubKey = DSAKeyUtil.decodePubKeyHex
PublicKey p2pSigPubKey = null;
p2pSigPubKey = DSAKeyUtil.decodePubKeyHex
("308201b83082012c06072a8648ce3804013082011f02818100fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c70215009760508f15230bccb292b982a2eb840bf0581cf502818100f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a0381850002818100db47d4cf76e9bfcc0ba1e98c21c19ba45d1440fa2fec732f664dc8fd63e98877e648aac6db8d1035cd640fe5ff2e0030c2f8694ed124e81bd42c5446a1ce5288d5c8b4073d1cd890fe61ee4527f4e3184279f394cb9c2a4e7924cb2e82320a846cc140304eac6d41d4eaebc4d69b92725715497a82890be9f49d348fda20b095");
this.defaultArbitrator = new Arbitrator(arbitratorStorage,
"default-524f-46c0-b96e-de5a11d3475d",
walletPubKey,
@ -107,7 +108,7 @@ public class ArbitrationRepository implements Serializable {
ArbitrationRepository.this.arbitratorsObservableMap.putAll(ArbitrationRepository.this.arbitratorsMap);
allArbitratorsSynced = true;
},
(errorMessage -> log.error(errorMessage)));
(log::error));
}
public Map<String, Arbitrator> getArbitratorsMap() {

View File

@ -28,8 +28,6 @@ import java.security.PublicKey;
import java.util.List;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
public class Arbitrator implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L;
@ -67,7 +65,7 @@ public class Arbitrator implements Serializable {
}
transient private Storage<Arbitrator> storage;
final transient private Storage<Arbitrator> storage;
// Persisted fields
private final String id;
@ -85,19 +83,19 @@ public class Arbitrator implements Serializable {
private String webUrl;
private String description;
public Arbitrator(@NotNull Storage<Arbitrator> storage,
@NotNull String id,
@NotNull byte[] pubKey,
@NotNull PublicKey p2pSigPubKey,
@NotNull String name,
@NotNull Reputation reputation,
@NotNull ID_TYPE idType,
@NotNull List<String> languageCodes,
@NotNull Coin fee,
@NotNull List<METHOD> arbitrationMethods,
@NotNull List<ID_VERIFICATION> idVerifications,
@NotNull String webUrl,
@NotNull String description) {
public Arbitrator(Storage<Arbitrator> storage,
String id,
byte[] pubKey,
PublicKey p2pSigPubKey,
String name,
Reputation reputation,
ID_TYPE idType,
List<String> languageCodes,
Coin fee,
List<METHOD> arbitrationMethods,
List<ID_VERIFICATION> idVerifications,
String webUrl,
String description) {
this.storage = storage;
this.id = id;
this.pubKey = pubKey;

View File

@ -65,6 +65,8 @@ class AddressBasedCoinSelector extends DefaultCoinSelector {
Collections.sort(outputs, (a, b) -> {
int depth1 = 0;
int depth2 = 0;
assert a.getParentTransaction() != null;
assert b.getParentTransaction() != null;
TransactionConfidence conf1 = a.getParentTransaction().getConfidence();
TransactionConfidence conf2 = b.getParentTransaction().getConfidence();
if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)

View File

@ -91,7 +91,7 @@ public class AddressEntry implements Serializable {
return pubKey;
}
public static enum Context {
public enum Context {
REGISTRATION_FEE,
TRADE,
ARBITRATOR_DEPOSIT

View File

@ -36,7 +36,7 @@ public class AddressEntryList extends ArrayList<AddressEntry> implements Seriali
private static final long serialVersionUID = 1L;
transient private static final Logger log = LoggerFactory.getLogger(AddressEntryList.class);
transient private Storage<AddressEntryList> storage;
final transient private Storage<AddressEntryList> storage;
transient private Wallet wallet;
// Persisted fields are in ArrayList superclass

View File

@ -47,6 +47,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
@ -138,7 +139,7 @@ public class TradeWalletService {
return takeOfferFeeTx;
}
public void broadcastTakeOfferFeeTx(Transaction takeOfferFeeTx, FutureCallback<Transaction> callback) throws InsufficientMoneyException {
public void broadcastTakeOfferFeeTx(Transaction takeOfferFeeTx, FutureCallback<Transaction> callback) {
ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(takeOfferFeeTx).future();
Futures.addCallback(future, callback);
}
@ -206,10 +207,8 @@ public class TradeWalletService {
printTxWithInputs("dummyTX", dummyTX);
List<TransactionOutput> connectedOutputsForAllInputs = new ArrayList<>();
for (TransactionInput input : dummyTX.getInputs()) {
connectedOutputsForAllInputs.add(input.getConnectedOutput());
}
List<TransactionOutput> connectedOutputsForAllInputs = dummyTX.getInputs().stream().map(TransactionInput::getConnectedOutput)
.collect(Collectors.toList());
// Only save offerer outputs, the dummy output (index 1) is ignored
List<TransactionOutput> outputs = new ArrayList<>();
@ -279,9 +278,7 @@ public class TradeWalletService {
preparedDepositTx.addOutput(p2SHMultiSigOutput);
// Add optional offerer outputs
for (TransactionOutput output : offererOutputs) {
preparedDepositTx.addOutput(output);
}
offererOutputs.forEach(preparedDepositTx::addOutput);
Coin takersSpendingAmount = Coin.ZERO;
@ -300,6 +297,7 @@ public class TradeWalletService {
checkScriptSig(preparedDepositTx, input, i);
// add up spending amount
assert input.getConnectedOutput() != null;
takersSpendingAmount = takersSpendingAmount.add(input.getConnectedOutput().getValue());
}
@ -352,6 +350,7 @@ public class TradeWalletService {
depositTx.addInput(input);
// add up spending amount
assert input.getConnectedOutput() != null;
offererSpendingAmount = offererSpendingAmount.add(input.getConnectedOutput().getValue());
}
@ -370,9 +369,7 @@ public class TradeWalletService {
}
// Add all outputs from takersPreparedDepositTx to depositTx
for (TransactionOutput output : takersPreparedDepositTx.getOutputs()) {
depositTx.addOutput(output);
}
takersPreparedDepositTx.getOutputs().forEach(depositTx::addOutput);
// Sign inputs
for (int i = 0; i < offererConnectedOutputsForAllInputs.size(); i++) {
@ -514,6 +511,7 @@ public class TradeWalletService {
verifyTransaction(payoutTx);
checkWalletConsistency();
checkScriptSig(payoutTx, input, 0);
assert input.getConnectedOutput() != null;
input.verify(input.getConnectedOutput());
printTxWithInputs("payoutTx", payoutTx);
@ -595,8 +593,10 @@ public class TradeWalletService {
}
private void signInput(Transaction transaction, TransactionInput input, int inputIndex) throws SigningException {
assert input.getConnectedOutput() != null;
Script scriptPubKey = input.getConnectedOutput().getScriptPubKey();
ECKey sigKey = input.getOutpoint().getConnectedKey(wallet);
assert sigKey != null;
Sha256Hash hash = transaction.hashForSignature(inputIndex, scriptPubKey, Transaction.SigHash.ALL, false);
ECKey.ECDSASignature signature = sigKey.sign(hash);
TransactionSignature txSig = new TransactionSignature(signature, Transaction.SigHash.ALL, false);
@ -614,6 +614,7 @@ public class TradeWalletService {
private void checkScriptSig(Transaction transaction, TransactionInput input, int inputIndex) throws TransactionVerificationException {
try {
log.trace("Verifies that this script (interpreted as a scriptSig) correctly spends the given scriptPubKey. Check input at index: " + inputIndex);
assert input.getConnectedOutput() != null;
input.getScriptSig().correctlySpends(transaction, inputIndex, input.getConnectedOutput().getScriptPubKey());
} catch (Throwable t) {
t.printStackTrace();
@ -651,8 +652,8 @@ public class TradeWalletService {
///////////////////////////////////////////////////////////////////////////////////////////
public class Result {
private List<TransactionOutput> connectedOutputsForAllInputs;
private List<TransactionOutput> outputs;
private final List<TransactionOutput> connectedOutputsForAllInputs;
private final List<TransactionOutput> outputs;
private Transaction depositTx;

View File

@ -90,7 +90,6 @@ public class WalletService {
private final TradeWalletService tradeWalletService;
private final AddressEntryList addressEntryList;
private final NetworkParameters params;
private final FeePolicy feePolicy;
private final SignatureService signatureService;
private final File walletDir;
private final String walletPrefix;
@ -107,13 +106,12 @@ public class WalletService {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public WalletService(BitcoinNetwork bitcoinNetwork, FeePolicy feePolicy, SignatureService signatureService,
public WalletService(BitcoinNetwork bitcoinNetwork, SignatureService signatureService,
TradeWalletService tradeWalletService, AddressEntryList addressEntryList, UserAgent userAgent,
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
this.tradeWalletService = tradeWalletService;
this.addressEntryList = addressEntryList;
this.params = bitcoinNetwork.getParameters();
this.feePolicy = feePolicy;
this.signatureService = signatureService;
this.walletDir = walletDir;
this.walletPrefix = walletPrefix;
@ -262,7 +260,6 @@ public class WalletService {
return ImmutableList.copyOf(addressEntryList);
}
@NotNull
public AddressEntry getRegistrationAddressEntry() {
return registrationAddressEntry;
}
@ -377,12 +374,9 @@ public class WalletService {
@SuppressWarnings("UnusedDeclaration")
public boolean isRegistrationFeeConfirmed() {
TransactionConfidence transactionConfidence = null;
if (getRegistrationAddressEntry() != null) {
transactionConfidence = getConfidenceForAddress(getRegistrationAddressEntry().getAddress());
}
return transactionConfidence != null &&
transactionConfidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING);
assert getRegistrationAddressEntry() != null;
TransactionConfidence transactionConfidence = getConfidenceForAddress(getRegistrationAddressEntry().getAddress());
return TransactionConfidence.ConfidenceType.BUILDING.equals(transactionConfidence.getConfidenceType());
}

View File

@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
public class InterceptTaskException extends RuntimeException {
private static final Logger log = LoggerFactory.getLogger(InterceptTaskException.class);
private static final long serialVersionUID = 5216202440370333534L;
public InterceptTaskException(String message) {
super(message);

View File

@ -17,10 +17,6 @@
package io.bitsquare.common.taskrunner;
import io.bitsquare.btc.exceptions.SigningException;
import io.bitsquare.btc.exceptions.TransactionVerificationException;
import io.bitsquare.btc.exceptions.WalletException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -49,7 +45,7 @@ public abstract class Task<T extends Model> {
}
}
abstract protected void doRun() throws WalletException, TransactionVerificationException, SigningException;
abstract protected void doRun();
private void interceptBeforeRun() {
if (getClass() == taskToInterceptBeforeRun)

View File

@ -21,6 +21,7 @@ import io.bitsquare.common.handlers.ErrorMessageHandler;
import io.bitsquare.common.handlers.ResultHandler;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
@ -45,8 +46,9 @@ public class TaskRunner<T extends Model> {
this.errorMessageHandler = errorMessageHandler;
}
public final void addTasks(Class<? extends Task>... items) {
tasks.addAll(Arrays.asList(items));
public final void addTasks(Class<? extends Task<? extends Model>>... items) {
List<Class<? extends Task<? extends Model>>> list = Arrays.asList(items);
tasks.addAll(list);
}
public void run() {

View File

@ -21,6 +21,8 @@ import static java.lang.String.format;
public class ViewfxException extends RuntimeException {
private static final long serialVersionUID = -6266047448442595372L;
public ViewfxException(Throwable cause, String format, Object... args) {
super(format(format, args), cause);
}

View File

@ -41,6 +41,6 @@ public @interface FxmlView {
*/
Class<? extends PathConvention> convention() default DefaultPathConvention.class;
static interface PathConvention extends Function<Class<? extends View>, String> {
interface PathConvention extends Function<Class<? extends View>, String> {
}
}

View File

@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class ViewPath extends ArrayList<Class<? extends View>> implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization.
@ -36,7 +37,8 @@ public class ViewPath extends ArrayList<Class<? extends View>> implements Serial
public static ViewPath to(Class<? extends View>... elements) {
ViewPath path = new ViewPath();
path.addAll(Arrays.asList(elements));
List<Class<? extends View>> list = Arrays.asList(elements);
path.addAll(list);
return path;
}

View File

@ -20,7 +20,7 @@ package io.bitsquare.common.viewfx.view;
public interface Wizard extends View {
void nextStep(Step currentStep);
public interface Step {
interface Step {
void hideWizardNavigation();
void setWizard(Wizard wizard);

View File

@ -73,7 +73,7 @@ public class EncryptionService<T> {
public T decryptToObject(PrivateKey privateKey, Bucket bucket) throws IllegalBlockSizeException, InvalidKeyException,
BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException {
return (T) Utilities.byteArrayToObject(decrypt(privateKey, bucket));
return Utilities.<T>byteArrayToObject(decrypt(privateKey, bucket));
}
public Bucket encrypt(PublicKey publicKey, byte[] payload) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,

View File

@ -24,6 +24,6 @@ public class HashService {
public Sha256Hash hash(String message) {
byte[] data = Utils.formatMessageForSigning(message);
return Sha256Hash.createDouble(data);
return Sha256Hash.hashTwice(data);
}
}

View File

@ -29,7 +29,7 @@ public class SignatureService {
public String signMessage(ECKey key, String message) {
byte[] data = Utils.formatMessageForSigning(message);
Sha256Hash hash = Sha256Hash.createDouble(data);
Sha256Hash hash = Sha256Hash.hashTwice(data);
return signMessage(key, hash);
}

View File

@ -74,6 +74,7 @@ public class Navigation implements Serializable {
currentPath = null;
}
@SuppressWarnings("unchecked")
public void navigateTo(Class<? extends View>... viewClasses) {
navigateTo(ViewPath.to(viewClasses));
}

View File

@ -54,9 +54,8 @@ public class SystemTray {
private final Runnable onExit;
private final MenuItem toggleShowHideItem = new MenuItem(HIDE_WINDOW_LABEL);
public static void create(Stage stage, Runnable onExit) {
systemTray = new SystemTray(stage, onExit);
systemTray = new SystemTray(stage, onExit);
}
public SystemTray(Stage stage, Runnable onExit) {

View File

@ -1,4 +1,5 @@
/* splash screen */
/*noinspection CssUnknownTarget*/
#image-splash-logo {
-fx-image: url("../../../images/logo_splash.png");
}

View File

@ -160,7 +160,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
});
// Delay a bit to give time for rendering the splash screen
Platform.runLater(() -> model.initBackend());
Platform.runLater(model::initBackend);
}
private void setupNotificationIcon(Pane portfolioButtonHolder) {

View File

@ -86,10 +86,10 @@ class MainViewModel implements ViewModel {
private final User user;
private final WalletService walletService;
private ArbitrationRepository arbitrationRepository;
private final ArbitrationRepository arbitrationRepository;
private final ClientNode clientNode;
private final TradeManager tradeManager;
private UpdateProcess updateProcess;
private final UpdateProcess updateProcess;
private final BSFormatter formatter;
@Inject
@ -123,7 +123,7 @@ class MainViewModel implements ViewModel {
}
public void initBackend() {
Platform.runLater(() -> updateProcess.init());
Platform.runLater(updateProcess::init);
setBitcoinNetworkSyncProgress(-1);
walletService.getDownloadProgress().subscribe(
@ -179,7 +179,7 @@ class MainViewModel implements ViewModel {
next -> {
},
error -> log.error(error.toString()),
() -> Platform.runLater(() -> onAllServicesInitialized())
() -> Platform.runLater(this::onAllServicesInitialized)
);
}

View File

@ -262,7 +262,7 @@ public class ArbitratorRegistrationView extends ActivatableView<AnchorPane, Void
() -> {
// log.debug("arbitrator added successfully " + arbitratorService.getAllArbitrators().size());
},
(errorMessage -> log.error(errorMessage)));
log::error);
}
@FXML
@ -284,9 +284,7 @@ public class ArbitratorRegistrationView extends ActivatableView<AnchorPane, Void
securityDepositAddressTextField.setText(securityDepositAddress);
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
copyIcon.setOnMouseClicked(e -> {
Utilities.copyToClipboard(securityDepositAddress);
});
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(securityDepositAddress));
paymentDoneButton.setDisable(walletService.getArbitratorDepositBalance().isZero());
log.debug("getArbitratorDepositBalance " + walletService.getArbitratorDepositBalance());

View File

@ -77,8 +77,7 @@ public class TransactionsView extends ActivatableViewAndModel {
@Override
public void doDeactivate() {
for (TransactionsListItem transactionsListItem : transactionsListItems)
transactionsListItem.cleanup();
transactionsListItems.forEach(TransactionsListItem::cleanup);
}
private void openTxDetails(TransactionsListItem item) {

View File

@ -116,8 +116,7 @@ public class WithdrawalView extends ActivatableViewAndModel {
@Override
public void doDeactivate() {
for (WithdrawalListItem item : addressList)
item.cleanup();
addressList.forEach(WithdrawalListItem::cleanup);
}
@FXML

View File

@ -47,13 +47,11 @@ public class PortfolioView extends ActivatableViewAndModel<TabPane, Activatable>
private final ViewLoader viewLoader;
private final Navigation navigation;
private final TradeManager tradeManager;
@Inject
public PortfolioView(CachingViewLoader viewLoader, Navigation navigation, TradeManager tradeManager) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.tradeManager = tradeManager;
}
@Override

View File

@ -226,6 +226,7 @@ class PendingTradesDataModel implements Activatable, DataModel {
public Coin getAmountToWithdraw() {
Trade trade = selectedItem.getTrade();
Coin amountToWithdraw = trade.getSecurityDeposit();
assert trade.getTradeAmount() != null;
if (trade instanceof OffererTrade)
amountToWithdraw = amountToWithdraw.add(trade.getTradeAmount());
return amountToWithdraw;

View File

@ -159,7 +159,7 @@ public class PendingTradesView extends ActivatableViewAndModel<AnchorPane, Pendi
// TODO Set focus to row does not work yet...
Platform.runLater(() -> table.requestFocus());
Platform.runLater(table::requestFocus);
table.getFocusModel().focus(model.selectedIndex.get());
txIdTextField.setup(model.getWalletService(), model.txId.get());
selectedIndexChangeListener.changed(null, null, model.selectedIndex.get());

View File

@ -182,6 +182,7 @@ class PendingTradesViewModel extends ActivatableWithDataModel<PendingTradesDataM
// payment
String getPaymentMethod() {
assert dataModel.getTrade().getContract() != null;
return BSResources.get(dataModel.getTrade().getContract().takerFiatAccount.type.toString());
}
@ -190,14 +191,17 @@ class PendingTradesViewModel extends ActivatableWithDataModel<PendingTradesDataM
}
String getHolderName() {
assert dataModel.getTrade().getContract() != null;
return dataModel.getTrade().getContract().takerFiatAccount.accountHolderName;
}
String getPrimaryId() {
assert dataModel.getTrade().getContract() != null;
return dataModel.getTrade().getContract().takerFiatAccount.accountPrimaryID;
}
String getSecondaryId() {
assert dataModel.getTrade().getContract() != null;
return dataModel.getTrade().getContract().takerFiatAccount.accountSecondaryID;
}

View File

@ -27,7 +27,6 @@ import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.main.MainView;
import io.bitsquare.gui.main.settings.application.PreferencesView;
import io.bitsquare.gui.main.settings.network.NetworkSettingsView;
import io.bitsquare.user.Preferences;
import javax.inject.Inject;
@ -40,7 +39,6 @@ public class SettingsView extends ActivatableViewAndModel<TabPane, Activatable>
@FXML Tab preferencesTab, networkSettingsTab;
private Preferences preferences;
private Navigation.Listener navigationListener;
private ChangeListener<Tab> tabChangeListener;
@ -48,10 +46,9 @@ public class SettingsView extends ActivatableViewAndModel<TabPane, Activatable>
private final Navigation navigation;
@Inject
public SettingsView(CachingViewLoader viewLoader, Navigation navigation, Preferences preferences) {
public SettingsView(CachingViewLoader viewLoader, Navigation navigation) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.preferences = preferences;
}
@Override

View File

@ -69,9 +69,8 @@ class CreateOfferDataModel implements Activatable, DataModel {
private final TradeManager tradeManager;
private final WalletService walletService;
private ArbitratorService arbitratorService;
private final AccountSettings accountSettings;
private Preferences preferences;
private final Preferences preferences;
private final BSFormatter formatter;
private final String offerId;
@ -111,7 +110,7 @@ class CreateOfferDataModel implements Activatable, DataModel {
AccountSettings accountSettings, Preferences preferences, User user, BSFormatter formatter) {
this.tradeManager = tradeManager;
this.walletService = walletService;
this.arbitratorService = arbitratorService;
ArbitratorService arbitratorService1 = arbitratorService;
this.accountSettings = accountSettings;
this.preferences = preferences;
this.formatter = formatter;
@ -151,8 +150,7 @@ class CreateOfferDataModel implements Activatable, DataModel {
// might be changed after screen change
if (accountSettings != null) {
// set it here again to cover the case of an securityDeposit change after a screen change
if (accountSettings != null)
securityDepositAsCoin.set(accountSettings.getSecurityDeposit());
securityDepositAsCoin.set(accountSettings.getSecurityDeposit());
acceptedCountries.setAll(accountSettings.getAcceptedCountries());
acceptedLanguageCodes.setAll(accountSettings.getAcceptedLanguageLocaleCodes());

View File

@ -125,7 +125,7 @@ class TakeOfferDataModel implements Activatable, DataModel {
}
void takeOffer(TakeOfferResultHandler handler) {
tradeManager.requestTakeOffer(amountAsCoin.get(), offer, (trade) -> handler.handleResult(trade));
tradeManager.requestTakeOffer(amountAsCoin.get(), offer, handler::handleResult);
}
void calculateVolume() {

View File

@ -47,7 +47,7 @@ import static javafx.beans.binding.Bindings.createStringBinding;
class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> implements ViewModel {
private static final Logger log = LoggerFactory.getLogger(TakeOfferViewModel.class);
public static enum State {
public enum State {
CHECK_AVAILABILITY,
AMOUNT_SCREEN,
PAYMENT_SCREEN,
@ -219,6 +219,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
break;
case DEPOSIT_PUBLISHED:
case DEPOSIT_CONFIRMED:
assert takerTrade.getDepositTx() != null;
transactionId.set(takerTrade.getDepositTx().getHashAsString());
applyTakeOfferRequestResult(true);
break;

View File

@ -73,7 +73,7 @@ public class BSFormatter {
// format is like: 1,00 never more then 2 decimals
private final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0).code(0, currencyCode);
private ArbitrationRepository arbitrationRepository;
private final ArbitrationRepository arbitrationRepository;
@Inject
@ -131,8 +131,7 @@ public class BSFormatter {
try {
return coinFormat.noCode().format(coin).toString();
} catch (Throwable t) {
if (coin != null)
log.warn("Exception at formatBtc: " + t.toString());
log.warn("Exception at formatBtc: " + t.toString());
return "";
}
}
@ -148,8 +147,7 @@ public class BSFormatter {
// pre and post fixing
return coinFormat.postfixCode().format(coin).toString();
} catch (Throwable t) {
if (coin != null)
log.warn("Exception at formatBtcWithCode: " + t.toString());
log.warn("Exception at formatBtcWithCode: " + t.toString());
return "";
}
}
@ -159,12 +157,11 @@ public class BSFormatter {
}
public Coin parseToCoin(String input) {
if (input != null) {
if (input != null && input.length() > 0) {
try {
return coinFormat.parse(cleanInput(input));
} catch (Throwable t) {
if (input != null && input.length() > 0)
log.warn("Exception at parseToBtc: " + t.toString());
log.warn("Exception at parseToBtc: " + t.toString());
return Coin.ZERO;
}
}
@ -217,8 +214,7 @@ public class BSFormatter {
try {
return fiatFormat.noCode().format(fiat).toString();
} catch (Throwable t) {
if (fiat != null)
log.warn("Exception at formatFiat: " + t.toString());
log.warn("Exception at formatFiat: " + t.toString());
return "";
}
}
@ -232,8 +228,7 @@ public class BSFormatter {
try {
return fiatFormat.postfixCode().format(fiat).toString();
} catch (Throwable t) {
if (fiat != null)
log.warn("Exception at formatFiatWithCode: " + t.toString());
log.warn("Exception at formatFiatWithCode: " + t.toString());
return "";
}
}
@ -243,12 +238,11 @@ public class BSFormatter {
}
public Fiat parseToFiat(String input) {
if (input != null) {
if (input != null && input.length() > 0) {
try {
return Fiat.parseFiat(currencyCode, cleanInput(input));
} catch (Exception e) {
if (input != null && input.length() > 0)
log.warn("Exception at parseToFiat: " + e.toString());
log.warn("Exception at parseToFiat: " + e.toString());
return Fiat.valueOf(currencyCode, 0);
}
@ -268,12 +262,11 @@ public class BSFormatter {
*/
public Fiat parseToFiatWith2Decimals(String input) {
if (input != null) {
if (input != null && input.length() > 0) {
try {
return parseToFiat(new BigDecimal(cleanInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
} catch (Throwable t) {
if (input != null && input.length() > 0)
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
return Fiat.valueOf(currencyCode, 0);
}
@ -317,7 +310,7 @@ public class BSFormatter {
}
public String arbitratorsToNames(List<Arbitrator> arbitrators) {
return arbitrators.stream().map(e -> e.getName()).collect(Collectors.joining(", "));
return arbitrators.stream().map(Arbitrator::getName).collect(Collectors.joining(", "));
}
public String arbitratorIdsToNames(List<String> ids) {
@ -325,7 +318,7 @@ public class BSFormatter {
}
public String languageCodesToString(List<String> languageLocales) {
return languageLocales.stream().map(e -> LanguageUtil.getDisplayName(e)).collect(Collectors.joining(", "));
return languageLocales.stream().map(LanguageUtil::getDisplayName).collect(Collectors.joining(", "));
}
public String arbitrationMethodsToString(List<Arbitrator.METHOD> methods) {

View File

@ -36,7 +36,7 @@ public class Transitions {
public final static int DEFAULT_DURATION = 400;
private Preferences preferences;
private final Preferences preferences;
private Timeline removeBlurTimeLine;
@Inject

View File

@ -44,6 +44,7 @@ public class Country implements Serializable {
Country country = (Country) o;
if (code != null ? !code.equals(country.code) : country.code != null) return false;
//noinspection SimplifiableIfStatement
if (name != null ? !name.equals(country.name) : country.name != null) return false;
return !(region != null ? !region.equals(country.region) : country.region != null);

View File

@ -26,7 +26,7 @@ import java.util.stream.Collectors;
public class CurrencyUtil {
public static List<String> getAllCurrencyCodes() {
return getAllCurrencies().stream().map(e -> e.getCurrencyCode()).collect(Collectors.toList());
return getAllCurrencies().stream().map(Currency::getCurrencyCode).collect(Collectors.toList());
}
public static String getDefaultCurrencyAsCode() {

View File

@ -33,7 +33,7 @@ public class LanguageUtil {
new Locale(locale.getLanguage(), "").getISO3Language()).collect(Collectors.toSet());
List<String> allLocaleCodes = new ArrayList<>();
allLocaleCodes.addAll(allLocaleCodesAsSet);
allLocaleCodes.sort((locale1, locale2) -> locale1.compareTo(locale2));
allLocaleCodes.sort(String::compareTo);
return allLocaleCodes;
}

View File

@ -41,6 +41,7 @@ public class Region implements Serializable {
Region region = (Region) o;
//noinspection SimplifiableIfStatement
if (code != null ? !code.equals(region.code) : region.code != null) return false;
return !(name != null ? !name.equals(region.name) : region.name != null);

View File

@ -133,7 +133,7 @@ public class Offer implements Serializable {
stateProperty = new SimpleObjectProperty<>(state);
}
public void validate() throws Exception {
public void validate() {
checkNotNull(getAcceptedCountries(), "AcceptedCountries is null");
checkNotNull(getAcceptedLanguageCodes(), "AcceptedLanguageLocales is null");
checkNotNull(getAmount(), "Amount is null");

View File

@ -86,7 +86,7 @@ public class OfferBook {
public void onOffersReceived(List<Offer> offers) {
//TODO use deltas instead replacing the whole list
offerBookListItems.clear();
offers.stream().forEach(e -> addOfferToOfferBookListItems(e));
offers.stream().forEach(OfferBook.this::addOfferToOfferBookListItems);
}
@Override

View File

@ -286,10 +286,10 @@ public class TomP2POfferBookService extends TomP2PDHTService implements OfferBoo
log.error("Get invalidationTimestamp from DHT failed. Data = " + data);
}
}
else if (futureGet.data() == null) {
/*else if (futureGet.data() == null) {
// OK as nothing is set at the moment
// log.trace("Get invalidationTimestamp from DHT returns null. That is ok for the startup.");
}
log.trace("Get invalidationTimestamp from DHT returns null. That is ok for the startup.");
}*/
else {
log.error("Get invalidationTimestamp from DHT failed with reason:" + futureGet.failedReason());
}

View File

@ -28,5 +28,5 @@ public interface ClientNode {
Node getBootstrapNodeAddress();
public Observable<BootstrapState> bootstrap(KeyPair keyPair);
Observable<BootstrapState> bootstrap(KeyPair keyPair);
}

View File

@ -31,7 +31,7 @@ public class EncryptedMailboxMessage implements MailboxMessage, Serializable {
private static final long serialVersionUID = -3111178895546299769L;
private static final Logger log = LoggerFactory.getLogger(EncryptedMailboxMessage.class);
private Bucket bucket;
private final Bucket bucket;
public EncryptedMailboxMessage(Bucket bucket) {
this.bucket = bucket;

View File

@ -22,6 +22,8 @@ import java.io.IOException;
@SuppressWarnings("serializable")
public class NetworkException extends IOException {
private static final long serialVersionUID = 3635593267998809977L;
public NetworkException(Throwable cause) {
super(cause);
}

View File

@ -78,7 +78,7 @@ public class BootstrappedPeerBuilder {
private KeyPair keyPair;
private final int port;
private boolean useManualPortForwarding;
private final boolean useManualPortForwarding;
private final Node bootstrapNode;
private final String networkInterface;

View File

@ -153,9 +153,7 @@ public class TomP2PMailboxService extends TomP2PDHTService implements MailboxSer
// it might change in future to something like foundAndRemoved and notFound
// See discussion at: https://github.com/tomp2p/TomP2P/issues/57#issuecomment-62069840
log.trace("isRemoved? " + futureRemove.isRemoved());
executor.execute(() -> {
resultHandler.handleResult();
});
executor.execute(resultHandler::handleResult);
}
@Override

View File

@ -27,7 +27,6 @@ import io.bitsquare.p2p.MessageHandler;
import io.bitsquare.p2p.MessageService;
import io.bitsquare.p2p.Peer;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.user.User;
import java.security.PublicKey;
@ -46,9 +45,8 @@ public class TomP2PMessageService extends TomP2PService implements MessageServic
private static final Logger log = LoggerFactory.getLogger(TomP2PMessageService.class);
private final CopyOnWriteArrayList<MessageHandler> messageHandlers = new CopyOnWriteArrayList<>();
private MailboxService mailboxService;
private User user;
private EncryptionService<MailboxMessage> encryptionService;
private final MailboxService mailboxService;
private final EncryptionService<MailboxMessage> encryptionService;
///////////////////////////////////////////////////////////////////////////////////////////
@ -56,10 +54,9 @@ public class TomP2PMessageService extends TomP2PService implements MessageServic
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public TomP2PMessageService(TomP2PNode tomP2PNode, MailboxService mailboxService, User user, EncryptionService<MailboxMessage> encryptionService) {
public TomP2PMessageService(TomP2PNode tomP2PNode, MailboxService mailboxService, EncryptionService<MailboxMessage> encryptionService) {
super(tomP2PNode);
this.mailboxService = mailboxService;
this.user = user;
this.encryptionService = encryptionService;
}

View File

@ -55,7 +55,7 @@ public class TomP2PNode implements ClientNode {
private PeerDHT peerDHT;
private BootstrappedPeerBuilder bootstrappedPeerBuilder;
private final Subject<BootstrapState, BootstrapState> bootstrapStateSubject;
private List<ResultHandler> resultHandlers = new CopyOnWriteArrayList<>();
private final List<ResultHandler> resultHandlers = new CopyOnWriteArrayList<>();
///////////////////////////////////////////////////////////////////////////////////////////
@ -94,7 +94,7 @@ public class TomP2PNode implements ClientNode {
public void onSuccess(@Nullable PeerDHT peerDHT) {
if (peerDHT != null) {
TomP2PNode.this.peerDHT = peerDHT;
resultHandlers.stream().forEach(e -> e.handleResult());
resultHandlers.stream().forEach(ResultHandler::handleResult);
bootstrapStateSubject.onCompleted();
}
else {

View File

@ -100,6 +100,7 @@ public class FileManager<T> {
.setNameFormat("FileManager thread")
.setPriority(Thread.MIN_PRIORITY); // Avoid competing with the GUI thread.
//noinspection Convert2Lambda
builder.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable throwable) {
@ -118,17 +119,14 @@ public class FileManager<T> {
this.delay = delay;
this.delayTimeUnit = checkNotNull(delayTimeUnit);
this.saver = new Callable<Void>() {
@Override
public Void call() throws Exception {
// Runs in an auto save thread.
if (!savePending.getAndSet(false)) {
// Some other scheduled request already beat us to it.
return null;
}
saveNowInternal(serializable);
this.saver = () -> {
// Runs in an auto save thread.
if (!savePending.getAndSet(false)) {
// Some other scheduled request already beat us to it.
return null;
}
saveNowInternal(serializable);
return null;
};
Runtime.getRuntime().addShutdownHook(new Thread() {
@ -165,11 +163,11 @@ public class FileManager<T> {
executor.schedule(saver, delay, delayTimeUnit);
}
public Object read(File file) throws IOException, ClassNotFoundException {
public T read(File file) throws IOException, ClassNotFoundException {
lock.lock();
try (final FileInputStream fileInputStream = new FileInputStream(file);
final ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
return objectInputStream.readObject();
return (T) objectInputStream.readObject();
} finally {
lock.unlock();
}
@ -213,7 +211,8 @@ public class FileManager<T> {
public void removeAndBackupFile(String fileName) throws IOException {
File corruptedBackupDir = new File(Paths.get(dir.getAbsolutePath(), "corrupted").toString());
if (!corruptedBackupDir.exists())
corruptedBackupDir.mkdir();
if (!corruptedBackupDir.mkdir())
log.warn("make dir failed");
File corruptedFile = new File(Paths.get(dir.getAbsolutePath(), "corrupted", fileName).toString());
renameTempFileToFile(storageFile, corruptedFile);
@ -222,7 +221,8 @@ public class FileManager<T> {
public void backupFile(String fileName) throws IOException {
File backupDir = new File(Paths.get(dir.getAbsolutePath(), "backup").toString());
if (!backupDir.exists())
backupDir.mkdir();
if (!backupDir.mkdir())
log.warn("make dir failed");
File backupFile = new File(Paths.get(dir.getAbsolutePath(), "backup", fileName).toString());
Files.copy(storageFile, backupFile);
@ -232,20 +232,21 @@ public class FileManager<T> {
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void saveNowInternal(T serializable) throws IOException {
private void saveNowInternal(T serializable) {
long now = System.currentTimeMillis();
saveToFile(serializable, dir, storageFile);
log.info("Save {} completed in {}msec", storageFile, System.currentTimeMillis() - now);
}
private void saveToFile(T serializable, File dir, File storageFile) throws IOException {
private void saveToFile(T serializable, File dir, File storageFile) {
lock.lock();
File tempFile = null;
FileOutputStream fileOutputStream = null;
ObjectOutputStream objectOutputStream = null;
try {
if (!dir.exists())
dir.mkdir();
if (!dir.mkdir())
log.warn("make dir failed");
tempFile = File.createTempFile("temp", null, dir);

View File

@ -111,7 +111,7 @@ public class Storage<T extends Serializable> {
if (storageFile.exists()) {
long now = System.currentTimeMillis();
try {
T persistedObject = (T) fileManager.read(storageFile);
T persistedObject = fileManager.read(storageFile);
log.info("Read {} completed in {}msec", serializable.getClass().getSimpleName(), System.currentTimeMillis() - now);
// If we did not get any exception we can be sure the data are consistent so we make a backup

View File

@ -41,6 +41,6 @@ class OffererTradeTask extends Task<OffererTrade> {
}
@Override
protected void doRun() throws WalletException, TransactionVerificationException, SigningException {
protected void doRun() {
}
}

View File

@ -41,6 +41,6 @@ class TakerTradeTask extends Task<TakerTrade> {
}
@Override
protected void doRun() throws WalletException, TransactionVerificationException, SigningException {
protected void doRun() {
}
}

View File

@ -40,7 +40,7 @@ public class AccountSettings implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L;
transient private Storage<AccountSettings> storage;
final transient private Storage<AccountSettings> storage;
// Persisted fields
private List<String> acceptedLanguageLocaleCodes = new ArrayList<>();
@ -119,7 +119,7 @@ public class AccountSettings implements Serializable {
}
public List<String> getAcceptedArbitratorIds() {
return acceptedArbitrators.stream().map(e -> e.getId()).collect(Collectors.toList());
return acceptedArbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList());
}
public List<String> getAcceptedLanguageLocaleCodes() {

View File

@ -57,7 +57,6 @@ public class User implements Serializable {
transient private static final Logger log = LoggerFactory.getLogger(User.class);
transient private Storage<User> storage;
transient private EncryptionService encryptionService;
// Persisted fields
private KeyPair p2pSigKeyPair;
@ -67,13 +66,13 @@ public class User implements Serializable {
private FiatAccount currentFiatAccount;
// Observable wrappers
transient private ObservableList<FiatAccount> fiatAccountsObservableList = FXCollections.observableArrayList(fiatAccounts);
transient private ObjectProperty<FiatAccount> currentFiatAccountProperty = new SimpleObjectProperty<>(currentFiatAccount);
final transient private ObservableList<FiatAccount> fiatAccountsObservableList = FXCollections.observableArrayList(fiatAccounts);
final transient private ObjectProperty<FiatAccount> currentFiatAccountProperty = new SimpleObjectProperty<>(currentFiatAccount);
@Inject
public User(Storage<User> storage, EncryptionService encryptionService) {
this.storage = storage;
this.encryptionService = encryptionService;
EncryptionService encryptionService1 = encryptionService;
User persisted = storage.initAndGetPersisted(this);
if (persisted != null) {

View File

@ -31,18 +31,10 @@ import org.slf4j.LoggerFactory;
public class DSAKeyUtil {
private static final Logger log = LoggerFactory.getLogger(DSAKeyUtil.class);
public static PublicKey decodePubKeyHex(String pubKeyHex) {
public static PublicKey decodePubKeyHex(String pubKeyHex) throws NoSuchAlgorithmException, InvalidKeySpecException {
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(Utils.HEX.decode(pubKeyHex));
try {
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
return keyFactory.generatePublic(pubKeySpec);
} catch (NoSuchAlgorithmException e) {
log.error("could not find algorithm", e);
return null;
} catch (InvalidKeySpecException e) {
log.error("wrong keyspec", e);
return null;
}
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
return keyFactory.generatePublic(pubKeySpec);
}
public static String encodePubKeyToHex(PublicKey pubKey) {

View File

@ -18,9 +18,8 @@ class DesktopUtil {
if (openSystemSpecific(uri.toString())) return true;
if (browseDESKTOP(uri)) return true;
return browseDESKTOP(uri);
return false;
}
@ -28,9 +27,8 @@ class DesktopUtil {
if (openSystemSpecific(file.getPath())) return true;
if (openDESKTOP(file)) return true;
return openDESKTOP(file);
return false;
}
@ -42,9 +40,8 @@ class DesktopUtil {
if (openSystemSpecific(file.getPath())) return true;
if (editDESKTOP(file)) return true;
return editDESKTOP(file);
return false;
}
@ -175,7 +172,7 @@ class DesktopUtil {
private static String[] prepareCommand(String command, String args, String file) {
List<String> parts = new ArrayList<String>();
List<String> parts = new ArrayList<>();
parts.add(command);
if (args != null) {
@ -202,7 +199,7 @@ class DesktopUtil {
System.out.println(msg);
}
public static enum EnumOS {
public enum EnumOS {
linux, macos, solaris, unknown, windows;
public boolean isLinux() {

View File

@ -152,7 +152,7 @@ public class Utilities {
return result;
}
public static Object byteArrayToObject(byte[] data) {
public static <T> T byteArrayToObject(byte[] data) {
ByteArrayInputStream bis = new ByteArrayInputStream(data);
ObjectInput in = null;
Object result = null;
@ -175,7 +175,7 @@ public class Utilities {
// ignore close exception
}
}
return result;
return (T) result;
}
public static byte[] objectToBytArray(Object object) {
@ -249,17 +249,16 @@ public class Utilities {
if (folder.isDirectory()) {
File[] list = folder.listFiles();
if (list != null) {
for (int i = 0; i < list.length; i++) {
File tmpF = list[i];
for (File tmpF : list) {
if (tmpF.isDirectory()) {
removeDirectory(tmpF);
}
tmpF.delete();
if (!tmpF.delete())
log.warn("can't delete file : " + tmpF);
}
}
if (!folder.delete()) {
if (!folder.delete())
log.warn("can't delete folder : " + folder);
}
}
}

View File

@ -17,9 +17,9 @@
package io.bitsquare.util.spring;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import joptsimple.OptionSet;
@ -38,10 +38,8 @@ public class JOptCommandLinePropertySource extends org.springframework.core.env.
@Override
public List<String> getOptionValues(String name) {
List<?> argValues = this.source.valuesOf(name);
List<String> stringArgValues = new ArrayList<>();
for (Object argValue : argValues) {
stringArgValues.add(argValue instanceof String ? (String) argValue : argValue.toString());
}
List<String> stringArgValues = argValues.stream().map(argValue -> argValue instanceof String ? (String) argValue : argValue.toString()).collect
(Collectors.toList());
if (stringArgValues.isEmpty()) {
return (this.source.has(name) ? Collections.<String>emptyList() : null);
}

View File

@ -121,7 +121,7 @@ takeOffer.advancedBox.txType=Payments method:
takeOffer.advancedBox.currency=Currency:
takeOffer.advancedBox.county=Payments account country:
takeOffer.advancedBox.info=These are the offer restrictions your trading partner has defined in his offer. Your \
settings are matching those constraints and you are able to trade with him.
settings are matching those constraints and you are able to trade with him.
takeOffer.success.headline=Your have successfully published the deposit.
takeOffer.success.info=You need to wait now for the Bitcoin buyer to transfer the money to you. \nYou will get a \