mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 22:19:13 +00:00
remove quadruple from simulator code;
This commit is contained in:
@@ -231,84 +231,4 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Quadruple<A, B, C, D> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2120209172266608653L;
|
||||
|
||||
private A a;
|
||||
|
||||
private B b;
|
||||
|
||||
private C c;
|
||||
|
||||
private D d;
|
||||
|
||||
private transient int hashCode;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
// required for some serialization frameworks such as GWT RPC
|
||||
private Quadruple() {
|
||||
}
|
||||
|
||||
public Quadruple(final A a, final B b, final C c, final D d) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.hashCode = 0;
|
||||
}
|
||||
|
||||
public A getA() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public B getB() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public C getC() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public D getD() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this.hashCode == 0) {
|
||||
this.hashCode = 17;
|
||||
this.hashCode = 37 * this.hashCode + (this.a != null ? a.hashCode() : 0);
|
||||
this.hashCode = 37 * this.hashCode + (this.b != null ? b.hashCode() : 0);
|
||||
this.hashCode = 37 * this.hashCode + (this.c != null ? c.hashCode() : 0);
|
||||
this.hashCode = 37 * this.hashCode + (this.d != null ? d.hashCode() : 0);
|
||||
}
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
|
||||
boolean result;
|
||||
if (this == obj) {
|
||||
result = true;
|
||||
} else if (obj instanceof Triple<?, ?, ?>) {
|
||||
final Quadruple<?, ?, ?, ?> thrice = (Quadruple<?, ?, ?, ?>) obj;
|
||||
result = (this.a != null && this.a.equals(thrice.a) || this.a == null && thrice.a == null)
|
||||
&& (this.b != null && this.b.equals(thrice.b) || this.b == null && thrice.b == null)
|
||||
&& (this.c != null && this.c.equals(thrice.c) || this.c == null && thrice.c == null)
|
||||
&& (this.d != null && this.d.equals(thrice.d) || this.d == null && thrice.d == null);
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "[" + this.a + ", " + this.b + ", " + this.c + ", " + this.d + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,6 @@ import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.impl.NauticalMileDistance;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.Util.Quadruple;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sailing.gwt.ui.client.SimulatorService;
|
||||
import com.sap.sailing.gwt.ui.shared.BoatClassDTO;
|
||||
@@ -54,6 +53,7 @@ import com.sap.sailing.gwt.ui.shared.windpattern.WindPatternDisplay;
|
||||
import com.sap.sailing.gwt.ui.shared.windpattern.WindPatternDisplayManager;
|
||||
import com.sap.sailing.gwt.ui.shared.windpattern.WindPatternNotFoundException;
|
||||
import com.sap.sailing.gwt.ui.shared.windpattern.WindPatternSetting;
|
||||
import com.sap.sailing.simulator.BoatClassProperties;
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.PolarDiagram;
|
||||
import com.sap.sailing.simulator.SailingSimulator;
|
||||
@@ -317,8 +317,8 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
result.setNotificationMessage(config.getErrorMessage());
|
||||
}
|
||||
|
||||
for (Quadruple<String, Double, String, Integer> tuple : ConfigurationManager.INSTANCE.getBoatClassesInfo()) {
|
||||
boatClassesDTOs.add(new BoatClassDTO(tuple.getA(), tuple.getB()));
|
||||
for (BoatClassProperties tuple : ConfigurationManager.INSTANCE.getBoatClassesInfo()) {
|
||||
boatClassesDTOs.add(new BoatClassDTO(tuple.getName(), tuple.getLength()));
|
||||
}
|
||||
|
||||
result.setBoatClassDTOs(boatClassesDTOs.toArray(new BoatClassDTO[boatClassesDTOs.size()]));
|
||||
|
||||
+23
-21
@@ -8,43 +8,45 @@ import junit.framework.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.impl.Util.Quadruple;
|
||||
import com.sap.sailing.simulator.BoatClassProperties;
|
||||
import com.sap.sailing.simulator.RaceProperties;
|
||||
import com.sap.sailing.simulator.impl.BoatClassPropertiesImpl;
|
||||
import com.sap.sailing.simulator.impl.ConfigurationManager;
|
||||
import com.sap.sailing.simulator.impl.RacePropertiesImpl;
|
||||
|
||||
public class ConfigurationManagerTest {
|
||||
|
||||
private final List<Quadruple<String, Double, String, Integer>> _boatClassesInfo = new ArrayList<Quadruple<String, Double, String, Integer>>();
|
||||
|
||||
private final List<Quadruple<String, String, String, Integer>> _racesInfo = new ArrayList<Quadruple<String, String, String, Integer>>();
|
||||
private final List<BoatClassProperties> _boatClassesInfo = new ArrayList<BoatClassProperties>();
|
||||
private final List<RaceProperties> _racesInfo = new ArrayList<RaceProperties>();
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
this._boatClassesInfo.add(new Quadruple<String, Double, String, Integer>("49er", 4.995, "resources/PolarDiagram49.csv", 0));
|
||||
this._boatClassesInfo.add(new Quadruple<String, Double, String, Integer>("49er Bethwaite", 4.876, "resources/PolarDiagram49Bethwaite.csv", 1));
|
||||
this._boatClassesInfo.add(new Quadruple<String, Double, String, Integer>("49er ORC", 4.995, "resources/PolarDiagram49ORC.csv", 2));
|
||||
this._boatClassesInfo.add(new Quadruple<String, Double, String, Integer>("49er STG", 4.876, "resources/PolarDiagram49STG.csv", 3));
|
||||
this._boatClassesInfo.add(new Quadruple<String, Double, String, Integer>("505 STG", 5.05, "resources/PolarDiagram505STG.csv", 4));
|
||||
this._boatClassesInfo.add(new BoatClassPropertiesImpl("49er", 4.995, "resources/PolarDiagram49.csv", 0));
|
||||
this._boatClassesInfo.add(new BoatClassPropertiesImpl("49er Bethwaite", 4.876, "resources/PolarDiagram49Bethwaite.csv", 1));
|
||||
this._boatClassesInfo.add(new BoatClassPropertiesImpl("49er ORC", 4.995, "resources/PolarDiagram49ORC.csv", 2));
|
||||
this._boatClassesInfo.add(new BoatClassPropertiesImpl("49er STG", 4.876, "resources/PolarDiagram49STG.csv", 3));
|
||||
this._boatClassesInfo.add(new BoatClassPropertiesImpl("505 STG", 5.05, "resources/PolarDiagram505STG.csv", 4));
|
||||
|
||||
this._racesInfo
|
||||
.add(new Quadruple<String, String, String, Integer>(
|
||||
.add(new RacePropertiesImpl(
|
||||
"Internationale Deutche Meisterschaft - 49er Race4",
|
||||
"49er STG",
|
||||
"http://germanmaster.traclive.dk/events/event_20110929_Internatio/clientparams.php?event=event_20110929_Internatio&race=d1f521fa-ec52-11e0-a523-406186cbf87c",
|
||||
0));
|
||||
this._racesInfo
|
||||
.add(new Quadruple<String, String, String, Integer>(
|
||||
.add(new RacePropertiesImpl (
|
||||
"Internationale Deutche Meisterschaft - 49er Race5",
|
||||
"49er STG",
|
||||
"http://germanmaster.traclive.dk/events/event_20110929_Internatio/clientparams.php?event=event_20110929_Internatio&race=eb06795a-ec52-11e0-a523-406186cbf87c",
|
||||
1));
|
||||
this._racesInfo
|
||||
.add(new Quadruple<String, String, String, Integer>(
|
||||
.add(new RacePropertiesImpl (
|
||||
"Internationale Deutche Meisterschaft - Star Race4",
|
||||
"49er STG",
|
||||
"http://germanmaster.traclive.dk/events/event_20110929_Internatio/clientparams.php?event=event_20110929_Internatio&race=6bb0829e-ec44-11e0-a523-406186cbf87c",
|
||||
2));
|
||||
this._racesInfo
|
||||
.add(new Quadruple<String, String, String, Integer>(
|
||||
.add(new RacePropertiesImpl (
|
||||
"Kieler Woche 2012 - 49er Yellow - Race 1",
|
||||
"49er STG",
|
||||
"http://germanmaster.traclive.dk/events/event_20120615_KielerWoch/clientparams.php?event=event_20120615_KielerWoch&race=0b5969cc-b789-11e1-a845-406186cbf87c",
|
||||
@@ -73,10 +75,10 @@ public class ConfigurationManagerTest {
|
||||
@Test
|
||||
public void test_getBoatClassesInfo() {
|
||||
int index = 0;
|
||||
for (final Quadruple<String, Double, String, Integer> tuple : ConfigurationManager.INSTANCE.getBoatClassesInfo()) {
|
||||
Assert.assertEquals(this._boatClassesInfo.get(index).getA(), tuple.getA());
|
||||
Assert.assertEquals(this._boatClassesInfo.get(index).getB(), tuple.getB());
|
||||
Assert.assertEquals(this._boatClassesInfo.get(index).getC(), tuple.getC());
|
||||
for (final BoatClassProperties tuple : ConfigurationManager.INSTANCE.getBoatClassesInfo()) {
|
||||
Assert.assertEquals(this._boatClassesInfo.get(index).getName(), tuple.getName());
|
||||
Assert.assertEquals(this._boatClassesInfo.get(index).getLength(), tuple.getLength());
|
||||
Assert.assertEquals(this._boatClassesInfo.get(index).getPolar(), tuple.getPolar());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -84,10 +86,10 @@ public class ConfigurationManagerTest {
|
||||
@Test
|
||||
public void test_getRacesInfo() {
|
||||
int index = 0;
|
||||
for (final Quadruple<String, String, String, Integer> tuple : ConfigurationManager.INSTANCE.getRacesInfo()) {
|
||||
Assert.assertEquals(this._racesInfo.get(index).getA(), tuple.getA());
|
||||
Assert.assertEquals(this._racesInfo.get(index).getB(), tuple.getB());
|
||||
Assert.assertEquals(this._racesInfo.get(index).getC(), tuple.getC());
|
||||
for (final RaceProperties tuple : ConfigurationManager.INSTANCE.getRacesInfo()) {
|
||||
Assert.assertEquals(this._racesInfo.get(index).getName(), tuple.getName());
|
||||
Assert.assertEquals(this._racesInfo.get(index).getBoatClass(), tuple.getBoatClass());
|
||||
Assert.assertEquals(this._racesInfo.get(index).getURL(), tuple.getURL());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sap.sailing.simulator;
|
||||
|
||||
public interface BoatClassProperties {
|
||||
|
||||
String getName();
|
||||
|
||||
Double getLength();
|
||||
|
||||
String getPolar();
|
||||
|
||||
Integer getIndex();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sap.sailing.simulator;
|
||||
|
||||
public interface RaceProperties {
|
||||
|
||||
String getName();
|
||||
|
||||
String getBoatClass();
|
||||
|
||||
String getURL();
|
||||
|
||||
Integer getIndex();
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.sap.sailing.simulator.impl;
|
||||
|
||||
import com.sap.sailing.simulator.BoatClassProperties;
|
||||
|
||||
public class BoatClassPropertiesImpl implements BoatClassProperties {
|
||||
|
||||
String name;
|
||||
Double length;
|
||||
String polar;
|
||||
Integer index;
|
||||
|
||||
public BoatClassPropertiesImpl(String name, Double length, String polar, Integer index) {
|
||||
this.name = name;
|
||||
this.length = length;
|
||||
this.polar = polar;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Double getLength() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public String getPolar() {
|
||||
return this.polar;
|
||||
}
|
||||
|
||||
public Integer getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
}
|
||||
+10
-9
@@ -9,7 +9,8 @@ import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.common.impl.Util.Quadruple;
|
||||
import com.sap.sailing.simulator.BoatClassProperties;
|
||||
import com.sap.sailing.simulator.RaceProperties;
|
||||
|
||||
public enum ConfigurationManager {
|
||||
|
||||
@@ -21,8 +22,8 @@ public enum ConfigurationManager {
|
||||
private static final String CONFIG_FILE_LOCATION = "resources/STG_configuration.csv";
|
||||
private static final String RACES_FILE_LOCATION = "resources/races.csv";
|
||||
|
||||
private List<Quadruple<String, Double, String, Integer>> _boatClassesInfo = new ArrayList<Quadruple<String, Double, String, Integer>>();
|
||||
private List<Quadruple<String, String, String, Integer>> _racesInfo = new ArrayList<Quadruple<String, String, String, Integer>>();
|
||||
private List<BoatClassProperties> _boatClassesInfo = new ArrayList<BoatClassProperties>();
|
||||
private List<RaceProperties> _racesInfo = new ArrayList<RaceProperties>();
|
||||
|
||||
private ReadingConfigurationFileStatus status = ReadingConfigurationFileStatus.SUCCESS;
|
||||
private String errorMessage = "";
|
||||
@@ -72,9 +73,9 @@ public enum ConfigurationManager {
|
||||
|
||||
if (polarDiagramConfig) {
|
||||
this._boatClassesInfo
|
||||
.add(new Quadruple<String, Double, String, Integer>(elements[0], Double.parseDouble(elements[1]), elements[2], index++));
|
||||
.add(new BoatClassPropertiesImpl(elements[0], Double.parseDouble(elements[1]), elements[2], index++));
|
||||
} else {
|
||||
this._racesInfo.add(new Quadruple<String, String, String, Integer>(elements[0], elements[1], elements[2], index++));
|
||||
this._racesInfo.add(new RacePropertiesImpl(elements[0], elements[1], elements[2], index++));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +89,11 @@ public enum ConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Quadruple<String, Double, String, Integer>> getBoatClassesInfo() {
|
||||
public List<BoatClassProperties> getBoatClassesInfo() {
|
||||
return this._boatClassesInfo;
|
||||
}
|
||||
|
||||
public List<Quadruple<String, String, String, Integer>> getRacesInfo() {
|
||||
public List<RaceProperties> getRacesInfo() {
|
||||
return this._racesInfo;
|
||||
}
|
||||
|
||||
@@ -105,11 +106,11 @@ public enum ConfigurationManager {
|
||||
}
|
||||
|
||||
public String getRaceURL(int index) {
|
||||
return this._racesInfo.get(index).getC();
|
||||
return this._racesInfo.get(index).getURL();
|
||||
}
|
||||
|
||||
public String getPolarDiagramFileLocation(int index) {
|
||||
return this._boatClassesInfo.get(index).getC();
|
||||
return this._boatClassesInfo.get(index).getPolar();
|
||||
}
|
||||
|
||||
public ReadingConfigurationFileStatus getStatus() {
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.sap.sailing.simulator.impl;
|
||||
|
||||
import com.sap.sailing.simulator.RaceProperties;
|
||||
|
||||
public class RacePropertiesImpl implements RaceProperties {
|
||||
|
||||
String name;
|
||||
String boatClass;
|
||||
String url;
|
||||
Integer index;
|
||||
|
||||
public RacePropertiesImpl(String name, String boatClass, String url, Integer index) {
|
||||
this.name = name;
|
||||
this.boatClass = boatClass;
|
||||
this.url = url;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getBoatClass() {
|
||||
return this.boatClass;
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public Integer getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -13,9 +13,9 @@ import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.MeterDistance;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.Util.Quadruple;
|
||||
import com.sap.sailing.simulator.Boundary;
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.RaceProperties;
|
||||
import com.sap.sailing.simulator.SailingSimulator;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.SimulatorUISelection;
|
||||
@@ -334,8 +334,8 @@ public class SailingSimulatorImpl implements SailingSimulator {
|
||||
|
||||
List<String> racesNames = new ArrayList<String>();
|
||||
|
||||
for (Quadruple<String, String, String, Integer> raceInfo : ConfigurationManager.INSTANCE.getRacesInfo()) {
|
||||
racesNames.add(raceInfo.getA());
|
||||
for (RaceProperties raceInfo : ConfigurationManager.INSTANCE.getRacesInfo()) {
|
||||
racesNames.add(raceInfo.getName());
|
||||
}
|
||||
|
||||
return racesNames;
|
||||
|
||||
Reference in New Issue
Block a user