simplified code
This commit is contained in:
@@ -11,7 +11,6 @@ import org.json.JSONObject;
|
||||
|
||||
import de.keawe.tools.translations.Translation;
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Plan.Direction;
|
||||
import de.srsoftware.web4rail.actions.Action;
|
||||
import de.srsoftware.web4rail.conditions.Condition;
|
||||
import de.srsoftware.web4rail.moving.Car;
|
||||
@@ -40,7 +39,6 @@ public abstract class BaseClass implements Constants{
|
||||
private Condition condition;
|
||||
private Car car;
|
||||
private Contact contact;
|
||||
private Direction direction = null;
|
||||
|
||||
public Context(BaseClass object) {
|
||||
main = object;
|
||||
@@ -82,16 +80,7 @@ public abstract class BaseClass implements Constants{
|
||||
public Contact contact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public Direction direction() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public Context direction(Direction newDirection) {
|
||||
direction = newDirection;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Route route() {
|
||||
return route;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package de.srsoftware.web4rail;
|
||||
|
||||
public class Context {
|
||||
|
||||
}
|
||||
@@ -20,7 +20,6 @@ public abstract class TextAction extends Action {
|
||||
public String fill(String tx,Context context) {
|
||||
if (isSet(context.block())) tx = tx.replace("%block%", context.block().name);
|
||||
if (isSet(context.contact())) tx = tx.replace("%contact%", context.contact().id().toString());
|
||||
if (isSet(context.direction())) tx = tx.replace("%dir%", context.direction().name());
|
||||
if (isSet(context.route())) tx = tx.replace("%route%", context.route().name());
|
||||
if (isSet(context.train())) tx = tx.replace("%train%", context.train().name());
|
||||
return tx;
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Map.Entry;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -338,18 +339,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
if (isSet(name))json.put(NAME, name);
|
||||
if (isSet(route)) json.put(ROUTE, route.id());
|
||||
if (isSet(direction)) json.put(DIRECTION, direction);
|
||||
|
||||
Vector<String> locoIds = new Vector<String>();
|
||||
for (Locomotive loco : locos) locoIds.add(loco.id().toString());
|
||||
json.put(LOCOS, locoIds);
|
||||
|
||||
Vector<String> carIds = new Vector<String>();
|
||||
for (Car car : cars) carIds.add(car.id().toString());
|
||||
json.put(CARS,carIds);
|
||||
|
||||
Vector<String> tileIds = new Vector<String>();
|
||||
for (Tile tile : trace) tileIds.add(tile.id().toString());
|
||||
json.put(TRACE, tileIds);
|
||||
json.put(LOCOS, locos.stream().map(l -> l.id().toString()).collect(Collectors.toList()));
|
||||
json.put(CARS,cars.stream().map(c -> c.id().toString()).collect(Collectors.toList()));
|
||||
json.put(TRACE, trace.stream().map(t -> t.id().toString()).collect(Collectors.toList()));
|
||||
|
||||
if (!tags.isEmpty()) json.put(TAGS, tags);
|
||||
return json;
|
||||
|
||||
Reference in New Issue
Block a user