comparation simplified

This commit is contained in:
vyacheslav.raskulin 2020-09-09 15:00:30 +03:00
parent 022c1407ed
commit 7da043afd0
6 changed files with 12 additions and 18 deletions

View file

@ -384,7 +384,7 @@
@Override
public int compare(MageCard o1, MageCard o2) {
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
int val = Integer.compare(o1.getOriginal().getConvertedManaCost(), o2.getOriginal().getConvertedManaCost());
if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
} else {

View file

@ -321,7 +321,7 @@
}
}
// sort the cards
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
cardsToLayout.sort(Comparator.comparingInt(cp -> cp.getLocation().x));
// relocate the cards
int dx = 0;
for (Component component : cardsToLayout) {

View file

@ -96,13 +96,10 @@ public class PickCheckBoxDialog extends MageDialog {
// sorting
if (choice.isSortEnabled()) {
Collections.sort(this.allItems, new Comparator<KeyValueItem>() {
@Override
public int compare(KeyValueItem o1, KeyValueItem o2) {
Integer n1 = choice.getSortData().get(o1.getKey());
Integer n2 = choice.getSortData().get(o2.getKey());
return n1.compareTo(n2);
}
this.allItems.sort((o1, o2) -> {
Integer n1 = choice.getSortData().get(o1.getKey());
Integer n2 = choice.getSortData().get(o2.getKey());
return n1.compareTo(n2);
});
}

View file

@ -57,13 +57,10 @@ public class PickChoiceDialog extends MageDialog {
// sorting
if (choice.isSortEnabled()) {
Collections.sort(this.allItems, new Comparator<KeyValueItem>() {
@Override
public int compare(KeyValueItem o1, KeyValueItem o2) {
Integer n1 = choice.getSortData().get(o1.Key);
Integer n2 = choice.getSortData().get(o2.Key);
return n1.compareTo(n2);
}
this.allItems.sort((o1, o2) -> {
Integer n1 = choice.getSortData().get(o1.Key);
Integer n2 = choice.getSortData().get(o2.Key);
return n1.compareTo(n2);
});
}

View file

@ -332,7 +332,7 @@ public class MageActionCallback implements ActionCallback {
private void sortLayout(List<CardPanel> cards, CardPanel source, boolean includeSource) {
source.getLocation().x -= COMPARE_GAP_X; // this creates nice effect
cards.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
cards.sort(Comparator.comparingInt(cp -> cp.getLocation().x));
int dx = 0;
boolean createdGapForSource = false;

View file

@ -12,7 +12,7 @@ public class CardViewCostComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return Integer.valueOf(o1.getConvertedManaCost()).compareTo(o2.getConvertedManaCost());
return Integer.compare(o1.getConvertedManaCost(), o2.getConvertedManaCost());
}
}