Replace anonymous classes with lambda expressions

This commit is contained in:
Thibault Meyer
2016-11-06 11:17:53 +01:00
parent da30df3b2b
commit 6680e2ea75
21 changed files with 177 additions and 303 deletions
@@ -98,11 +98,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
protected void loadLargeAllocation(final int allocateSize) {
// preAllocateIds was called with a relatively large batchSize
// so we will just go ahead and load those anyway in background
backgroundExecutor.execute(new Runnable() {
public void run() {
loadMoreIds(allocateSize, null);
}
});
backgroundExecutor.execute(() -> loadMoreIds(allocateSize, null));
}
/**
@@ -145,12 +141,10 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
currentlyBackgroundLoading = batchSize;
backgroundExecutor.execute(new Runnable() {
public void run() {
loadMoreIds(batchSize, null);
synchronized (backgroundLoadMonitor) {
currentlyBackgroundLoading = 0;
}
backgroundExecutor.execute(() -> {
loadMoreIds(batchSize, null);
synchronized (backgroundLoadMonitor) {
currentlyBackgroundLoading = 0;
}
});
}
@@ -42,12 +42,7 @@ public class MigrationModel {
private void readMigrations() {
// find all the migration xml files
File[] xmlFiles = modelDirectory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().toLowerCase().endsWith(modelSuffix);
}
});
File[] xmlFiles = modelDirectory.listFiles(pathname -> pathname.getName().toLowerCase().endsWith(modelSuffix));
List<MigrationResource> resources = new ArrayList<>();
@@ -974,12 +974,9 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
prop.docStoreMapping(mapping, prefix);
}
if (inheritInfo != null) {
inheritInfo.visitChildren(new InheritInfoVisitor() {
@Override
public void visit(InheritInfo inheritInfo) {
for (BeanProperty localProperty : inheritInfo.localProperties()) {
localProperty.docStoreMapping(mapping, prefix);
}
inheritInfo.visitChildren(inheritInfo1 -> {
for (BeanProperty localProperty : inheritInfo1.localProperties()) {
localProperty.docStoreMapping(mapping, prefix);
}
});
}
@@ -94,15 +94,12 @@ public class InheritInfo {
*/
public void appendCheckConstraintValues(final String propertyName, final Set<String> checkConstraintValues) {
visitChildren(new InheritInfoVisitor() {
@Override
public void visit(InheritInfo inheritInfo) {
BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName);
if (prop != null) {
Set<String> values = prop.getDbCheckConstraintValues();
if (values != null) {
checkConstraintValues.addAll(values);
}
visitChildren(inheritInfo -> {
BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName);
if (prop != null) {
Set<String> values = prop.getDbCheckConstraintValues();
if (values != null) {
checkConstraintValues.addAll(values);
}
}
});
@@ -152,13 +152,11 @@ public final class PostCommitProcessing {
* In background notify persist listeners, cluster and document store.
*/
Runnable backgroundNotify() {
return new Runnable() {
public void run() {
processCacheChanges(cacheChanges);
localPersistListenersNotify();
notifyCluster();
processDocStoreUpdates();
}
return () -> {
processCacheChanges(cacheChanges);
localPersistListenersNotify();
notifyCluster();
processDocStoreUpdates();
};
}
@@ -422,12 +422,7 @@ public class TransactionManager {
if (changeLogPrepare.prepare(changeSet)) {
// call the log method in background
backgroundExecutor.execute(new Runnable() {
@Override
public void run() {
changeLogListener.log(changeSet);
}
});
backgroundExecutor.execute(() -> changeLogListener.log(changeSet));
}
}
@@ -262,12 +262,9 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
InheritInfo inheritInfo = desc.getInheritInfo();
if (inheritInfo != null) {
inheritInfo.visitChildren(new InheritInfoVisitor() {
@Override
public void visit(InheritInfo inheritInfo) {
for (BeanProperty localProperty : inheritInfo.localProperties()) {
localProperty.docStoreInclude(includeByDefault, docStructure);
}
inheritInfo.visitChildren(inheritInfo1 -> {
for (BeanProperty localProperty : inheritInfo1.localProperties()) {
localProperty.docStoreInclude(includeByDefault, docStructure);
}
});
}