Skip to content

Commit

Permalink
simplify collection emptiness check
Browse files Browse the repository at this point in the history
Use isEmpty() API of collections to simplify the emptiness check.reduces
one extra comparison.
  • Loading branch information
elsazac authored and akurtakov committed Jan 4, 2024
1 parent f897258 commit ba8b454
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public void processFragment(MModelFragments fragmentsContainer, MModelFragment f
log(LogLevel.DEBUG, "Nothing to merge for fragment {} of {}", contributorURI, //$NON-NLS-1$
contributorName);
}
if (evalImports && fragmentsContainer.getImports().size() > 0) {
if (evalImports && !fragmentsContainer.getImports().isEmpty()) {
resolveImports(fragmentsContainer.getImports(), addedElements);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public MUIElement find(String id, MUIElement searchRoot) {
}

List<MUIElement> elements = findElements(searchRoot, id, MUIElement.class);
if (elements.size() > 0) {
if (!elements.isEmpty()) {
return elements.get(0);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ && isValid(perspective, candidate)) {

List<MPart> activeCandidates = modelService.findElements(perspective, null, MPart.class,
singletonList(EPartService.ACTIVE_ON_CLOSE_TAG));
if (activeCandidates.size() > 0) {
if (!activeCandidates.isEmpty()) {
activeCandidates.get(0).getTags().remove(EPartService.ACTIVE_ON_CLOSE_TAG);
MPart candidate = activeCandidates.get(0);
if (partService.isInContainer(perspective, candidate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ private void internalFixContext(MPart part, MUIElement oldSelectedElement) {
@Override
public MPart findPart(String id) {
List<MPart> parts = getParts(MPart.class, id);
return parts.size() > 0 ? parts.get(0) : null;
return parts.isEmpty() ? null : parts.get(0);
}

private <T> List<T> getParts(Class<T> cls, String id) {
Expand Down Expand Up @@ -1020,7 +1020,7 @@ private MPart addPart(MPart providedPart, MPart localPart) {
} else {
// Find the first visible stack in the area
List<MPartStack> sharedStacks = modelService.findElements(area, null, MPartStack.class);
if (sharedStacks.size() > 0) {
if (!sharedStacks.isEmpty()) {
for (MPartStack stack : sharedStacks) {
if (stack.isToBeRendered()) {
stack.getChildren().add(providedPart);
Expand Down Expand Up @@ -1085,7 +1085,7 @@ private void addToLastContainer(String category, MPart part) {
descId += ":*"; //$NON-NLS-1$
List<MPlaceholder> phList = modelService.findElements(workbenchWindow, descId,
MPlaceholder.class, null, EModelService.PRESENTATION);
if (phList.size() > 0) {
if (!phList.isEmpty()) {
MUIElement phParent = phList.get(0).getParent();
if (phParent instanceof MPartStack) {
MPartStack theStack = (MPartStack) phParent;
Expand Down

0 comments on commit ba8b454

Please sign in to comment.