Skip to content

Commit f6d5cc9

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.core.databinding
1 parent ccafe58 commit f6d5cc9

29 files changed

+147
-105
lines changed

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/AggregateValidationStatus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public final class AggregateValidationStatus extends ComputedValue<IStatus> {
5959
*/
6060
public static final int MAX_SEVERITY = 2;
6161

62-
private int strategy;
63-
private IObservableCollection<? extends ValidationStatusProvider> validationStatusProviders;
62+
private final int strategy;
63+
private final IObservableCollection<? extends ValidationStatusProvider> validationStatusProviders;
6464

6565
/**
6666
* Creates a new aggregate validation status observable for the given data

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/Binding.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ public Binding(IObservable target, IObservable model) {
6060
*/
6161
public final void init(DataBindingContext context) {
6262
this.context = context;
63-
if (target.isDisposed())
63+
if (target.isDisposed()) {
6464
throw new IllegalArgumentException("Target observable is disposed"); //$NON-NLS-1$
65-
if (model.isDisposed())
65+
}
66+
if (model.isDisposed()) {
6667
throw new IllegalArgumentException("Model observable is disposed"); //$NON-NLS-1$
68+
}
6769
this.disposeListener = event -> {
6870
if (context != null) {
6971
context.getValidationRealm().exec(Binding.this::dispose);

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/DataBindingContext.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class DataBindingContext {
107107

108108
private IObservableMap<Binding, IStatus> validationStatusMap;
109109

110-
private Realm validationRealm;
110+
private final Realm validationRealm;
111111

112112
/**
113113
* Creates a data binding context, using the current default realm for the
@@ -358,12 +358,14 @@ public final <T, M> Binding bindSet(
358358
IObservableSet<M> modelObservableSet,
359359
UpdateSetStrategy<? super T, ? extends M> targetToModel,
360360
UpdateSetStrategy<? super M, ? extends T> modelToTarget) {
361-
if (targetToModel == null)
361+
if (targetToModel == null) {
362362
targetToModel = createTargetToModelUpdateSetStrategy(
363363
targetObservableSet, modelObservableSet);
364-
if (modelToTarget == null)
364+
}
365+
if (modelToTarget == null) {
365366
modelToTarget = createModelToTargetUpdateSetStrategy(
366367
modelObservableSet, targetObservableSet);
368+
}
367369
targetToModel.fillDefaults(targetObservableSet, modelObservableSet);
368370
modelToTarget.fillDefaults(modelObservableSet, targetObservableSet);
369371
SetBinding<? super M, ? extends T> result = new SetBinding<>(targetObservableSet,

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/ObservablesManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
*/
3636
public class ObservablesManager {
3737

38-
private Set<IObservable> managedObservables = new IdentitySet<>();
39-
private Set<IObservable> excludedObservables = new IdentitySet<>();
40-
private Map<DataBindingContext, ManagerEntry> contexts = new HashMap<>();
38+
private final Set<IObservable> managedObservables = new IdentitySet<>();
39+
private final Set<IObservable> excludedObservables = new IdentitySet<>();
40+
private final Map<DataBindingContext, ManagerEntry> contexts = new HashMap<>();
4141

4242
/**
4343
* Create a new observables manager.

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,23 @@
8282
private static Map<Pair, Object> converterMap;
8383

8484
private static Class<?> autoboxed(Class<?> clazz) {
85-
if (clazz == Float.TYPE)
85+
if (clazz == Float.TYPE) {
8686
return Float.class;
87-
else if (clazz == Double.TYPE)
87+
} else if (clazz == Double.TYPE) {
8888
return Double.class;
89-
else if (clazz == Short.TYPE)
89+
} else if (clazz == Short.TYPE) {
9090
return Short.class;
91-
else if (clazz == Integer.TYPE)
91+
} else if (clazz == Integer.TYPE) {
9292
return Integer.class;
93-
else if (clazz == Long.TYPE)
93+
} else if (clazz == Long.TYPE) {
9494
return Long.class;
95-
else if (clazz == Byte.TYPE)
95+
} else if (clazz == Byte.TYPE) {
9696
return Byte.class;
97-
else if (clazz == Boolean.TYPE)
97+
} else if (clazz == Boolean.TYPE) {
9898
return Boolean.class;
99-
else if (clazz == Character.TYPE)
99+
} else if (clazz == Character.TYPE) {
100100
return Character.class;
101+
}
101102
return clazz;
102103
}
103104

@@ -154,8 +155,7 @@ final protected void checkAssignable(Object toType, Object fromType,
154155
Object converterOrClassname = converterMap.get(key);
155156
if (converterOrClassname instanceof IConverter) {
156157
return (IConverter<?, ?>) converterOrClassname;
157-
} else if (converterOrClassname instanceof String) {
158-
String classname = (String) converterOrClassname;
158+
} else if (converterOrClassname instanceof String classname) {
159159
Class<?> converterClass;
160160
try {
161161
converterClass = Class.forName(classname);

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateValueStrategy.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ protected IStatus doSet(IObservableValue<? super D> observableValue, D value) {
487487

488488
private static class ValidatorRegistry {
489489

490-
private Map<Pair, IValidator<?>> validators = new HashMap<>();
490+
private final Map<Pair, IValidator<?>> validators = new HashMap<>();
491491

492492
/**
493493
* Adds the system-provided validators to the current validator
@@ -553,8 +553,9 @@ private void associate(Object fromClass, Object toClass, IValidator<?> validator
553553
*/
554554
private IValidator<?> get(Object fromClass, Object toClass) {
555555
IValidator<?> result = validators.get(new Pair(fromClass, toClass));
556-
if (result != null)
556+
if (result != null) {
557557
return result;
558+
}
558559
if (fromClass != null && toClass != null && fromClass == toClass) {
559560
return value -> Status.OK_STATUS;
560561
}

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/conversion/Converter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
*/
2929
public abstract class Converter<F, T> implements IConverter<F, T> {
3030

31-
private Object fromType;
32-
private Object toType;
31+
private final Object fromType;
32+
private final Object toType;
3333

3434
/**
3535
* @param fromType type of source values

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/validation/MultiValidator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void handleStale(StaleEvent staleEvent) {
160160
}
161161
}
162162

163-
private DependencyListener dependencyListener = new DependencyListener();
163+
private final DependencyListener dependencyListener = new DependencyListener();
164164

165165
/**
166166
* Constructs a MultiValidator on the default realm.
@@ -247,8 +247,9 @@ class ValidationRunnable implements Runnable {
247247
public void run() {
248248
try {
249249
validationResult = validate();
250-
if (validationResult == null)
250+
if (validationResult == null) {
251251
validationResult = ValidationStatus.ok();
252+
}
252253
} catch (RuntimeException e) {
253254
// Usually an NPE as dependencies are init'ed
254255
validationResult = ValidationStatus

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/validation/ValidationStatus.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,15 @@ public int hashCode() {
122122
*/
123123
@Override
124124
public boolean equals(Object obj) {
125-
if (this == obj)
125+
if (this == obj) {
126126
return true;
127-
if (obj == null)
127+
}
128+
if (obj == null) {
128129
return false;
129-
if (getClass() != obj.getClass())
130+
}
131+
if (getClass() != obj.getClass()) {
130132
return false;
133+
}
131134
final ValidationStatus other = (ValidationStatus) obj;
132135

133136
return getSeverity() == other.getSeverity() && Objects.equals(getMessage(), other.getMessage())

bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/BindingStatus.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@ public int hashCode() {
8484

8585
@Override
8686
public boolean equals(Object obj) {
87-
if (this == obj)
87+
if (this == obj) {
8888
return true;
89-
if (obj == null)
89+
}
90+
if (obj == null) {
9091
return false;
91-
if (getClass() != obj.getClass())
92+
}
93+
if (getClass() != obj.getClass()) {
9294
return false;
95+
}
9396
final BindingStatus other = (BindingStatus) obj;
9497
return Arrays.equals(getChildren(), other.getChildren());
9598
}

0 commit comments

Comments
 (0)