Trying to create the develop method
This commit is contained in:
parent
e6f0dc3029
commit
58d29974f5
@ -24,6 +24,11 @@ public interface ICityService
|
||||
*/
|
||||
void addCity(City cityToAdd);
|
||||
|
||||
/**
|
||||
* Updating the fields of a specific city
|
||||
*/
|
||||
void updateCity(City cityToUpdate);
|
||||
|
||||
/**
|
||||
* Get all cities sorted by name
|
||||
* @return {@link List}
|
||||
|
||||
@ -30,7 +30,7 @@ final public class City implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* The primary key of the city in our datbase which is automatically incremented
|
||||
* The primary key of the city in our database which is automatically incremented
|
||||
*/
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
public int id;
|
||||
@ -40,16 +40,21 @@ final public class City implements Serializable
|
||||
*/
|
||||
@NonNull
|
||||
public String nameCity;
|
||||
|
||||
@Nullable
|
||||
public String w_icon;
|
||||
public String w_icon = null;
|
||||
|
||||
@Nullable
|
||||
public String w_temp;
|
||||
public String w_temp = null;
|
||||
|
||||
@Nullable
|
||||
public String w_feelsliketemp;
|
||||
public String w_feelsliketemp = null;
|
||||
|
||||
@Nullable
|
||||
public String w_mintemp;
|
||||
public String w_mintemp = null;
|
||||
|
||||
@Nullable
|
||||
public String w_maxtemp;
|
||||
public String w_maxtemp = null;
|
||||
|
||||
/**
|
||||
* Constructor of the city class
|
||||
@ -61,6 +66,26 @@ final public class City implements Serializable
|
||||
this.nameCity = nameCity;
|
||||
}
|
||||
|
||||
public void setW_icon(@Nullable String w_icon) {
|
||||
this.w_icon = w_icon;
|
||||
}
|
||||
|
||||
public void setW_temp(@Nullable String w_temp) {
|
||||
this.w_temp = w_temp;
|
||||
}
|
||||
|
||||
public void setW_feelsliketemp(@Nullable String w_feelsliketemp) {
|
||||
this.w_feelsliketemp = w_feelsliketemp;
|
||||
}
|
||||
|
||||
public void setW_mintemp(@Nullable String w_mintemp) {
|
||||
this.w_mintemp = w_mintemp;
|
||||
}
|
||||
|
||||
public void setW_maxtemp(@Nullable String w_maxtemp) {
|
||||
this.w_maxtemp = w_maxtemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equals function that return true or false weither both name are same and both object belongs to City class
|
||||
* @param o The object to compare
|
||||
@ -68,26 +93,20 @@ final public class City implements Serializable
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
City city1 = (City) o;
|
||||
|
||||
return nameCity.equals(city1.nameCity);
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
City city = (City) o;
|
||||
return id == city.id &&
|
||||
nameCity.equals(city.nameCity) &&
|
||||
Objects.equals(w_icon, city.w_icon) &&
|
||||
Objects.equals(w_temp, city.w_temp) &&
|
||||
Objects.equals(w_feelsliketemp, city.w_feelsliketemp) &&
|
||||
Objects.equals(w_mintemp, city.w_mintemp) &&
|
||||
Objects.equals(w_maxtemp, city.w_maxtemp);
|
||||
}
|
||||
|
||||
/**
|
||||
* hashCode function
|
||||
* @return Clé de hashage (int)
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(nameCity);
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, nameCity, w_icon, w_temp, w_feelsliketemp, w_mintemp, w_maxtemp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import fr.romanet.vj.apps.myweather.ICityService;
|
||||
import fr.romanet.vj.apps.myweather.bo.City;
|
||||
import java.util.List;
|
||||
@ -24,7 +26,11 @@ public interface CityDao extends ICityService
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void addCity(City cityToAdd);
|
||||
|
||||
@Update
|
||||
void updateCity(City cityToUpdate);
|
||||
|
||||
@Override
|
||||
@Query("SELECT * FROM City ORDER BY nameCity DESC")
|
||||
List<City> sortCityByName();
|
||||
|
||||
}
|
||||
|
||||
@ -48,6 +48,8 @@ public final class CityRepository
|
||||
cityDatabase.cityDao().addCity(cityToAdd);
|
||||
}
|
||||
|
||||
public void updateCity(City cityToUpdate) {cityDatabase.cityDao().updateCity(cityToUpdate);}
|
||||
|
||||
public List<City> sortCityByName()
|
||||
{
|
||||
return cityDatabase.cityDao().sortCityByName();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user