Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 9947, use isEmpty() for checking emptiness #9981

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ public ActionForward importFile(ActionMapping mapping, ActionForm formIn,
RhnSet set = RhnSetDecl.CONFIG_IMPORT_FILE_NAMES.get(user);
Set cfnids = getCfnids(set);
//if they don't have a set, don't do anything.
if (cfnids.size() < 1) {
if (cfnids.isEmpty()) {
return createErrorMessage(request, mapping, formIn, server.getId(),
"sdcfilelist.jsp.noSelected");
}
@@ -173,7 +173,7 @@ private ActionForward createRevisionAction(HttpServletRequest request, ActionFor
RhnSet set = RhnSetDecl.CONFIG_FILE_NAMES.get(user);
Set revisions = getCrids(set, sid);
//if they don't have a set, don't do anything.
if (revisions.size() < 1) {
if (revisions.isEmpty()) {
return createErrorMessage(request, mapping, form, sid,
"sdcfilelist.jsp.noSelected");
}
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ public ActionForward goToConfirm(ActionMapping mapping,
HttpServletRequest request,
HttpServletResponse response) {
//They didn't select anything. Tell them to select something.
if (updateSet(request).size() < 1) {
if (updateSet(request).isEmpty()) {
ActionErrors errors = new ActionErrors();
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("sdcfilelist.jsp.noSelected"));
Original file line number Diff line number Diff line change
@@ -282,7 +282,7 @@ public ActionForward execute(ActionMapping actionMapping,
request.setAttribute(LATEST_SP, true);
return forward;
}
else if (migrationTargets.size() >= 1) {
else if (!migrationTargets.isEmpty()) {
// At least one target available
logger.debug("Found at least one migration target");
request.setAttribute(TARGET_PRODUCTS, migrationTargets);
Original file line number Diff line number Diff line change
@@ -996,7 +996,7 @@ public int addAssignedSystemGroups(User loggedInUser, String login, List<String>
User targetUser = XmlRpcUserHelper.getInstance().lookupTargetUser(
loggedInUser, login);

if (sgNames == null || sgNames.size() < 1) {
if (sgNames == null || sgNames.isEmpty()) {
throw new IllegalArgumentException("no servergroup names supplied");
}

Original file line number Diff line number Diff line change
@@ -233,7 +233,7 @@ public static Action lookupAction(User user, Long aid) {
params.put("org_id", user.getOrg().getId());
params.put("aid", aid);
params.put("include_orphans", user.hasRole(RoleFactory.ORG_ADMIN) ? "Y" : "N");
if (m.execute(params).size() < 1) {
if (m.execute(params).isEmpty()) {
returnedAction = null;
}

@@ -577,7 +577,7 @@ public static Action createConfigUploadAction(User user, Set filenames, Server s
}

//if this is a pointless action, don't do it.
if (a.getConfigFileNameAssociations().size() < 1) {
if (a.getConfigFileNameAssociations().isEmpty()) {
return null;
}

Original file line number Diff line number Diff line change
@@ -519,7 +519,7 @@ public static List<RankedChannel> addRelevantMigrationProductChannels(

// ...if it has a target with that base product...
List<SUSEProductDto> targets = findAllTargetProducts(suseProductID);
if (log.isDebugEnabled() && targets.size() <= 0) {
if (log.isDebugEnabled() && targets.isEmpty()) {
log.debug("No target products found for {}", suseProductID);
}
for (SUSEProductDto target : targets) {
@@ -552,7 +552,7 @@ public static List<RankedChannel> addRelevantMigrationProductChannels(

// ...if it has a source with that base product...
List<SUSEProductDto> sources = findAllSourceProducts(suseProductID);
if (log.isDebugEnabled() && sources.size() <= 0) {
if (log.isDebugEnabled() && sources.isEmpty()) {
log.debug("No source products found for {}", suseProductID);
}
for (SUSEProductDto source : sources) {
Original file line number Diff line number Diff line change
@@ -2327,7 +2327,7 @@ public static boolean isAvailableToUser(User user, Long sid) {
Map<String, Object> params = new HashMap<>();
params.put("uid", user.getId());
params.put("sid", sid);
return m.execute(params).size() >= 1;
return !m.execute(params).isEmpty();
}

/**
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ public static Object getACS(Request request, Response response) {

final Collection<String> keys = attributes.keySet();

if (keys.contains((String) "uid") && attributes.get("uid").size() >= 1) {
if (keys.contains((String) "uid") && !attributes.get("uid").isEmpty()) {
final Optional uidOpt = Optional.ofNullable(attributes.get("uid").get(0));
if (uidOpt.isPresent()) {
final User user = UserFactory.lookupByLogin(String.valueOf(uidOpt.get()));
2 changes: 1 addition & 1 deletion java/code/src/com/suse/utils/Lists.java
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ private static <T> List<List<T>> combinations(List<List<T>> acc, List<T> list)
* @return cartesian product of the input
*/
public static <T> List<List<T>> combinations(List<List<T>> lists) {
if (lists.size() < 1) {
if (lists.isEmpty()) {
return new ArrayList<>();
}
else {