Skip to content

Commit 6ec8696

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.core.databinding.observable
1 parent 0f5ed45 commit 6ec8696

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+294
-173
lines changed

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/ChangeManager.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ protected void removeListener(Object listenerType,
9191
}
9292

9393
protected boolean hasListeners() {
94-
if (listenerTypes != null)
95-
for (int i = 0; i < listenerTypes.length; i++)
96-
if (listenerTypes[i] != DisposeEvent.TYPE)
97-
if (listenerLists[i].size() > 0)
94+
if (listenerTypes != null) {
95+
for (int i = 0; i < listenerTypes.length; i++) {
96+
if (listenerTypes[i] != DisposeEvent.TYPE) {
97+
if (listenerLists[i].size() > 0) {
9898
return true;
99+
}
100+
}
101+
}
102+
}
99103
return false;
100104
}
101105

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/DecoratingObservable.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DecoratingObservable extends AbstractObservable implements
3232

3333
private IStaleListener staleListener;
3434

35-
private boolean disposedDecoratedOnDispose;
35+
private final boolean disposedDecoratedOnDispose;
3636

3737
/**
3838
* Constructs a DecoratingObservable which decorates the given observable.
@@ -97,10 +97,12 @@ protected void handleStaleEvent(StaleEvent event) {
9797

9898
@Override
9999
public boolean equals(Object obj) {
100-
if (obj == this)
100+
if (obj == this) {
101101
return true;
102-
if (obj == null)
102+
}
103+
if (obj == null) {
103104
return false;
105+
}
104106
if (getClass() == obj.getClass()) {
105107
DecoratingObservable other = (DecoratingObservable) obj;
106108
return Objects.equals(this.decorated, other.decorated);
@@ -119,8 +121,9 @@ public synchronized void dispose() {
119121
decorated.removeStaleListener(staleListener);
120122
}
121123
if (decorated != null) {
122-
if (disposedDecoratedOnDispose)
124+
if (disposedDecoratedOnDispose) {
123125
decorated.dispose();
126+
}
124127
decorated = null;
125128
}
126129
staleListener = null;

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/Diffs.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
public class Diffs {
4040
private static final class UnmodifiableListDiff<E> extends ListDiff<E> {
41-
private ListDiff<? extends E> toWrap;
41+
private final ListDiff<? extends E> toWrap;
4242

4343
public UnmodifiableListDiff(ListDiff<? extends E> diff) {
4444
this.toWrap = diff;
@@ -56,7 +56,7 @@ public ListDiffEntry<E>[] getDifferences() {
5656
}
5757

5858
private static final class UnmodifiableSetDiff<E> extends SetDiff<E> {
59-
private SetDiff<? extends E> toWrap;
59+
private final SetDiff<? extends E> toWrap;
6060

6161
public UnmodifiableSetDiff(SetDiff<? extends E> diff) {
6262
toWrap = diff;
@@ -74,7 +74,7 @@ public Set<E> getRemovals() {
7474
}
7575

7676
private static final class UnmodifiableMapDiff<K, V> extends MapDiff<K, V> {
77-
private MapDiff<? extends K, ? extends V> toWrap;
77+
private final MapDiff<? extends K, ? extends V> toWrap;
7878

7979
public UnmodifiableMapDiff(MapDiff<? extends K, ? extends V> diff) {
8080
toWrap = diff;
@@ -107,7 +107,7 @@ public V getNewValue(Object key) {
107107
}
108108

109109
private static final class UnmodifiableValueDiff<E> extends ValueDiff<E> {
110-
private ValueDiff<? extends E> toWrap;
110+
private final ValueDiff<? extends E> toWrap;
111111

112112
public UnmodifiableValueDiff(ValueDiff<? extends E> diff) {
113113
toWrap = diff;

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/ObservableTracker.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ public static void setIgnore(boolean ignore) {
198198
int newCount = (lastCount == null ? 0 : lastCount.intValue())
199199
+ (ignore ? 1 : -1);
200200

201-
if (newCount < 0)
201+
if (newCount < 0) {
202202
throw new IllegalStateException("Ignore count is already zero"); //$NON-NLS-1$
203+
}
203204

204205
if (newCount == 0) {
205206
currentIgnoreCount.remove();
@@ -250,26 +251,31 @@ private static boolean isIgnore() {
250251
* @param observable the observable whose getter was called
251252
*/
252253
public static void getterCalled(IObservable observable) {
253-
if (observable.isDisposed())
254+
if (observable.isDisposed()) {
254255
Assert.isTrue(false, "Getter called on disposed observable " //$NON-NLS-1$
255256
+ toString(observable));
257+
}
256258
Realm realm = observable.getRealm();
257-
if (!realm.isCurrent())
259+
if (!realm.isCurrent()) {
258260
Assert.isTrue(false, "Getter called outside realm of observable " //$NON-NLS-1$
259261
+ toString(observable));
262+
}
260263

261-
if (isIgnore())
264+
if (isIgnore()) {
262265
return;
266+
}
263267

264268
Set<IObservable> getterCalledSet = currentGetterCalledSet.get();
265269
if (getterCalledSet != null && getterCalledSet.add(observable)) {
266270
// If anyone is listening for observable usage...
267271
IChangeListener changeListener = currentChangeListener.get();
268-
if (changeListener != null)
272+
if (changeListener != null) {
269273
observable.addChangeListener(changeListener);
274+
}
270275
IStaleListener staleListener = currentStaleListener.get();
271-
if (staleListener != null)
276+
if (staleListener != null) {
272277
observable.addStaleListener(staleListener);
278+
}
273279
}
274280
}
275281

