still overhauling class hierarchy
This commit is contained in:
@@ -199,8 +199,7 @@ public abstract class Block extends StretchableTile implements Comparable<Block>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
super.load(json);
|
||||
public Tile load(JSONObject json) {
|
||||
name = json.has(NAME) ? json.getString(NAME) : "Block";
|
||||
turnAllowed = json.has(ALLOW_TURN) && json.getBoolean(ALLOW_TURN);
|
||||
if (json.has(WAIT_TIMES)) {
|
||||
@@ -210,7 +209,7 @@ public abstract class Block extends StretchableTile implements Comparable<Block>
|
||||
if (object instanceof JSONObject) waitTimes.add(new WaitTime(null).load((JSONObject) object));
|
||||
});
|
||||
}
|
||||
return this;
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -345,7 +344,7 @@ public abstract class Block extends StretchableTile implements Comparable<Block>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
if (params.containsKey(NAME)) name=params.get(NAME);
|
||||
if (params.containsKey(Train.class.getSimpleName())) {
|
||||
Id trainId = Id.from(params,Train.class.getSimpleName());
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class Bridge extends Tile {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(COUNTERPART)) {
|
||||
new Thread() {
|
||||
@Override
|
||||
|
||||
@@ -117,11 +117,10 @@ public class Contact extends Tile{
|
||||
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
super.load(json);
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(ADDRESS)) addr(json.getInt(ADDRESS));
|
||||
if (json.has(REALM_ACTIONS)) actions = ActionList.load(json.getJSONArray(REALM_ACTIONS));
|
||||
return this;
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +212,7 @@ public class Contact extends Tile{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
if (params.containsKey(ADDRESS)) addr(Integer.parseInt(params.get(ADDRESS)));
|
||||
return super.update(params);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Relay extends Tile implements Device{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(ADDRESS)) address = json.getInt(ADDRESS);
|
||||
if (json.has(PORT_A)) portA = json.getInt(PORT_A);
|
||||
if (json.has(PORT_B)) portB = json.getInt(PORT_B);
|
||||
@@ -227,7 +227,7 @@ public class Relay extends Tile implements Device{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
if (params.containsKey(PROTOCOL)) protocol = Protocol.valueOf(params.get(PROTOCOL));
|
||||
if (params.containsKey(ADDRESS)) address = Integer.parseInt(params.get(ADDRESS));
|
||||
if (params.containsKey(PORT_A)) portA = Integer.parseInt(params.get(PORT_A));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -30,10 +29,9 @@ public abstract class StretchableTile extends Tile {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
super.load(json);
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(STRETCH_LENGTH)) stretch = json.getInt(STRETCH_LENGTH);
|
||||
return this;
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +59,7 @@ public abstract class StretchableTile extends Tile {
|
||||
protected abstract String stretchType();
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
for (Entry<String, String> entry : params.entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case STRETCH_LENGTH:
|
||||
|
||||
@@ -25,10 +25,9 @@ public class TextDisplay extends StretchableTile {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
super.load(json);
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(TEXT)) text = json.getString(TEXT);
|
||||
return this;
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +72,7 @@ public class TextDisplay extends StretchableTile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
for (Entry<String, String> entry : params.entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case TEXT:
|
||||
|
||||
@@ -169,7 +169,8 @@ public abstract class Tile extends BaseClass{
|
||||
}
|
||||
}
|
||||
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
public Tile load(JSONObject json) {
|
||||
super.load(json);
|
||||
JSONObject pos = json.getJSONObject(POS);
|
||||
x = pos.getInt(X);
|
||||
y = pos.getInt(Y);
|
||||
@@ -394,7 +395,7 @@ public abstract class Tile extends BaseClass{
|
||||
plan.place(this);
|
||||
}
|
||||
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
LOG.debug("{}.update({})",getClass().getSimpleName(),params);
|
||||
String oneWayDir = params.get("oneway");
|
||||
if (isSet(oneWayDir)) {
|
||||
@@ -407,7 +408,7 @@ public abstract class Tile extends BaseClass{
|
||||
disabled = "on".equals(params.get(DISABLED));
|
||||
String len = params.get(LENGTH);
|
||||
if (isSet(len)) length(Integer.parseInt(len));
|
||||
plan.stream(tag(null).toString());
|
||||
plan.place(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class Turnout extends Tile implements Device{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tile load(JSONObject json) throws IOException {
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(ADDRESS)) address = json.getInt(ADDRESS);
|
||||
if (json.has(PORT_A)) portA = json.getInt(PORT_A);
|
||||
if (json.has(PORT_B)) portB = json.getInt(PORT_B);
|
||||
@@ -201,7 +201,7 @@ public abstract class Turnout extends Tile implements Device{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
if (params.containsKey(PROTOCOL)) protocol = Protocol.valueOf(params.get(PROTOCOL));
|
||||
if (params.containsKey(ADDRESS)) {
|
||||
int newAddress = Integer.parseInt(params.get(ADDRESS));
|
||||
|
||||
@@ -50,7 +50,7 @@ public class TurnoutL extends Turnout {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
if (params.containsKey(STRAIGHT)) portA = Integer.parseInt(params.get(STRAIGHT));
|
||||
if (params.containsKey(LEFT)) portB = Integer.parseInt(params.get(LEFT));
|
||||
return super.update(params);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TurnoutR extends Turnout {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
if (params.containsKey(STRAIGHT)) portA = Integer.parseInt(params.get(STRAIGHT));
|
||||
if (params.containsKey(RIGHT)) portB = Integer.parseInt(params.get(RIGHT));
|
||||
return super.update(params);
|
||||
|
||||
Reference in New Issue
Block a user