avoid boxing Comparator.comparings
This commit is contained in:
@@ -100,7 +100,7 @@ public class EventBus
|
||||
{
|
||||
final ImmutableMultimap.Builder<Class<?>, Subscriber> builder = ImmutableMultimap.builder();
|
||||
builder.putAll(subscribers);
|
||||
builder.orderValuesBy(Comparator.comparing(Subscriber::getPriority).reversed()
|
||||
builder.orderValuesBy(Comparator.comparingDouble(Subscriber::getPriority).reversed()
|
||||
.thenComparing(s -> s.object.getClass().getName()));
|
||||
|
||||
for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass())
|
||||
@@ -171,7 +171,7 @@ public class EventBus
|
||||
{
|
||||
final ImmutableMultimap.Builder<Class<?>, Subscriber> builder = ImmutableMultimap.builder();
|
||||
builder.putAll(subscribers);
|
||||
builder.orderValuesBy(Comparator.comparing(Subscriber::getPriority).reversed()
|
||||
builder.orderValuesBy(Comparator.comparingDouble(Subscriber::getPriority).reversed()
|
||||
.thenComparing(s -> s.object.getClass().getName()));
|
||||
|
||||
Subscriber sub = new Subscriber(subFn, null, priority, (Consumer<Object>) subFn);
|
||||
|
||||
@@ -546,8 +546,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
||||
Widget[] containerChildren = itemContainer.getDynamicChildren();
|
||||
|
||||
// sort the child array as the items are not in the displayed order
|
||||
Arrays.sort(containerChildren, Comparator.comparing(Widget::getOriginalY)
|
||||
.thenComparing(Widget::getOriginalX));
|
||||
Arrays.sort(containerChildren, Comparator.comparingInt(Widget::getOriginalY)
|
||||
.thenComparingInt(Widget::getOriginalX));
|
||||
|
||||
for (Widget child : containerChildren)
|
||||
{
|
||||
|
||||
@@ -436,9 +436,9 @@ class WidgetInspector extends DevToolsFrame
|
||||
|
||||
parent = Stream.of(roots)
|
||||
.filter(w -> w.getType() == WidgetType.LAYER && w.getContentType() == 0 && !w.isSelfHidden())
|
||||
.sorted(Comparator.comparing((Widget w) -> w.getRelativeX() + w.getRelativeY())
|
||||
.sorted(Comparator.comparingInt((Widget w) -> w.getRelativeX() + w.getRelativeY())
|
||||
.reversed()
|
||||
.thenComparing(Widget::getId)
|
||||
.thenComparingInt(Widget::getId)
|
||||
.reversed())
|
||||
.findFirst().get();
|
||||
x = 4;
|
||||
|
||||
@@ -462,14 +462,14 @@ public class FishingPlugin extends Plugin
|
||||
|
||||
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
||||
fishingSpots.sort(
|
||||
Comparator.comparing(
|
||||
Comparator.comparingInt(
|
||||
// Negate to have the furthest first
|
||||
(NPC npc) -> -npc.getLocalLocation().distanceTo(cameraPoint))
|
||||
// Order by position
|
||||
.thenComparing(NPC::getLocalLocation, Comparator.comparing(LocalPoint::getX)
|
||||
.thenComparing(LocalPoint::getY))
|
||||
.thenComparing(NPC::getLocalLocation, Comparator.comparingInt(LocalPoint::getX)
|
||||
.thenComparingInt(LocalPoint::getY))
|
||||
// And then by id
|
||||
.thenComparing(NPC::getId)
|
||||
.thenComparingInt(NPC::getId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SaradominBrew implements Effect
|
||||
).toArray(StatChange[]::new));
|
||||
changes.setPositivity(Stream.of(changes.getStatChanges())
|
||||
.map(sc -> sc.getPositivity())
|
||||
.max(Comparator.comparing(Enum::ordinal)).get());
|
||||
.max(Comparator.naturalOrder()).get());
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,9 @@ public class SuperRestore implements Effect
|
||||
return calc.effect(client);
|
||||
})
|
||||
).toArray(StatChange[]::new));
|
||||
changes.setPositivity(Stream.of(changes.getStatChanges()).map(sc -> sc.getPositivity()).max(Comparator.comparing(Enum::ordinal)).get());
|
||||
changes.setPositivity(Stream.of(changes.getStatChanges())
|
||||
.map(sc -> sc.getPositivity())
|
||||
.max(Comparator.naturalOrder()).get());
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CastleWarsBandage implements Effect
|
||||
changes.setStatChanges(new StatChange[]{hitPoints, runEnergy});
|
||||
changes.setPositivity(Stream.of(changes.getStatChanges())
|
||||
.map(StatChange::getPositivity)
|
||||
.max(Comparator.comparing(Enum::ordinal)).get());
|
||||
.max(Comparator.naturalOrder()).get());
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ public class MusicPlugin extends Plugin
|
||||
if (tracks == null)
|
||||
{
|
||||
tracks = Arrays.stream(musicList.getDynamicChildren())
|
||||
.sorted(Comparator.comparing(Widget::getRelativeY))
|
||||
.sorted(Comparator.comparingInt(Widget::getRelativeY))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ public class QuestListPlugin extends Plugin
|
||||
{
|
||||
// Find all of the widgets that we care about, sorting by their Y value
|
||||
quests = Arrays.stream(list.getDynamicChildren())
|
||||
.sorted(Comparator.comparing(Widget::getRelativeY))
|
||||
.sorted(Comparator.comparingInt(Widget::getRelativeY))
|
||||
.filter(w -> !QUEST_HEADERS.contains(w.getText()))
|
||||
.map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -271,7 +271,7 @@ public class ContainableFrame extends JFrame
|
||||
{
|
||||
return Arrays.stream(GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices())
|
||||
.map(GraphicsDevice::getDefaultConfiguration)
|
||||
.max(Comparator.comparing(config ->
|
||||
.max(Comparator.comparingInt(config ->
|
||||
{
|
||||
Rectangle intersection = config.getBounds().intersection(getBounds());
|
||||
return intersection.width * intersection.height;
|
||||
|
||||
Reference in New Issue
Block a user