The listing should be open to the outside world:
public class Vehicle {
private String id;
private String name;
public enum Color {
RED, GREEN, ANY;
};
private Color color;
public Color getColor(){
return color;
}
public void setColor(Color color){
this.color = color;
}
}
Then from the package side you can do:
vehicle.setColor(Vehicle.Color.GREEN);
if you only need to use Vehicle.Color inside the same package as Vehicleyou can remove publicfrom the ad enum.
source
share