Problème dans une enum avec case
Bonjour,
j'aimerais faire un case dans mon enum hors le type de l'enum n'etant pas un string n'est pas reconnu par mon case.
Y aurait-il un autre moyen ?
Voici le bout de code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| public enum RouteType {
DEFAULT(null),
AVOID_HIGHWAYS("highways"),
AVOID_TOLLS("tolls"),
AVOID_FERRIES("ferries"),
PUBLIC_TRANSIT("transit"),
WALKING("walking"),
BICYCLING("bicycling");
private String param;
private RouteType(String param) { this.param = param; }
public String getParam() { return param; }
public String toParam() {
switch(this.param)
{
case null:
return "";
break;
case AVOID_HIGHWAYS: case AVOID_TOLLS: case AVOID_FERRIES:
return new StringBuilder("&avoid=").append(this.param).toString();
break;
case PUBLIC_TRANSIT: case WALKING: case BICYCLING:
return new StringBuilder("&mode=").append(this.param).toString();
break;
default:
break;
}
}
} |
PS : c'est pour utiliser le web service de google maps