:
, , .. , . Java.
, , - , , , . , Game.compareTo IdEntity.compareTo IdEntity.super.compareTo, this.
super, this, this . . Game :
ToIntFunction<IdEntity> f=IdEntity.super::compareTo;
default IdEntity.compareTo Game, IdEntity.
. , abstract compareTo, Comparable, . -, . , Comparator . Game IdEntity, " " Comparator, , .
import java.util.Comparator;
public interface IdEntity /* not Comparable<IdEntity> */ {
int getId();
static Comparator<IdEntity> defaultOrder() {
return Comparator.comparingInt(IdEntity::getId);
}
}
Game :
public class Game implements IdEntity,Comparable<Game> {
public int compareTo(Game o) {
int something;
return something;
}
}
Game IdEntity.defaultOrder():
import java.util.Comparator;
public class Game implements IdEntity {
public static Comparator<Game> defaultGameOrder() {
return (a,b) -> {
int something;
return something;
};
}
}