2023-08-18 15:15:15 +00:00
|
|
|
import java.lang.Integer;
|
2023-09-01 10:34:43 +00:00
|
|
|
import java.lang.Number;
|
|
|
|
import java.lang.Float;
|
2023-08-18 15:15:15 +00:00
|
|
|
|
2024-10-02 13:09:19 +00:00
|
|
|
public record Point(Number x, Number y) {}
|
2023-08-18 15:15:15 +00:00
|
|
|
|
|
|
|
public class OverloadPattern {
|
2024-11-19 12:32:55 +00:00
|
|
|
public Number m(Point(Integer x, Integer y), Point(Float a, Float b)) {
|
2024-11-19 14:19:40 +00:00
|
|
|
return 1;
|
2023-08-18 15:15:15 +00:00
|
|
|
}
|
|
|
|
|
2024-11-19 12:32:55 +00:00
|
|
|
public Number m(Point(Integer x, Integer y), Point(Integer a, Integer b)) {
|
2024-11-19 14:19:40 +00:00
|
|
|
return 2;
|
2024-11-19 12:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Number m(Point(Float x, Float y), Point(Integer a, Integer b)) {
|
2024-11-19 14:19:40 +00:00
|
|
|
return 3;
|
2024-11-19 12:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Number m(Point(Float x, Float y), Point(Float a, Float b)) {
|
2024-11-19 14:19:40 +00:00
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Number m(Point(Integer x, Integer y)) {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Number m(Point(Float x, Float y)) {
|
|
|
|
return 6;
|
2024-11-07 16:04:43 +00:00
|
|
|
}
|
2023-09-01 10:34:43 +00:00
|
|
|
|
2024-03-14 12:50:56 +00:00
|
|
|
public m(Integer x) {
|
2023-08-18 15:15:15 +00:00
|
|
|
return x;
|
|
|
|
}
|
2023-09-01 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
public class OverloadPattern {
|
|
|
|
Integer m$Point$_$java$lang$Integer$_$java$lang$Integer$_$(Point point) {
|
|
|
|
var x = point.x();
|
|
|
|
var y = point.y();
|
|
|
|
return x + y;
|
|
|
|
}
|
|
|
|
|
|
|
|
Float m$Point$_$java$lang$Float$_$java$lang$Float$_$(Point point) {
|
|
|
|
var x = point.x();
|
|
|
|
var y = point.y();
|
|
|
|
return x * y;
|
|
|
|
}
|
|
|
|
|
2023-09-01 10:51:06 +00:00
|
|
|
Number m(Point point) {
|
2023-09-01 16:26:01 +00:00
|
|
|
return switch(point) {
|
2023-09-01 10:34:43 +00:00
|
|
|
case Point(Integer x, Integer y) ->
|
|
|
|
m$Point$_$java$lang$Integer$_$java$lang$Integer$_$(point);
|
|
|
|
case Point(Float x, Float y) ->
|
|
|
|
m$Point$_$java$lang$Float$_$java$lang$Float$_$(point);
|
2023-09-01 10:51:06 +00:00
|
|
|
default -> throw new IllegalArgumentException();
|
2023-09-01 10:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Integer m(Integer x) {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|