Skip to content

Commit

Permalink
Update javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaytotomato committed Aug 9, 2024
1 parent e54ee1f commit 8a852d9
Show file tree
Hide file tree
Showing 18 changed files with 979 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Map;

/**
* Allows adding custom aliases for Country, State and City
* Allows adding custom aliases for countries, states and cities
*/
public interface LocationAliases {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
import com.tomaytotomato.model.Country;
import java.util.List;

/**
* Loads countries from the location4j.jar and provides it to any classes that need it.
*/
public interface CountriesDataLoader {

/**
* Returns a list of {@link Country} after loading them from disk
* @return list of countries
*/
List<Country> getCountries();

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

/**
* The default loader for retrieving Countries from the DEFAULT_FILE located in the location4j.jar
*
*/
public class DefaultCountriesDataLoaderImpl implements CountriesDataLoader {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.tomaytotomato.model.Location;
import com.tomaytotomato.model.State;

/**
* Converts {@link Country}, {@link State} and {@link City} objects into {@link Location} objects
*/
public interface LocationMapper {

Location toLocation(Country country);
Expand Down
132 changes: 131 additions & 1 deletion library/src/main/java/com/tomaytotomato/model/City.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.tomaytotomato.model;


import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
* Represents a city with various attributes such as name, state, and country.
* <p>
* This class provides methods to access city details including geographic coordinates,
* country and state associations, and other identifiers.
* </p>
*/
public class City implements Serializable {

private static final long serialVersionUID = 1L;
Expand All @@ -21,96 +27,215 @@ public class City implements Serializable {
private BigDecimal latitude;
private BigDecimal longitude;

/**
* Default constructor for City.
*/
City() {}

/**
* Gets the unique identifier of the city.
*
* @return the city's unique ID
*/
public Integer getId() {
return id;
}

/**
* Sets the unique identifier of the city.
*
* @param id the unique ID to set for the city
*/
public void setId(Integer id) {
this.id = id;
}

/**
* Gets the unique identifier of the country associated with the city.
*
* @return the country's unique ID
*/
public Integer getCountryId() {
return countryId;
}

/**
* Sets the unique identifier of the country associated with the city.
*
* @param countryId the unique ID to set for the country
*/
public void setCountryId(Integer countryId) {
this.countryId = countryId;
}

/**
* Gets the name of the country associated with the city.
*
* @return the country's name
*/
public String getCountryName() {
return countryName;
}

/**
* Sets the name of the country associated with the city.
*
* @param countryName the name to set for the country
*/
public void setCountryName(String countryName) {
this.countryName = countryName;
}

/**
* Gets the ISO 3166-1 alpha-2 code of the country associated with the city.
*
* @return the country's ISO2 code
*/
public String getCountryIso2Code() {
return countryIso2Code;
}

/**
* Sets the ISO 3166-1 alpha-2 code of the country associated with the city.
*
* @param countryIso2Code the ISO2 code to set for the country
*/
public void setCountryIso2Code(String countryIso2Code) {
this.countryIso2Code = countryIso2Code;
}

/**
* Gets the ISO 3166-1 alpha-3 code of the country associated with the city.
*
* @return the country's ISO3 code
*/
public String getCountryIso3Code() {
return countryIso3Code;
}

/**
* Sets the ISO 3166-1 alpha-3 code of the country associated with the city.
*
* @param countryIso3Code the ISO3 code to set for the country
*/
public void setCountryIso3Code(String countryIso3Code) {
this.countryIso3Code = countryIso3Code;
}

/**
* Gets the unique identifier of the state associated with the city.
*
* @return the state's unique ID
*/
public Integer getStateId() {
return stateId;
}

/**
* Sets the unique identifier of the state associated with the city.
*
* @param stateId the unique ID to set for the state
*/
public void setStateId(Integer stateId) {
this.stateId = stateId;
}

/**
* Gets the code of the state associated with the city.
*
* @return the state's code
*/
public String getStateCode() {
return stateCode;
}

/**
* Sets the code of the state associated with the city.
*
* @param stateCode the code to set for the state
*/
public void setStateCode(String stateCode) {
this.stateCode = stateCode;
}

/**
* Gets the name of the state associated with the city.
*
* @return the state's name
*/
public String getStateName() {
return stateName;
}

/**
* Sets the name of the state associated with the city.
*
* @param stateName the name to set for the state
*/
public void setStateName(String stateName) {
this.stateName = stateName;
}

/**
* Gets the name of the city.
*
* @return the name of the city
*/
public String getName() {
return name;
}

/**
* Sets the name of the city.
*
* @param name the name to set for the city
*/
public void setName(String name) {
this.name = name;
}

/**
* Gets the latitude of the city.
*
* @return the city's latitude
*/
public BigDecimal getLatitude() {
return latitude;
}

/**
* Sets the latitude of the city.
*
* @param latitude the latitude to set for the city
*/
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}

/**
* Gets the longitude of the city.
*
* @return the city's longitude
*/
public BigDecimal getLongitude() {
return longitude;
}

/**
* Sets the longitude of the city.
*
* @param longitude the longitude to set for the city
*/
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}

/**
* Checks whether two city objects are equal based on their attributes.
*
* @param o the object to compare with
* @return true if the objects are equal, false otherwise
*/
@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -131,6 +256,11 @@ public boolean equals(Object o) {
getLongitude(), city.getLongitude());
}

/**
* Computes the hash code for the city object based on its attributes.
*
* @return the hash code of the city
*/
@Override
public int hashCode() {
return Objects.hash(getId(), getCountryId(), getCountryName(), getCountryIso2Code(),
Expand Down
Loading

0 comments on commit 8a852d9

Please sign in to comment.