Skip to content

Instantly share code, notes, and snippets.

@jeje
Created July 24, 2014 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeje/ed94e0084ce1c935d11a to your computer and use it in GitHub Desktop.
Save jeje/ed94e0084ce1c935d11a to your computer and use it in GitHub Desktop.
public class WeatherRequest {
private LocationType locationType;
private Float[] coordinates;
private String zipCode;
private String city;
private String state;
private String country;
private Locale locale;
public WeatherRequest forCoordinates(Float coordinateX, Float coordinateY) {
this.coordinates = new Float[]{coordinateX, coordinateY};
this.locationType = LocationType.COORDINATES;
return this;
}
public WeatherRequest forZipCode(String zipCode) {
this.zipCode = zipCode;
this.locationType = LocationType.ZIPCODE;
return this;
}
public WeatherRequest forCityInState(String city, String state) {
this.city = city;
this.state = state;
this.locationType = LocationType.CITY_STATE;
return this;
}
public WeatherRequest forCityInCountry(String city, String country) {
this.city = city;
this.country = country;
this.locationType = LocationType.CITY_COUNTRY;
return this;
}
public WeatherRequest forLocalIP() {
this.locationType = LocationType.AUTO_IP;
return this;
}
public WeatherRequest withLocale(Locale locale) {
this.locale = locale;
return this;
}
public LocationType getLocationType() {
return locationType;
}
public Float[] getCoordinates() {
return coordinates;
}
public String getZipCode() {
return zipCode;
}
public String getCity() {
return city;
}
public String getState() {
return state;
}
public String getCountry() {
return country;
}
public Locale getLocale() {
return locale;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment