Cleanup and fix some warnings.
This commit is contained in:
@@ -11,11 +11,12 @@ public class Changeable {
|
||||
|
||||
private static final ExecutorService changeExecutor = Executors.newSingleThreadExecutor();
|
||||
|
||||
private boolean changed;
|
||||
private Grouping grouping = Grouping.APPLY;
|
||||
private final Object mutex = new Object();
|
||||
private Grouping grouping = Grouping.APPLY;
|
||||
private boolean changed;
|
||||
|
||||
void setChanged() {
|
||||
synchronized (changeExecutor) {
|
||||
synchronized (mutex) {
|
||||
if (changed)
|
||||
return;
|
||||
|
||||
@@ -23,36 +24,36 @@ public class Changeable {
|
||||
changed = true;
|
||||
if (grouping != Grouping.APPLY)
|
||||
return;
|
||||
|
||||
changeExecutor.submit( () -> {
|
||||
synchronized (changeExecutor) {
|
||||
if (grouping != Grouping.APPLY)
|
||||
return;
|
||||
changed = false;
|
||||
}
|
||||
|
||||
onChanged();
|
||||
} );
|
||||
}
|
||||
|
||||
changeExecutor.submit( () -> {
|
||||
synchronized (changeExecutor) {
|
||||
if (grouping != Grouping.APPLY)
|
||||
return;
|
||||
changed = false;
|
||||
}
|
||||
|
||||
onChanged();
|
||||
} );
|
||||
}
|
||||
|
||||
protected void onChanged() {
|
||||
}
|
||||
|
||||
public void beginChanges() {
|
||||
synchronized (changeExecutor) {
|
||||
synchronized (mutex) {
|
||||
grouping = Grouping.BATCH;
|
||||
}
|
||||
}
|
||||
|
||||
public void ignoreChanges() {
|
||||
synchronized (changeExecutor) {
|
||||
synchronized (mutex) {
|
||||
grouping = Grouping.IGNORE;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean endChanges() {
|
||||
synchronized (changeExecutor) {
|
||||
synchronized (mutex) {
|
||||
grouping = Grouping.APPLY;
|
||||
|
||||
if (changed) {
|
||||
|
@@ -159,7 +159,7 @@ public class MPFileSite extends MPBasicSite<MPFileQuestion> {
|
||||
|
||||
@Override
|
||||
public int compareTo(final MPSite<?> o) {
|
||||
int comparison = (o instanceof MPFileSite)? -getLastUsed().compareTo( ((MPFileSite) o).getLastUsed() ): 0;
|
||||
int comparison = (o instanceof MPFileSite)? ((MPFileSite) o).getLastUsed().compareTo( getLastUsed() ): 0;
|
||||
if (comparison != 0)
|
||||
return comparison;
|
||||
|
||||
|
@@ -171,7 +171,7 @@ public class MPFileUser extends MPBasicUser<MPFileSite> {
|
||||
|
||||
@Override
|
||||
public int compareTo(final MPUser<?> o) {
|
||||
int comparison = (o instanceof MPFileUser)? -getLastUsed().compareTo( ((MPFileUser) o).getLastUsed() ): 0;
|
||||
int comparison = (o instanceof MPFileUser)? ((MPFileUser) o).getLastUsed().compareTo( getLastUsed() ): 0;
|
||||
if (comparison != 0)
|
||||
return comparison;
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package com.lyndir.masterpassword.model.impl;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -41,6 +42,7 @@ class MPJSONAnyObject {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "ChainOfInstanceofChecks", "Contract" })
|
||||
@SuppressFBWarnings({"EQ_UNUSUAL","EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", "HE_EQUALS_USE_HASHCODE"})
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj instanceof Collection<?>)
|
||||
return ((Collection<?>) obj).isEmpty();
|
||||
|
@@ -82,8 +82,7 @@ public class MPJSONFile extends MPJSONAnyObject {
|
||||
user.default_type = modelUser.getDefaultType();
|
||||
|
||||
// Section "sites"
|
||||
if (sites == null)
|
||||
sites = new LinkedHashMap<>();
|
||||
sites = new LinkedHashMap<>();
|
||||
for (final MPFileSite modelSite : modelUser.getSites()) {
|
||||
String content = null, loginContent = null;
|
||||
|
||||
|
Reference in New Issue
Block a user