@Test(expected = AssertionError.class) public void testTranslate() throws Exception { new UnitOfMeasureTranslator("Not.A.Unit.Of.Measure").translate(); }
@Override public UnitOfMeasure translate() { if (this.unitOfMeasure == null || this.unitOfMeasure.isEmpty()) { return UnitOfMeasure.WATT_HOUR; } UnitOfMeasure result; switch (this.unitOfMeasure) { case "Wh": result = UnitOfMeasure.WATT_HOUR; break; case "kWh": result = UnitOfMeasure.KILOWATT_HOUR; break; case "varh": result = UnitOfMeasure.VAR_HOUR; break; case "kvarh": result = UnitOfMeasure.KILOVAR_HOUR; break; case "W": result = UnitOfMeasure.WATT; break; case "kW": result = UnitOfMeasure.KILOWATT; break; case "var": result = UnitOfMeasure.VAR; break; case "kvar": result = UnitOfMeasure.KILOVAR; break; case "Amp": result = UnitOfMeasure.AMPERES; break; case "Volt": result = UnitOfMeasure.VOLTAGE; break; case "Celsius": result = UnitOfMeasure.CELSIUS; break; default: throw new AssertionError(String.format("Unknown value for UnitOfMeasure: '%s'", this.unitOfMeasure)); } return result; }
UnitOfMeasureTranslator implements Translator<UnitOfMeasure> { @Override public UnitOfMeasure translate() { if (this.unitOfMeasure == null || this.unitOfMeasure.isEmpty()) { return UnitOfMeasure.WATT_HOUR; } UnitOfMeasure result; switch (this.unitOfMeasure) { case "Wh": result = UnitOfMeasure.WATT_HOUR; break; case "kWh": result = UnitOfMeasure.KILOWATT_HOUR; break; case "varh": result = UnitOfMeasure.VAR_HOUR; break; case "kvarh": result = UnitOfMeasure.KILOVAR_HOUR; break; case "W": result = UnitOfMeasure.WATT; break; case "kW": result = UnitOfMeasure.KILOWATT; break; case "var": result = UnitOfMeasure.VAR; break; case "kvar": result = UnitOfMeasure.KILOVAR; break; case "Amp": result = UnitOfMeasure.AMPERES; break; case "Volt": result = UnitOfMeasure.VOLTAGE; break; case "Celsius": result = UnitOfMeasure.CELSIUS; break; default: throw new AssertionError(String.format("Unknown value for UnitOfMeasure: '%s'", this.unitOfMeasure)); } return result; } }
UnitOfMeasureTranslator implements Translator<UnitOfMeasure> { @Override public UnitOfMeasure translate() { if (this.unitOfMeasure == null || this.unitOfMeasure.isEmpty()) { return UnitOfMeasure.WATT_HOUR; } UnitOfMeasure result; switch (this.unitOfMeasure) { case "Wh": result = UnitOfMeasure.WATT_HOUR; break; case "kWh": result = UnitOfMeasure.KILOWATT_HOUR; break; case "varh": result = UnitOfMeasure.VAR_HOUR; break; case "kvarh": result = UnitOfMeasure.KILOVAR_HOUR; break; case "W": result = UnitOfMeasure.WATT; break; case "kW": result = UnitOfMeasure.KILOWATT; break; case "var": result = UnitOfMeasure.VAR; break; case "kvar": result = UnitOfMeasure.KILOVAR; break; case "Amp": result = UnitOfMeasure.AMPERES; break; case "Volt": result = UnitOfMeasure.VOLTAGE; break; case "Celsius": result = UnitOfMeasure.CELSIUS; break; default: throw new AssertionError(String.format("Unknown value for UnitOfMeasure: '%s'", this.unitOfMeasure)); } return result; } UnitOfMeasureTranslator(String unitOfMeasure); }
UnitOfMeasureTranslator implements Translator<UnitOfMeasure> { @Override public UnitOfMeasure translate() { if (this.unitOfMeasure == null || this.unitOfMeasure.isEmpty()) { return UnitOfMeasure.WATT_HOUR; } UnitOfMeasure result; switch (this.unitOfMeasure) { case "Wh": result = UnitOfMeasure.WATT_HOUR; break; case "kWh": result = UnitOfMeasure.KILOWATT_HOUR; break; case "varh": result = UnitOfMeasure.VAR_HOUR; break; case "kvarh": result = UnitOfMeasure.KILOVAR_HOUR; break; case "W": result = UnitOfMeasure.WATT; break; case "kW": result = UnitOfMeasure.KILOWATT; break; case "var": result = UnitOfMeasure.VAR; break; case "kvar": result = UnitOfMeasure.KILOVAR; break; case "Amp": result = UnitOfMeasure.AMPERES; break; case "Volt": result = UnitOfMeasure.VOLTAGE; break; case "Celsius": result = UnitOfMeasure.CELSIUS; break; default: throw new AssertionError(String.format("Unknown value for UnitOfMeasure: '%s'", this.unitOfMeasure)); } return result; } UnitOfMeasureTranslator(String unitOfMeasure); @Override UnitOfMeasure translate(); }
UnitOfMeasureTranslator implements Translator<UnitOfMeasure> { @Override public UnitOfMeasure translate() { if (this.unitOfMeasure == null || this.unitOfMeasure.isEmpty()) { return UnitOfMeasure.WATT_HOUR; } UnitOfMeasure result; switch (this.unitOfMeasure) { case "Wh": result = UnitOfMeasure.WATT_HOUR; break; case "kWh": result = UnitOfMeasure.KILOWATT_HOUR; break; case "varh": result = UnitOfMeasure.VAR_HOUR; break; case "kvarh": result = UnitOfMeasure.KILOVAR_HOUR; break; case "W": result = UnitOfMeasure.WATT; break; case "kW": result = UnitOfMeasure.KILOWATT; break; case "var": result = UnitOfMeasure.VAR; break; case "kvar": result = UnitOfMeasure.KILOVAR; break; case "Amp": result = UnitOfMeasure.AMPERES; break; case "Volt": result = UnitOfMeasure.VOLTAGE; break; case "Celsius": result = UnitOfMeasure.CELSIUS; break; default: throw new AssertionError(String.format("Unknown value for UnitOfMeasure: '%s'", this.unitOfMeasure)); } return result; } UnitOfMeasureTranslator(String unitOfMeasure); @Override UnitOfMeasure translate();  }