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-10-02 13:09:19 +00:00
|
|
|
public m(Point(x, y), Point(z, a)) {
|
|
|
|
return x + y + z + a;
|
2023-08-18 15:15:15 +00:00
|
|
|
}
|
|
|
|
|
2024-10-02 13:09:19 +00:00
|
|
|
/*public m(Point(Float x, Float y)) {
|
2023-09-01 10:34:43 +00:00
|
|
|
return x * y;
|
2024-10-02 13:09:19 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|