Skip to content

Commit db0d051

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

23 files changed

+106
-57
lines changed

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/typed/BeanProperties.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ public static <S, T> IBeanValueProperty<S, T> value(Class<S> beanClass, String p
111111
@SuppressWarnings("unchecked")
112112
public static <S, T> IBeanValueProperty<S, T> value(Class<S> beanClass, String propertyName, Class<T> valueType) {
113113
String[] propertyNames = split(propertyName);
114-
if (propertyNames.length > 1)
114+
if (propertyNames.length > 1) {
115115
valueType = null;
116+
}
116117

117118
PropertyDescriptor propertyDescriptor;
118119
IValueProperty<S, T> property;
@@ -132,8 +133,9 @@ public static <S, T> IBeanValueProperty<S, T> value(Class<S> beanClass, String p
132133
}
133134

134135
private static String[] split(String propertyName) {
135-
if (propertyName.indexOf('.') == -1)
136+
if (propertyName.indexOf('.') == -1) {
136137
return new String[] { propertyName };
138+
}
137139
List<String> propertyNames = new ArrayList<>();
138140
int index;
139141
while ((index = propertyName.indexOf('.')) != -1) {
@@ -158,8 +160,9 @@ private static String[] split(String propertyName) {
158160
public static <S, T> IBeanValueProperty<S, T>[] values(Class<S> beanClass, String... propertyNames) {
159161
@SuppressWarnings("unchecked")
160162
IBeanValueProperty<S, T>[] properties = new IBeanValueProperty[propertyNames.length];
161-
for (int i = 0; i < properties.length; i++)
163+
for (int i = 0; i < properties.length; i++) {
162164
properties[i] = value(beanClass, propertyNames[i], null);
165+
}
163166
return properties;
164167
}
165168

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/typed/PojoProperties.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ public static <S, E> IBeanValueProperty<S, E> value(Class<S> beanClass, String p
112112
@SuppressWarnings("unchecked")
113113
public static <S, T> IBeanValueProperty<S, T> value(Class<S> beanClass, String propertyName, Class<T> valueType) {
114114
String[] propertyNames = split(propertyName);
115-
if (propertyNames.length > 1)
115+
if (propertyNames.length > 1) {
116116
valueType = null;
117+
}
117118

118119
IValueProperty<S, T> property;
119120
PropertyDescriptor propertyDescriptor;
@@ -134,8 +135,9 @@ public static <S, T> IBeanValueProperty<S, T> value(Class<S> beanClass, String p
134135
}
135136

136137
private static String[] split(String propertyName) {
137-
if (propertyName.indexOf('.') == -1)
138+
if (propertyName.indexOf('.') == -1) {
138139
return new String[] { propertyName };
140+
}
139141
List<String> propertyNames = new ArrayList<>();
140142
int index;
141143
while ((index = propertyName.indexOf('.')) != -1) {
@@ -161,8 +163,9 @@ public static <S, T> IBeanValueProperty<S, T>[] values(Class<S> beanClass,
161163
String... propertyNames) {
162164
@SuppressWarnings("unchecked")
163165
IBeanValueProperty<S, T>[] properties = (IBeanValueProperty<S, T>[]) new IBeanValueProperty<?, ?>[propertyNames.length];
164-
for (int i = 0; i < properties.length; i++)
166+
for (int i = 0; i < properties.length; i++) {
165167
properties[i] = value(beanClass, propertyNames[i], null);
168+
}
166169
return properties;
167170
}
168171

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousBeanListProperty.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class AnonymousBeanListProperty<S, E> extends DelegatingListProperty<S, E> {
3131
private final String propertyName;
3232

33-
private Map<Class<S>, IListProperty<S, E>> delegates;
33+
private final Map<Class<S>, IListProperty<S, E>> delegates;
3434

3535
public AnonymousBeanListProperty(String propertyName, Class<E> elementType) {
3636
super(elementType);
@@ -42,8 +42,9 @@ public AnonymousBeanListProperty(String propertyName, Class<E> elementType) {
4242
@Override
4343
protected IListProperty<S, E> doGetDelegate(S source) {
4444
Class<S> beanClass = (Class<S>) source.getClass();
45-
if (delegates.containsKey(beanClass))
45+
if (delegates.containsKey(beanClass)) {
4646
return delegates.get(beanClass);
47+
}
4748

4849
IListProperty<S, E> delegate;
4950
try {
@@ -59,8 +60,9 @@ protected IListProperty<S, E> doGetDelegate(S source) {
5960
public String toString() {
6061
String s = "?." + propertyName + "[]"; //$NON-NLS-1$ //$NON-NLS-2$
6162
Class<?> elementType = (Class<?>) getElementType();
62-
if (elementType != null)
63+
if (elementType != null) {
6364
s += "<" + BeanPropertyHelper.shortClassName(elementType) + ">"; //$NON-NLS-1$//$NON-NLS-2$
65+
}
6466
return s;
6567
}
6668
}

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousBeanMapProperty.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class AnonymousBeanMapProperty<S, K, V> extends DelegatingMapProperty<S, K, V> {
3434
private final String propertyName;
3535

36-
private Map<Class<S>, IMapProperty<S, K, V>> delegates;
36+
private final Map<Class<S>, IMapProperty<S, K, V>> delegates;
3737

3838
/**
3939
* @param propertyName property name
@@ -49,8 +49,9 @@ public AnonymousBeanMapProperty(String propertyName, Class<?> keyType, Class<?>
4949
@Override
5050
protected IMapProperty<S, K, V> doGetDelegate(S source) {
5151
Class<S> beanClass = (Class<S>) source.getClass();
52-
if (delegates.containsKey(beanClass))
52+
if (delegates.containsKey(beanClass)) {
5353
return delegates.get(beanClass);
54+
}
5455

5556
IMapProperty<S, K, V> delegate;
5657
try {

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousBeanSetProperty.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class AnonymousBeanSetProperty<S, E> extends DelegatingSetProperty<S, E> {
3131
private final String propertyName;
3232

33-
private Map<Class<S>, ISetProperty<S, E>> delegates;
33+
private final Map<Class<S>, ISetProperty<S, E>> delegates;
3434

3535
/**
3636
* @param propertyName property name
@@ -46,8 +46,9 @@ public AnonymousBeanSetProperty(String propertyName, Class<E> elementType) {
4646
@Override
4747
protected ISetProperty<S, E> doGetDelegate(Object source) {
4848
Class<S> beanClass = (Class<S>) source.getClass();
49-
if (delegates.containsKey(beanClass))
49+
if (delegates.containsKey(beanClass)) {
5050
return delegates.get(beanClass);
51+
}
5152

5253
ISetProperty<S, E> delegate;
5354
try {
@@ -63,8 +64,9 @@ protected ISetProperty<S, E> doGetDelegate(Object source) {
6364
public String toString() {
6465
String s = "?." + propertyName + "{}"; //$NON-NLS-1$ //$NON-NLS-2$
6566
Class<?> elementType = (Class<?>) getElementType();
66-
if (elementType != null)
67+
if (elementType != null) {
6768
s += "<" + BeanPropertyHelper.shortClassName(elementType) + ">"; //$NON-NLS-1$//$NON-NLS-2$
69+
}
6870
return s;
6971
}
7072
}

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousBeanValueProperty.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class AnonymousBeanValueProperty<S, T> extends DelegatingValueProperty<S, T> {
3434
private final String propertyName;
3535

36-
private Map<Class<S>, IValueProperty<S, T>> delegates;
36+
private final Map<Class<S>, IValueProperty<S, T>> delegates;
3737

3838
/**
3939
* @param propertyName property name
@@ -53,8 +53,9 @@ protected IValueProperty<S, T> doGetDelegate(S source) {
5353

5454
@SuppressWarnings("unchecked")
5555
private IValueProperty<S, T> getClassDelegate(Class<S> beanClass) {
56-
if (delegates.containsKey(beanClass))
56+
if (delegates.containsKey(beanClass)) {
5757
return delegates.get(beanClass);
58+
}
5859

5960
IValueProperty<S, T> delegate;
6061
try {
@@ -69,8 +70,9 @@ private IValueProperty<S, T> getClassDelegate(Class<S> beanClass) {
6970
@Override
7071
public <M extends S> IObservableValue<T> observeDetail(IObservableValue<M> master) {
7172
Object valueType = getValueType();
72-
if (valueType == null)
73+
if (valueType == null) {
7374
valueType = inferValueType(master.getValueType());
75+
}
7476
return MasterDetailObservables.detailValue(master, valueFactory(master
7577
.getRealm()), valueType);
7678
}
@@ -88,8 +90,9 @@ private Object inferValueType(Object masterObservableValueType) {
8890
public String toString() {
8991
String s = "?." + propertyName; //$NON-NLS-1$
9092
Class<?> valueType = (Class<?>) getValueType();
91-
if (valueType != null)
93+
if (valueType != null) {
9294
s += "<" + BeanPropertyHelper.shortClassName(valueType) + ">"; //$NON-NLS-1$//$NON-NLS-2$
95+
}
9396
return s;
9497
}
9598
}

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousPojoListProperty.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class AnonymousPojoListProperty<S, E> extends DelegatingListProperty<S, E> {
3232
private final String propertyName;
3333

34-
private Map<Class<S>, IListProperty<S, E>> delegates;
34+
private final Map<Class<S>, IListProperty<S, E>> delegates;
3535

3636
/**
3737
* @param propertyName property name
@@ -47,8 +47,9 @@ public AnonymousPojoListProperty(String propertyName, Class<E> elementType) {
4747
@Override
4848
protected IListProperty<S, E> doGetDelegate(S source) {
4949
Class<S> beanClass = (Class<S>) source.getClass();
50-
if (delegates.containsKey(beanClass))
50+
if (delegates.containsKey(beanClass)) {
5151
return delegates.get(beanClass);
52+
}
5253

5354
IListProperty<S, E> delegate;
5455
try {
@@ -64,8 +65,9 @@ protected IListProperty<S, E> doGetDelegate(S source) {
6465
public String toString() {
6566
String s = "?." + propertyName + "{}"; //$NON-NLS-1$ //$NON-NLS-2$
6667
Class<?> elementType = (Class<?>) getElementType();
67-
if (elementType != null)
68+
if (elementType != null) {
6869
s += "<" + BeanPropertyHelper.shortClassName(elementType) + ">"; //$NON-NLS-1$//$NON-NLS-2$
70+
}
6971
return s;
7072
}
7173
}

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousPojoMapProperty.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public class AnonymousPojoMapProperty<S, K, V> extends DelegatingMapProperty<S, K, V> {
3333
private final String propertyName;
3434

35-
private Map<Class<S>, IMapProperty<S, K, V>> delegates;
35+
private final Map<Class<S>, IMapProperty<S, K, V>> delegates;
3636

3737
/**
3838
* @param propertyName property name
@@ -49,8 +49,9 @@ public AnonymousPojoMapProperty(String propertyName, Class<K> keyType, Class<V>
4949
@Override
5050
protected IMapProperty<S, K, V> doGetDelegate(S source) {
5151
Class<S> beanClass = (Class<S>) source.getClass();
52-
if (delegates.containsKey(beanClass))
52+
if (delegates.containsKey(beanClass)) {
5353
return delegates.get(beanClass);
54+
}
5455

5556
IMapProperty<S, K, V> delegate;
5657
try {

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousPojoSetProperty.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class AnonymousPojoSetProperty<S, E> extends DelegatingSetProperty<S, E> {
3232
private final String propertyName;
3333

34-
private Map<Class<S>, ISetProperty<S, E>> delegates;
34+
private final Map<Class<S>, ISetProperty<S, E>> delegates;
3535

3636
/**
3737
* @param propertyName property name
@@ -47,8 +47,9 @@ public AnonymousPojoSetProperty(String propertyName, Class<E> elementType) {
4747
@Override
4848
protected ISetProperty<S, E> doGetDelegate(S source) {
4949
Class<S> beanClass = (Class<S>) source.getClass();
50-
if (delegates.containsKey(beanClass))
50+
if (delegates.containsKey(beanClass)) {
5151
return delegates.get(beanClass);
52+
}
5253

5354
ISetProperty<S, E> delegate;
5455
try {
@@ -64,8 +65,9 @@ protected ISetProperty<S, E> doGetDelegate(S source) {
6465
public String toString() {
6566
String s = "?." + propertyName + "{}"; //$NON-NLS-1$ //$NON-NLS-2$
6667
Class<?> elementType = (Class<?>) getElementType();
67-
if (elementType != null)
68+
if (elementType != null) {
6869
s += "<" + BeanPropertyHelper.shortClassName(elementType) + ">"; //$NON-NLS-1$//$NON-NLS-2$
70+
}
6971
return s;
7072
}
7173
}

bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/AnonymousPojoValueProperty.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class AnonymousPojoValueProperty<S, T> extends DelegatingValueProperty<S, T> {
3434
private final String propertyName;
3535

36-
private Map<Class<S>, IValueProperty<S, T>> delegates;
36+
private final Map<Class<S>, IValueProperty<S, T>> delegates;
3737

3838
/**
3939
* @param propertyName property name
@@ -53,8 +53,9 @@ protected IValueProperty<S, T> doGetDelegate(S source) {
5353

5454
@SuppressWarnings("unchecked")
5555
private IValueProperty<S, T> getClassDelegate(Class<S> pojoClass) {
56-
if (delegates.containsKey(pojoClass))
56+
if (delegates.containsKey(pojoClass)) {
5757
return delegates.get(pojoClass);
58+
}
5859

5960
IValueProperty<S, T> delegate;
6061
try {
@@ -69,8 +70,9 @@ private IValueProperty<S, T> getClassDelegate(Class<S> pojoClass) {
6970
@Override
7071
public <M extends S> IObservableValue<T> observeDetail(IObservableValue<M> master) {
7172
Object valueType = getValueType();
72-
if (valueType == null)
73+
if (valueType == null) {
7374
valueType = inferValueType(master.getValueType());
75+
}
7476
return MasterDetailObservables.detailValue(master, valueFactory(master
7577
.getRealm()), valueType);
7678
}
@@ -88,8 +90,9 @@ private Object inferValueType(Object masterObservableValueType) {
8890
public String toString() {
8991
String s = "?." + propertyName; //$NON-NLS-1$
9092
Class<?> valueType = (Class<?>) getValueType();
91-
if (valueType != null)
93+
if (valueType != null) {
9294
s += "<" + BeanPropertyHelper.shortClassName(valueType) + ">"; //$NON-NLS-1$//$NON-NLS-2$
95+
}
9396
return s;
9497
}
9598
}

0 commit comments

Comments
 (0)