Prefer isEmpty() over size() == 0

This commit is contained in:
Trustin Lee 2012-11-10 01:21:25 +09:00
parent 67f1d9a23d
commit 53cecdb31b
3 changed files with 4 additions and 5 deletions

View File

@ -562,7 +562,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
char firstChar = line.charAt(0);
if (lastHeader != null && (firstChar == ' ' || firstChar == '\t')) {
List<String> current = trailer.getHeaders(lastHeader);
if (current.size() != 0) {
if (!current.isEmpty()) {
int lastPos = current.size() - 1;
String newString = current.get(lastPos) + line.trim();
current.set(lastPos, newString);

View File

@ -374,8 +374,7 @@ public class HttpPostRequestDecoder {
throw new EndOfDataDecoderException();
}
}
return bodyListHttpData.size() > 0 &&
bodyListHttpDataRank < bodyListHttpData.size();
return !bodyListHttpData.isEmpty() && bodyListHttpDataRank < bodyListHttpData.size();
}
/**

View File

@ -405,7 +405,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
duringMixedMode = false;
}
InternalAttribute internal = new InternalAttribute();
if (multipartHttpDatas.size() > 0) {
if (!multipartHttpDatas.isEmpty()) {
// previously a data field so CRLF
internal.addValue("\r\n");
}
@ -430,7 +430,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
} else if (data instanceof FileUpload) {
FileUpload fileUpload = (FileUpload) data;
InternalAttribute internal = new InternalAttribute();
if (multipartHttpDatas.size() > 0) {
if (!multipartHttpDatas.isEmpty()) {
// previously a data field so CRLF
internal.addValue("\r\n");
}