[cleanup] erefactor/EclipseJdt - Invert equals arguments if parameter is constant string

EclipseJdt cleanup 'InvertEquals' applied by erefactor.

For EclipseJdt see https://www.eclipse.org/eclipse/news/4.19/jdt.php
For erefactor see https://github.com/cal101/erefactor
This commit is contained in:
cal101 2021-06-06 13:37:57 +00:00
parent c402d7cbc2
commit 86caedac50
8 changed files with 18 additions and 18 deletions

View File

@ -273,19 +273,19 @@ public class BeanDesc implements Serializable {
if (fieldName.startsWith("is")) { if (fieldName.startsWith("is")) {
// 字段已经是is开头 // 字段已经是is开头
if (methodName.equals(fieldName) // isName - isName if (methodName.equals(fieldName) // isName - isName
|| methodName.equals("get" + handledFieldName)// isName - getIsName || ("get" + handledFieldName).equals(methodName)// isName - getIsName
|| methodName.equals("is" + handledFieldName)// isName - isIsName || ("is" + handledFieldName).equals(methodName)// isName - isIsName
) { ) {
return true; return true;
} }
} else if (methodName.equals("is" + handledFieldName)) { } else if (("is" + handledFieldName).equals(methodName)) {
// 字段非is开头 name - isName // 字段非is开头 name - isName
return true; return true;
} }
} }
// 包括boolean的任何类型只有一种匹配情况name - getName // 包括boolean的任何类型只有一种匹配情况name - getName
return methodName.equals("get" + handledFieldName); return ("get" + handledFieldName).equals(methodName);
} }
/** /**
@ -324,15 +324,15 @@ public class BeanDesc implements Serializable {
// 针对Boolean类型特殊检查 // 针对Boolean类型特殊检查
if (isBooleanField && fieldName.startsWith("is")) { if (isBooleanField && fieldName.startsWith("is")) {
// 字段是is开头 // 字段是is开头
if (methodName.equals("set" + StrUtil.removePrefix(fieldName, "is"))// isName - setName if (("set" + StrUtil.removePrefix(fieldName, "is")).equals(methodName)// isName - setName
|| methodName.equals("set" + handledFieldName)// isName - setIsName || ("set" + handledFieldName).equals(methodName)// isName - setIsName
) { ) {
return true; return true;
} }
} }
// 包括boolean的任何类型只有一种匹配情况name - setName // 包括boolean的任何类型只有一种匹配情况name - setName
return methodName.equals("set" + fieldName); return ("set" + fieldName).equals(methodName);
} }
// ------------------------------------------------------------------------------------------------------ Private method end // ------------------------------------------------------------------------------------------------------ Private method end
} }

View File

@ -1166,7 +1166,7 @@ public class ImgUtil {
* @since 4.3.2 * @since 4.3.2
*/ */
public static BufferedImage toBufferedImage(Image image, String imageType) { public static BufferedImage toBufferedImage(Image image, String imageType) {
final int type = imageType.equalsIgnoreCase(IMAGE_TYPE_PNG) final int type = IMAGE_TYPE_PNG.equalsIgnoreCase(imageType)
? BufferedImage.TYPE_INT_ARGB ? BufferedImage.TYPE_INT_ARGB
: BufferedImage.TYPE_INT_RGB; : BufferedImage.TYPE_INT_RGB;
return toBufferedImage(image, type); return toBufferedImage(image, type);

View File

@ -243,7 +243,7 @@ public class NetUtil {
long cBegin = NetUtil.ipv4ToLong("192.168.0.0"); long cBegin = NetUtil.ipv4ToLong("192.168.0.0");
long cEnd = NetUtil.ipv4ToLong("192.168.255.255"); long cEnd = NetUtil.ipv4ToLong("192.168.255.255");
isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || ipAddress.equals(LOCAL_IP); isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || LOCAL_IP.equals(ipAddress);
return isInnerIp; return isInnerIp;
} }

View File

@ -1508,7 +1508,7 @@ public class XmlUtil {
*/ */
@Override @Override
public String getNamespaceURI(String prefix) { public String getNamespaceURI(String prefix) {
if (prefix == null || prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) { if (prefix == null || XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
return prefixUri.get(DEFAULT_NS); return prefixUri.get(DEFAULT_NS);
} else { } else {
return prefixUri.get(prefix); return prefixUri.get(prefix);

View File

@ -102,7 +102,7 @@ public class CollUtilTest {
Collection<String> union = CollUtil.union(list1, list2); Collection<String> union = CollUtil.union(list1, list2);
Assert.assertEquals(3, CollUtil.count(union, t -> t.equals("b"))); Assert.assertEquals(3, CollUtil.count(union, t -> "b".equals(t)));
} }
@Test @Test
@ -111,7 +111,7 @@ public class CollUtilTest {
ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d"); ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d");
Collection<String> intersection = CollUtil.intersection(list1, list2); Collection<String> intersection = CollUtil.intersection(list1, list2);
Assert.assertEquals(2, CollUtil.count(intersection, t -> t.equals("b"))); Assert.assertEquals(2, CollUtil.count(intersection, t -> "b".equals(t)));
} }
@Test @Test
@ -236,7 +236,7 @@ public class CollUtilTest {
final String[] result = new String[1]; final String[] result = new String[1];
CollUtil.forEach(map, (key, value, index) -> { CollUtil.forEach(map, (key, value, index) -> {
if (key.equals("a")) { if ("a".equals(key)) {
result[0] = value; result[0] = value;
} }
}); });

View File

@ -76,7 +76,7 @@ public class TimerTaskList implements Delayed {
*/ */
public void removeTask(TimerTask timerTask) { public void removeTask(TimerTask timerTask) {
synchronized (this) { synchronized (this) {
if (timerTask.timerTaskList.equals(this)) { if (this.equals(timerTask.timerTaskList)) {
timerTask.next.prev = timerTask.prev; timerTask.next.prev = timerTask.prev;
timerTask.prev.next = timerTask.next; timerTask.prev.next = timerTask.next;
timerTask.timerTaskList = null; timerTask.timerTaskList = null;

View File

@ -387,7 +387,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
public boolean isKeepAlive() { public boolean isKeepAlive() {
String connection = header(Header.CONNECTION); String connection = header(Header.CONNECTION);
if (connection == null) { if (connection == null) {
return !httpVersion.equalsIgnoreCase(HTTP_1_0); return !HTTP_1_0.equalsIgnoreCase(httpVersion);
} }
return false == "close".equalsIgnoreCase(connection); return false == "close".equalsIgnoreCase(connection);

View File

@ -109,7 +109,7 @@ public class Platform extends UserAgentInfo {
* @since 5.2.3 * @since 5.2.3
*/ */
public boolean isIPhoneOrIPod() { public boolean isIPhoneOrIPod() {
return IPHONE.equals(this) || IPOD.equals(this); return this.equals(IPHONE) || this.equals(IPOD);
} }
/** /**
@ -119,7 +119,7 @@ public class Platform extends UserAgentInfo {
* @since 5.2.3 * @since 5.2.3
*/ */
public boolean isIPad() { public boolean isIPad() {
return IPAD.equals(this); return this.equals(IPAD);
} }
/** /**
@ -139,7 +139,7 @@ public class Platform extends UserAgentInfo {
* @since 5.2.3 * @since 5.2.3
*/ */
public boolean isAndroid() { public boolean isAndroid() {
return ANDROID.equals(this) || GOOGLE_TV.equals(this); return this.equals(ANDROID) || this.equals(GOOGLE_TV);
} }
} }