Skip to content

Commit 8932451

Browse files
committed
Take into account Sonar comments
1 parent 27dd767 commit 8932451

79 files changed

Lines changed: 524 additions & 622 deletions

File tree

Some content is hidden

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

org.restlet/src/main/java/org/restlet/Request.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ public boolean isAsynchronous() {
590590
*/
591591
@Override
592592
public boolean isConfidential() {
593-
return (getProtocol() == null) ? false : getProtocol().isConfidential();
593+
return getProtocol() != null && getProtocol().isConfidential();
594594
}
595595

596596
/**

org.restlet/src/main/java/org/restlet/data/AuthenticationInfo.java

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
package org.restlet.data;
1010

11+
import java.util.Objects;
1112
import org.restlet.engine.util.SystemUtils;
1213

1314
/**
@@ -38,15 +39,6 @@ public class AuthenticationInfo {
3839
/** The optional response digest for mutual authentication. */
3940
private volatile String responseDigest;
4041

41-
/**
42-
* Default constructor.
43-
*
44-
* @param nextNonce The next nonce value.
45-
*/
46-
// public AuthenticationInfo(String nextNonce) {
47-
// this(nextNonce, 0, );
48-
// }
49-
5042
/**
5143
* Constructor.
5244
*
@@ -72,51 +64,30 @@ public AuthenticationInfo(
7264
/** {@inheritDoc} */
7365
@Override
7466
public final boolean equals(final Object obj) {
75-
boolean result = (obj == this);
76-
77-
// if obj == this no need to go further
78-
if (!result) {
79-
// if obj isn't a challenge request or is null don't evaluate
80-
// further
81-
if (obj instanceof AuthenticationInfo) {
82-
final AuthenticationInfo that = (AuthenticationInfo) obj;
83-
if (getNextServerNonce() != null) {
84-
result = getNextServerNonce().equals(that.getNextServerNonce());
85-
} else {
86-
result = (that.getNextServerNonce() == null);
87-
}
88-
89-
if (result) {
90-
result = (getNonceCount() == that.getNonceCount());
91-
}
92-
93-
if (result) {
94-
if (getClientNonce() != null) {
95-
result = getClientNonce().equals(that.getClientNonce());
96-
} else {
97-
result = (that.getClientNonce() == null);
98-
}
99-
}
100-
101-
if (result) {
102-
if (getQuality() != null) {
103-
result = getQuality().equals(that.getQuality());
104-
} else {
105-
result = (that.getQuality() == null);
106-
}
107-
}
108-
109-
if (result) {
110-
if (getResponseDigest() != null) {
111-
result = getResponseDigest().equals(that.getResponseDigest());
112-
} else {
113-
result = (that.getResponseDigest() == null);
114-
}
115-
}
67+
if (obj == this) {
68+
return true;
69+
}
70+
if (obj == null) {
71+
return false;
72+
}
73+
74+
if (obj instanceof final AuthenticationInfo that) {
75+
if (!Objects.equals(getNextServerNonce(), that.getNextServerNonce())) {
76+
return false;
77+
}
78+
if (getNonceCount() != that.getNonceCount()) {
79+
return false;
80+
}
81+
if (!Objects.equals(getClientNonce(), that.getClientNonce())) {
82+
return false;
83+
}
84+
if (!Objects.equals(getQuality(), that.getQuality())) {
85+
return false;
11686
}
87+
return Objects.equals(getResponseDigest(), that.getResponseDigest());
11788
}
11889

119-
return result;
90+
return false;
12091
}
12192

12293
/**

org.restlet/src/main/java/org/restlet/data/ChallengeMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public String getOpaque() {
158158
*/
159159
public Series<Parameter> getParameters() {
160160
if (this.parameters == null) {
161-
this.parameters = new Series<Parameter>(Parameter.class);
161+
this.parameters = new Series<>(Parameter.class);
162162
}
163163

164164
return this.parameters;

org.restlet/src/main/java/org/restlet/data/ChallengeRequest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public List<Reference> getDomainRefs() {
8383
synchronized (this) {
8484
r = this.domainRefs;
8585
if (r == null) {
86-
this.domainRefs = r = new CopyOnWriteArrayList<Reference>();
86+
this.domainRefs = r = new CopyOnWriteArrayList<>();
8787
this.domainRefs.add(new Reference("/"));
8888
}
8989
}
@@ -104,7 +104,7 @@ public List<String> getQualityOptions() {
104104
synchronized (this) {
105105
r = this.qualityOptions;
106106
if (r == null) {
107-
this.qualityOptions = r = new CopyOnWriteArrayList<String>();
107+
this.qualityOptions = r = new CopyOnWriteArrayList<>();
108108
this.qualityOptions.add(QUALITY_AUTHENTICATION);
109109
}
110110
}
@@ -143,17 +143,17 @@ public void setDomainRefs(List<Reference> domainRefs) {
143143
* @see #setDomainRefs(List)
144144
*/
145145
public void setDomainUris(Collection<String> domainUris) {
146-
List<Reference> domainRefs = null;
146+
List<Reference> newDomainRefs = null;
147147

148148
if (domainUris != null) {
149-
domainRefs = new CopyOnWriteArrayList<Reference>();
149+
newDomainRefs = new CopyOnWriteArrayList<>();
150150

151151
for (String domainUri : domainUris) {
152-
domainRefs.add(new Reference(domainUri));
152+
newDomainRefs.add(new Reference(domainUri));
153153
}
154154
}
155155

156-
setDomainRefs(domainRefs);
156+
setDomainRefs(newDomainRefs);
157157
}
158158

159159
/**

org.restlet/src/main/java/org/restlet/data/CharacterSet.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ public CharacterSet(String name, String description) {
249249
/** {@inheritDoc} */
250250
@Override
251251
public boolean equals(Object object) {
252-
return (object instanceof CharacterSet)
253-
&& getName().equalsIgnoreCase(((CharacterSet) object).getName());
252+
if (object instanceof CharacterSet characterSet) {
253+
return getName().equalsIgnoreCase(characterSet.getName());
254+
}
255+
return false;
254256
}
255257

256258
@Override

0 commit comments

Comments
 (0)