these are the more complicated code improvements#233
Conversation
| return Long.valueOf(firstTime).compareTo(Long.valueOf(secondTime)); | ||
| } | ||
| }; | ||
| public static final Comparator<Zman> DATE_ORDER = (zman1, zman2) -> { |
There was a problem hiding this comment.
@Elyahu41 , how about this using Lambda?
public static final Comparator DATE_ORDER = Comparator.comparingLong(
zman -> zman == null || zman.getZman() == null ? Long.MAX_VALUE : zman.getZman().getTime()
);
There was a problem hiding this comment.
I just double checked this code with IntelliJ. If you want to code the method that way, I recommend this:
public static final Comparator<Zman> DATE_ORDER = Comparator.comparingLong(zman ->
zman == null || zman.getZman() == null ? Long.MAX_VALUE : zman.getZman().toEpochMilli()
);
| return firstLabel.compareTo(secondLabel); | ||
| } | ||
| }; | ||
| public static final Comparator<Zman> NAME_ORDER = (zman1, zman2) -> { |
There was a problem hiding this comment.
How about this?
public static final Comparator NAME_ORDER = Comparator.comparing(
zman -> zman == null || zman.getLabel() == null ? "" : zman.getLabel()
);
There was a problem hiding this comment.
That's fine. I think you're just missing the typing tag for no warnings to show:
public static final Comparator<Zman> NAME_ORDER = Comparator.comparing(zman ->
zman == null || zman.getLabel() == null ? "" : zman.getLabel()
);
| return firstDuration == secondDuration ? 0 : firstDuration > secondDuration ? 1 : -1; | ||
| } | ||
| }; | ||
| public static final Comparator<Zman> DURATION_ORDER = (zman1, zman2) -> { |
There was a problem hiding this comment.
And this
public static final Comparator DURATION_ORDER = Comparator.comparingLong(
zman -> zman == null ? Long.MAX_VALUE : zman.getDuration()
);
There was a problem hiding this comment.
same here @KosherJava :
public static final Comparator<Zman> DURATION_ORDER = Comparator.comparingLong(
zman -> zman == null ? Long.MAX_VALUE : zman.getDuration()
);
|
@Elyahu41 , I will leave it up to you. |
|
Ok, then let's go with the methods you proposed just with the type included. Should I fix the conflicts with this branch so that you can merge it? |
|
@Elyahu41 , yes please |
No description provided.