private FuelType parseFuelType(String fuelType) { if(fuelType.equals(FuelType.diesel.toString())){ return FuelType.diesel; } else if(fuelType.equals(FuelType.electricity.toString())){ return FuelType.electricity; } else if(fuelType.equals(FuelType.gasoline.toString())){ return FuelType.gasoline; } throw new IllegalStateException("fuelType " + fuelType + " is not supported"); }
private FuelType parseFuelType(String fuelType) { if(fuelType.equals(FuelType.diesel.toString())){ return FuelType.diesel; } else if(fuelType.equals(FuelType.electricity.toString())){ return FuelType.electricity; } else if(fuelType.equals(FuelType.gasoline.toString())){ return FuelType.gasoline; } throw new IllegalStateException("fuelType " + fuelType + " is not supported"); }
private FuelType parseFuelType(final String content) { if (FuelType.gasoline.toString().equalsIgnoreCase(content)){ return FuelType.gasoline; } else if (FuelType.diesel.toString().equalsIgnoreCase(content)){ return FuelType.diesel; } else if (FuelType.electricity.toString().equalsIgnoreCase(content)){ return FuelType.electricity; } else if (FuelType.biodiesel.toString().equalsIgnoreCase(content)){ return FuelType.biodiesel; } else { throw new IllegalArgumentException("Fuel type: " + content + " is not supported!"); } }
private void writeTypes(BufferedWriter writer)throws IOException { writer.write("\t<vehicleTypes>\n"); for(CarrierVehicleType type : vehicleTypes.getVehicleTypes().values()){ writer.write("\t\t<vehicleType id=\"" + type.getId() + "\">\n"); writer.write("\t\t\t<description>" + type.getDescription() + "</description>\n"); EngineInformation engineInformation = type.getEngineInformation(); if(engineInformation != null) writer.write("\t\t\t<engineInformation fuelType=\"" + engineInformation.getFuelType().toString() + "\" gasConsumption=\"" + engineInformation.getGasConsumption() + "\"/>\n"); writer.write("\t\t\t<capacity>" + type.getCarrierVehicleCapacity() + "</capacity>\n"); VehicleCostInformation vehicleCostInformation = type.getVehicleCostInformation(); if(vehicleCostInformation == null) throw new IllegalStateException("vehicleCostInformation is missing."); writer.write("\t\t\t<costInformation fix=\"" + vehicleCostInformation.fix + "\" perMeter=\"" + vehicleCostInformation.perDistanceUnit + "\" perSecond=\"" + vehicleCostInformation.perTimeUnit + "\"/>\n"); writer.write("\t\t</vehicleType>\n"); } writer.write("\t</vehicleTypes>\n\n"); }
private void writeEngineInformation(EngineInformation ei) throws UncheckedIOException { this.writeStartTag(VehicleSchemaV1Names.ENGINEINFORMATION, null); this.writeStartTag(VehicleSchemaV1Names.FUELTYPE, null); this.writeContent(ei.getFuelType().toString(), false); this.writeEndTag(VehicleSchemaV1Names.FUELTYPE); atts.clear(); atts.add(this.createTuple(VehicleSchemaV1Names.LITERPERMETER, Double.toString(ei.getGasConsumption()))); this.writeStartTag(VehicleSchemaV1Names.GASCONSUMPTION, atts, true); this.writeEndTag(VehicleSchemaV1Names.ENGINEINFORMATION); }