I am exploring the possibilities of static and standard methods introduced in java 8.
I have an interface that has two default methods that create a command that I run on the server via ssh in order to remotely perform some simple tasks. Moving the mouse requires 2 arguments: the x and y positions of the mouse.
public interface Robot {
default String moveMouse(int x, int y) {
return constructCmd("java -jar move_mouse.jar " + x + " " + y);
}
default String clickLeft() {
return constructCmd("java -jar click_left.jar");
}
static String constructCmd(String cmd) {
return "export DISPLAY=:1.0\n" +
"cd Desktop\n" +
cmd;
}
}
I have several enumerations with predefined values, I could combine all the enumerations into one, and not use the interface, whatever that is, however this enumeration will contain hundreds or thousands of values, and I want it to be organized somewhat , ve split evertying in a few listings.
, , , .
public enum Field implements Robot {
AGE_FIELD(778, 232),
NAME_FIELD(662, 280);
public int x;
public int y;
Field(int x, int y) {
this.x = x;
this.y = y;
}
}
, String:
Field.AGE_FIELD.clickLeft();
Field.AGE_FIELD.moveMouse(Field.AGE_FIELD.x, Field.AGE_FIELD.y);
moveMouse , , enum.
- ?