Skip to content

Commit 2233169

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.e4.ui.css.core
1 parent 2aedf1f commit 2233169

22 files changed

+68
-56
lines changed

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2ColorHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ public static RGBColor getRGBColor(String value) {
7777
* @return string representation of rgbColor
7878
*/
7979
public static String getColorStringValue(RGBColor rgbColor, ICSSValueConverterConfig config) {
80-
if (config instanceof ICSSValueConverterColorConfig) {
81-
ICSSValueConverterColorConfig colorConfig = (ICSSValueConverterColorConfig) config;
80+
if (config instanceof ICSSValueConverterColorConfig colorConfig) {
8281
switch (colorConfig.getFormat()) {
8382
case ICSSValueConverterColorConfig.COLOR_HEXA_FORMAT:
8483
return getHexaColorStringValue(rgbColor);

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2PrimitiveValueImpl.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public Counter getCounterValue() throws DOMException {
5858

5959
@Override
6060
public float getFloatValue(short word0) throws DOMException {
61-
if (v != -9999)
61+
if (v != -9999) {
6262
return v;
63+
}
6364
return i;
6465
}
6566

@@ -116,12 +117,15 @@ public void setCssText(String s) throws DOMException {
116117

117118
@Override
118119
public String toString() {
119-
if (s != null)
120+
if (s != null) {
120121
return s;
121-
if (v != -9999)
122+
}
123+
if (v != -9999) {
122124
return Float.toString(v);
123-
if (i != -9999)
125+
}
126+
if (i != -9999) {
124127
return Integer.toString(i);
128+
}
125129
return super.toString();
126130
}
127131
}

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/AbstractCSSValueConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
public abstract class AbstractCSSValueConverter implements ICSSValueConverter {
2525

26-
private Object toType;
26+
private final Object toType;
2727

2828
public AbstractCSSValueConverter(Object toType) {
2929
this.toType = toType;

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/CSSValueBooleanConverterImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,20 @@ public Object convert(CSSValue value, CSSEngine engine, Object context)
4040
throws Exception {
4141
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
4242
CSSPrimitiveValue primitiveValue = (CSSPrimitiveValue) value;
43-
if ("true".equals(primitiveValue.getStringValue()))
43+
if ("true".equals(primitiveValue.getStringValue())) {
4444
return Boolean.TRUE;
45+
}
4546
}
4647
return Boolean.FALSE;
4748
}
4849

4950
@Override
5051
public String convert(Object value, CSSEngine engine, Object context,
5152
ICSSValueConverterConfig config) throws Exception {
52-
if (value instanceof Boolean) {
53-
Boolean b = (Boolean) value;
54-
if (b.booleanValue())
53+
if (value instanceof Boolean b) {
54+
if (b.booleanValue()) {
5555
return "true";
56+
}
5657
}
5758
return "false";
5859
}

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/CSSValueConverterConfigColorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class CSSValueConverterConfigColorImpl implements
3131
public static final ICSSValueConverterConfig COLOR_RGB_FORMAT_CONFIG = new CSSValueConverterConfigColorImpl(
3232
COLOR_RGB_FORMAT);
3333

34-
private int format;
34+
private final int format;
3535

3636
public CSSValueConverterConfigColorImpl(int format) {
3737
this.format = format;

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/css2/AbstractCSSPropertyBackgroundCompositeHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ public boolean isCSSPropertyComposite(String property) {
5959

6060
@Override
6161
public String[] getCSSPropertiesNames(String property) {
62-
if ("background".equals(property))
62+
if ("background".equals(property)) {
6363
return BACKROUND_CSSPROPERTIES;
64+
}
6465
return null;
6566
}
6667
}

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/css2/AbstractCSSPropertyBorderCompositeHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ public boolean isCSSPropertyComposite(String property) {
6969

7070
@Override
7171
public String[] getCSSPropertiesNames(String property) {
72-
if ("border".equals(property))
72+
if ("border".equals(property)) {
7373
return BORDER_CSSPROPERTIES;
74+
}
7475
return null;
7576
}
7677

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/css2/AbstractCSSPropertyFontCompositeHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public boolean isCSSPropertyComposite(String property) {
5252

5353
@Override
5454
public String[] getCSSPropertiesNames(String property) {
55-
if ("font".equals(property))
55+
if ("font".equals(property)) {
5656
return FONT_CSSPROPERTIES;
57+
}
5758
return null;
5859
}
5960
}

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/providers/AbstractCSSPropertyHandlerProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public CSSStyleDeclaration getDefaultCSSStyleDeclaration(CSSEngine engine,
3131
throws Exception {
3232
Element elt = engine.getElement(widget);
3333
if (elt != null) {
34-
if (elt instanceof CSSStylableElement) {
35-
CSSStylableElement stylableElement = (CSSStylableElement) elt;
34+
if (elt instanceof CSSStylableElement stylableElement) {
3635
return getDefaultCSSStyleDeclaration(engine, stylableElement,
3736
newStyle, pseudoE);
3837
}

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/providers/CSSPropertyHandlerSimpleProviderImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ public static void registerDefaultCSSProperty(String propertyName,
227227
* Merge custom CSS Properties with default CSS properties.
228228
*/
229229
private void initializeCSSPropertiesIfNeed() {
230-
if (isCSSPropertiesInitialized)
230+
if (isCSSPropertiesInitialized) {
231231
return;
232+
}
232233
customCSSProperties.putAll(defaultCSSProperties);
233234
isCSSPropertiesInitialized = true;
234235
}
@@ -244,10 +245,11 @@ public CSSStyleDeclaration getDefaultCSSStyleDeclaration(CSSEngine engine,
244245
String pseudoE) throws Exception {
245246
CSSStyleDeclaration defaultStyleDeclaration = stylableElement
246247
.getDefaultStyleDeclaration(pseudoE);
247-
if (defaultStyleDeclaration != null)
248+
if (defaultStyleDeclaration != null) {
248249
// default style is already computed for the stylable element ,
249250
// return it.
250251
return defaultStyleDeclaration;
252+
}
251253

252254
// Default style must be computed.
253255
StringBuilder style = null;
@@ -256,8 +258,9 @@ public CSSStyleDeclaration getDefaultCSSStyleDeclaration(CSSEngine engine,
256258
String s = getCSSPropertyStyle(engine, stylableElement,
257259
propertyName, pseudoE);
258260
if (s != null) {
259-
if (style == null)
261+
if (style == null) {
260262
style = new StringBuilder();
263+
}
261264
style.append(s);
262265
}
263266
}

0 commit comments

Comments
 (0)