Skip to content

Commit 23e2bda

Browse files
eclipse-pde-botlaeubi
authored andcommitted
Perform clean code of ui/org.eclipse.pde.bnd.ui
1 parent 3d67780 commit 23e2bda

13 files changed

+150
-99
lines changed

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/resolution/CapReqComparator.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,38 @@ public class CapReqComparator implements Comparator<Object> {
2929

3030
@Override
3131
public int compare(Object o1, Object o2) {
32-
if (o1 instanceof Requirement)
32+
if (o1 instanceof Requirement) {
3333
return compareReqToObj((Requirement) o1, o2);
34+
}
3435

35-
if (o1 instanceof RequirementWrapper)
36+
if (o1 instanceof RequirementWrapper) {
3637
return compareReqToObj(((RequirementWrapper) o1).requirement, o2);
38+
}
3739

38-
if (o1 instanceof Capability)
40+
if (o1 instanceof Capability) {
3941
return compareCapToObj((Capability) o1, o2);
42+
}
4043

4144
return 0;
4245
}
4346

4447
private int compareReqToObj(Requirement r1, Object o2) {
45-
if (o2 instanceof Requirement)
48+
if (o2 instanceof Requirement) {
4649
return compareReqToReq(r1, (Requirement) o2);
50+
}
4751

48-
if (o2 instanceof RequirementWrapper)
52+
if (o2 instanceof RequirementWrapper) {
4953
return compareReqToReq(r1, ((RequirementWrapper) o2).requirement);
54+
}
5055

5156
// requirements sort before other things
5257
return -1;
5358
}
5459

5560
private int compareCapToObj(Capability c1, Object o2) {
56-
if (o2 instanceof Capability)
61+
if (o2 instanceof Capability) {
5762
return compareCapToCap(c1, (Capability) o2);
63+
}
5864

5965
// capabilities sort after other things
6066
return 1;
@@ -65,8 +71,9 @@ private int compareCapToCap(Capability c1, Capability c2) {
6571
String ns1 = c1.getNamespace();
6672
String ns2 = c2.getNamespace();
6773
int nsDiff = ns1.compareTo(ns2);
68-
if (nsDiff != 0)
74+
if (nsDiff != 0) {
6975
return nsDiff;
76+
}
7077

7178
// Compare the main attribute
7279
String attribName = R5LabelFormatter.getMainAttributeName(ns1);
@@ -78,14 +85,16 @@ private int compareCapToCap(Capability c1, Capability c2) {
7885
if (attrib1 != null && attrib2 != null) {
7986
int attribDiff = attrib1.toString()
8087
.compareTo(attrib2.toString());
81-
if (attribDiff != 0)
88+
if (attribDiff != 0) {
8289
return attribDiff;
90+
}
8391
}
8492

8593
// Compare the versions
8694
String versionAttribName = R5LabelFormatter.getVersionAttributeName(ns1);
87-
if (versionAttribName == null)
95+
if (versionAttribName == null) {
8896
return 0;
97+
}
8998

9099
Version v1 = highestVersion(c1.getAttributes().get(versionAttribName));
91100
Version v2 = highestVersion(c2.getAttributes().get(versionAttribName));

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/resolution/CapReqMapContentProvider.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ public Object[] getElements(Object input) {
7474
for (Entry<String, List<Object>> entry : map.entrySet()) {
7575
// Skip if namespace is a member of the namespaces we have already
7676
// added.
77-
if (NAMESPACES.contains(entry.getKey()))
77+
if (NAMESPACES.contains(entry.getKey())) {
7878
continue;
79+
}
7980

8081
List<Object> listForNs = entry.getValue();
8182
Object[] array = listForNs.toArray();
@@ -112,8 +113,7 @@ public Object getParent(Object object) {
112113
public boolean hasChildren(Object object) {
113114
boolean children = false;
114115

115-
if (object instanceof RequirementWrapper) {
116-
RequirementWrapper rw = (RequirementWrapper) object;
116+
if (object instanceof RequirementWrapper rw) {
117117
children = rw.requirers != null && !rw.requirers.isEmpty();
118118
}
119119

@@ -125,18 +125,20 @@ public Object[] getChildren(Object parent) {
125125
Object[] result = EMPTY;
126126
if (parent instanceof RequirementWrapper) {
127127
Collection<? extends Object> requirers = ((RequirementWrapper) parent).requirers;
128-
if (requirers != null)
128+
if (requirers != null) {
129129
result = requirers.toArray();
130+
}
130131
}
131132
return result;
132133
}
133134

134135
public void setFilter(String filterString) {
135136
if (filterString == null || filterString.length() == 0 || filterString.trim()
136-
.equals("*"))
137+
.equals("*")) {
137138
wildcardFilter = null;
138-
else
139+
} else {
139140
wildcardFilter = "*" + filterString.trim() + "*";
141+
}
140142

141143
}
142144

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/resolution/CapabilityLabelProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,20 @@ static String tooltipText(Capability cap) {
8989
}
9090

9191
for (Entry<String, Object> attribute : cap.getAttributes()
92-
.entrySet())
92+
.entrySet()) {
9393
buf.append(";\n\t")
9494
.append(attribute.getKey())
9595
.append(" = ")
9696
.append(attribute.getValue());
97+
}
9798

9899
for (Entry<String, String> directive : cap.getDirectives()
99-
.entrySet())
100+
.entrySet()) {
100101
buf.append(";\n\t")
101102
.append(directive.getKey())
102103
.append(" := ")
103104
.append(directive.getValue());
105+
}
104106

105107
return buf.toString();
106108
}

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/resolution/RequirementWrapper.java

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

5454
@Override
5555
public boolean equals(Object obj) {
56-
if (this == obj)
56+
if (this == obj) {
5757
return true;
58-
if (obj == null)
58+
}
59+
if (obj == null) {
5960
return false;
60-
if (getClass() != obj.getClass())
61+
}
62+
if (getClass() != obj.getClass()) {
6163
return false;
64+
}
6265
RequirementWrapper other = (RequirementWrapper) obj;
6366
return java == other.java && Objects.equals(requirement, other.requirement)
6467
&& Objects.equals(requirers, other.requirers) && resolved == other.resolved;

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/resolution/RequirementWrapperLabelProvider.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ public RequirementWrapperLabelProvider(boolean shortenNamespaces) {
4343
@Override
4444
public void update(ViewerCell cell) {
4545
Object element = cell.getElement();
46-
if (element instanceof RequirementWrapper) {
47-
RequirementWrapper rw = (RequirementWrapper) element;
48-
46+
if (element instanceof RequirementWrapper rw) {
4947
Image icon = Resources.getImage(R5LabelFormatter.getNamespaceImagePath(rw.requirement.getNamespace()));
5048
cell.setImage(icon);
5149

5250
StyledString label = getLabel(rw.requirement);
53-
if (rw.resolved || rw.java)
51+
if (rw.resolved || rw.java) {
5452
label.setStyle(0, label.length(), resolved);
53+
}
5554

5655
cell.setText(label.getString());
5756
cell.setStyleRanges(label.getStyleRanges());
@@ -93,10 +92,12 @@ static String tooltipText(RequirementWrapper rw) {
9392
Requirement req = rw.requirement;
9493

9594
StringBuilder buf = new StringBuilder(300);
96-
if (rw.resolved)
95+
if (rw.resolved) {
9796
buf.append("RESOLVED:\n");
98-
if (rw.java)
97+
}
98+
if (rw.java) {
9999
buf.append("JAVA:\n");
100+
}
100101

101102
Resource r = req.getResource();
102103

@@ -117,18 +118,20 @@ static String tooltipText(RequirementWrapper rw) {
117118
buf.append(req.getNamespace());
118119

119120
for (Entry<String, Object> attr : req.getAttributes()
120-
.entrySet())
121+
.entrySet()) {
121122
buf.append(";\n\t")
122123
.append(attr.getKey())
123124
.append(" = ")
124125
.append(attr.getValue());
126+
}
125127

126128
for (Entry<String, String> directive : req.getDirectives()
127-
.entrySet())
129+
.entrySet()) {
128130
buf.append(";\n\t")
129131
.append(directive.getKey())
130132
.append(" := ")
131133
.append(directive.getValue());
134+
}
132135

133136
return buf.toString();
134137
}

0 commit comments

Comments
 (0)