package com.inet.dashboard.openweathermap; import javax.annotation.Nonnull; import javax.annotation.Nullable; /** * Wrapper of the settings that is used to identify the refresh task to update the weather data */ public class WidgetSettings { private @Nonnull String apiKey; private @Nonnull String location; private @Nonnull Units units; private @Nonnull String language; /** * Creates the instance * @param apiKey the api key from openweathermap.org * @param location the location the weather should be loaded for * @param units the units of the values * @param language the client language */ public WidgetSettings( @Nonnull String apiKey, @Nonnull String location, @Nonnull Units units, @Nonnull String language ) { this.apiKey = apiKey; this.location = location; this.units = units; this.language = language; } /** * Returns the api key from openweathermap.org * @return the api key from openweathermap.org */ public String getApiKey() { return apiKey; } /** * Returns the client language * @return the client language */ public String getLanguage() { return language; } /** * Returns the location the weather should be loaded for * @return the location the weather should be loaded for */ public String getLocation() { return location; } /** * Returns the units of the values * @return the units of the values */ public Units getUnits() { return units; } /** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((language == null) ? 0 : language.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + ((units == null) ? 0 : units.hashCode()); return result; } /** * {@inheritDoc} */ @Override public boolean equals( @Nullable Object obj ) { if( this == obj ) { return true; } if( obj == null ) { return false; } if( getClass() != obj.getClass() ) { return false; } WidgetSettings other = (WidgetSettings)obj; if( !language.equals( other.language ) ) { return false; } if( !location.equals( other.location ) ) { return false; } if( units != other.units ) { return false; } return true; } }