@Test public void GIVEN_null_wind_speed_WHEN_knots_formatting_requested_THEN_returns_blank_knots_value() { testee = new WindSpeedFormatter(null); assertEquals("--.- kts", testee.format(WindSpeedUnit.KNOTS)); }
public String format(WindSpeedUnit unit) { String formatted = null; if (windSpeed != null) { String formatString; if (unit == BEAUFORT_SCALE) { formatted = String.format(Locale.US, "%1d Bft", windSpeed.getValue(unit).intValue()); } else { if (unit == KNOTS) { formatString = "%1.1f kts"; } else if (unit == METRES_PER_SECOND) { formatString = "%1.1f m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatString = "%1.1f km/h"; } else { formatString = "%1.1f mph"; } formatted = String.format(Locale.US, formatString, windSpeed.getValue(unit).setScale(1, RoundingMode.HALF_DOWN)); } } else { if (unit == KNOTS) { formatted = "--.- kts"; } else if (unit == METRES_PER_SECOND) { formatted = "--.- m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatted = "--.- km/h"; } else if (unit == MILES_PER_HOUR) { formatted = "--.- mph"; } else if (unit == BEAUFORT_SCALE) { formatted = "-- Bft"; } } return formatted; }
WindSpeedFormatter { public String format(WindSpeedUnit unit) { String formatted = null; if (windSpeed != null) { String formatString; if (unit == BEAUFORT_SCALE) { formatted = String.format(Locale.US, "%1d Bft", windSpeed.getValue(unit).intValue()); } else { if (unit == KNOTS) { formatString = "%1.1f kts"; } else if (unit == METRES_PER_SECOND) { formatString = "%1.1f m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatString = "%1.1f km/h"; } else { formatString = "%1.1f mph"; } formatted = String.format(Locale.US, formatString, windSpeed.getValue(unit).setScale(1, RoundingMode.HALF_DOWN)); } } else { if (unit == KNOTS) { formatted = "--.- kts"; } else if (unit == METRES_PER_SECOND) { formatted = "--.- m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatted = "--.- km/h"; } else if (unit == MILES_PER_HOUR) { formatted = "--.- mph"; } else if (unit == BEAUFORT_SCALE) { formatted = "-- Bft"; } } return formatted; } }
WindSpeedFormatter { public String format(WindSpeedUnit unit) { String formatted = null; if (windSpeed != null) { String formatString; if (unit == BEAUFORT_SCALE) { formatted = String.format(Locale.US, "%1d Bft", windSpeed.getValue(unit).intValue()); } else { if (unit == KNOTS) { formatString = "%1.1f kts"; } else if (unit == METRES_PER_SECOND) { formatString = "%1.1f m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatString = "%1.1f km/h"; } else { formatString = "%1.1f mph"; } formatted = String.format(Locale.US, formatString, windSpeed.getValue(unit).setScale(1, RoundingMode.HALF_DOWN)); } } else { if (unit == KNOTS) { formatted = "--.- kts"; } else if (unit == METRES_PER_SECOND) { formatted = "--.- m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatted = "--.- km/h"; } else if (unit == MILES_PER_HOUR) { formatted = "--.- mph"; } else if (unit == BEAUFORT_SCALE) { formatted = "-- Bft"; } } return formatted; } WindSpeedFormatter(WindSpeed windSpeed); }
WindSpeedFormatter { public String format(WindSpeedUnit unit) { String formatted = null; if (windSpeed != null) { String formatString; if (unit == BEAUFORT_SCALE) { formatted = String.format(Locale.US, "%1d Bft", windSpeed.getValue(unit).intValue()); } else { if (unit == KNOTS) { formatString = "%1.1f kts"; } else if (unit == METRES_PER_SECOND) { formatString = "%1.1f m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatString = "%1.1f km/h"; } else { formatString = "%1.1f mph"; } formatted = String.format(Locale.US, formatString, windSpeed.getValue(unit).setScale(1, RoundingMode.HALF_DOWN)); } } else { if (unit == KNOTS) { formatted = "--.- kts"; } else if (unit == METRES_PER_SECOND) { formatted = "--.- m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatted = "--.- km/h"; } else if (unit == MILES_PER_HOUR) { formatted = "--.- mph"; } else if (unit == BEAUFORT_SCALE) { formatted = "-- Bft"; } } return formatted; } WindSpeedFormatter(WindSpeed windSpeed); String format(WindSpeedUnit unit); }
WindSpeedFormatter { public String format(WindSpeedUnit unit) { String formatted = null; if (windSpeed != null) { String formatString; if (unit == BEAUFORT_SCALE) { formatted = String.format(Locale.US, "%1d Bft", windSpeed.getValue(unit).intValue()); } else { if (unit == KNOTS) { formatString = "%1.1f kts"; } else if (unit == METRES_PER_SECOND) { formatString = "%1.1f m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatString = "%1.1f km/h"; } else { formatString = "%1.1f mph"; } formatted = String.format(Locale.US, formatString, windSpeed.getValue(unit).setScale(1, RoundingMode.HALF_DOWN)); } } else { if (unit == KNOTS) { formatted = "--.- kts"; } else if (unit == METRES_PER_SECOND) { formatted = "--.- m/s"; } else if (unit == KILOMETRES_PER_HOUR) { formatted = "--.- km/h"; } else if (unit == MILES_PER_HOUR) { formatted = "--.- mph"; } else if (unit == BEAUFORT_SCALE) { formatted = "-- Bft"; } } return formatted; } WindSpeedFormatter(WindSpeed windSpeed); String format(WindSpeedUnit unit);  }