@@ -281,8 +287,9 @@ public static void getterCalled(IObservable observable) {
281287
* @since 1.2
282288
*/
283289
public static void observableCreated(IObservable observable) {
284-
if (isIgnore())
290+
if (isIgnore()) {
285291
return;
292+
}
286293
Set<IObservable> observableCreatedSet = currentObservableCreatedSet.get();
287294
if (observableCreatedSet != null) {
288295
observableCreatedSet.add(observable);

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/Observables.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,9 @@ public static <K, V> IObservableValue<V> observeMapEntry(
704704
*/
705705
public static <K, V> IObservableValue<V> observeMapEntry(
706706
IObservableMap<K, V> map, K key, Object valueType) {
707-
if (valueType == null)
707+
if (valueType == null) {
708708
valueType = map.getValueType();
709+
}
709710
return new MapEntryObservableValue<>(map, key, valueType);
710711
}
711712

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/Realm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ protected void syncExec(Runnable runnable) {
305305
static class SyncRunnable implements Runnable {
306306
boolean hasRun = false;
307307

308-
private Runnable runnable;
308+
private final Runnable runnable;
309309

310310
SyncRunnable(Runnable runnable) {
311311
this.runnable = runnable;

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,14 @@ public boolean add(E o) {
314314
public E move(int oldIndex, int newIndex) {
315315
checkRealm();
316316
int size = doGetSize();
317-
if (oldIndex < 0 || oldIndex >= size)
317+
if (oldIndex < 0 || oldIndex >= size) {
318318
throw new IndexOutOfBoundsException(
319319
"oldIndex: " + oldIndex + ", size:" + size); //$NON-NLS-1$ //$NON-NLS-2$
320-
if (newIndex < 0 || newIndex >= size)
320+
}
321+
if (newIndex < 0 || newIndex >= size) {
321322
throw new IndexOutOfBoundsException(
322323
"newIndex: " + newIndex + ", size:" + size); //$NON-NLS-1$ //$NON-NLS-2$
324+
}
323325
E element = remove(oldIndex);
324326
add(newIndex, element);
325327
return element;

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/list/ComputedList.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,16 @@ private class PrivateInterface implements Runnable, IChangeListener,
183183
@Override
184184
public void run() {
185185
cachedList = calculate();
186-
if (cachedList == null)
186+
if (cachedList == null) {
187187
cachedList = Collections.EMPTY_LIST;
188+
}
188189
}
189190

190191
@Override
191192
public void handleStale(StaleEvent event) {
192-
if (!dirty)
193+
if (!dirty) {
193194
makeStale();
195+
}
194196
}
195197

196198
@Override
@@ -199,7 +201,7 @@ public void handleChange(ChangeEvent event) {
199201
}
200202
}
201203

202-
private PrivateInterface privateInterface = new PrivateInterface();
204+
private final PrivateInterface privateInterface = new PrivateInterface();
203205

204206
private Object elementType;
205207

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/list/ListChangeEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class ListChangeEvent<E> extends ObservableEvent {
4444
* Always identical to <code>EventObject.source</code> but the type
4545
* information is maintained.
4646
*/
47-
private IObservableList<E> typedSource;
47+
private final IObservableList<E> typedSource;
4848

4949
/**
5050
* Creates a new list change event.

bundles/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/list/ListDiff.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ public void accept(ListDiffVisitor<? super E> visitor) {
146146
}
147147
}
148148

149-
if (add)
149+
if (add) {
150150
visitor.handleAdd(pos, elem);
151-
else
151+
} else {
152152
visitor.handleRemove(pos, elem);
153+
}
153154
}
154155
}
155156

@@ -309,8 +310,9 @@ public String toString() {
309310
buffer.append("{"); //$NON-NLS-1$
310311

311312
for (int i = 0; i < differences.length; i++) {
312-
if (i > 0)
313+
if (i > 0) {
313314
buffer.append(", "); //$NON-NLS-1$
315+
}
314316

315317
buffer.append("difference[") //$NON-NLS-1$
316318
.append(i)

0 commit comments

Comments
 (0)