Unused DTOs and transformation services were removed to clean up the codebase and reduce clutter. Added new utility exceptions and DTOs, including `NotFoundException`, `ReferencedException`, and `LocationDTO`, to improve error handling and code organization.
81 lines
No EOL
2.3 KiB
Java
81 lines
No EOL
2.3 KiB
Java
package de.avatic.lcc.dto.generic;
|
|
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* Represents a geographical location with latitude and longitude.
|
|
* This immutable DTO (Data Transfer Object) is used to transfer location data across system layers.
|
|
*/
|
|
public class LocationDTO {
|
|
|
|
/**
|
|
* The latitude of the location.
|
|
* Positive values indicate north and negative values indicate south.
|
|
*/
|
|
private final double latitude;
|
|
|
|
/**
|
|
* The longitude of the location.
|
|
* Positive values indicate east and negative values indicate west.
|
|
*/
|
|
private final double longitude;
|
|
|
|
/**
|
|
* Constructs a new {@code LocationDTO} with the specified latitude and longitude.
|
|
*
|
|
* @param latitude the latitude of the location, where north is positive and south is negative
|
|
* @param longitude the longitude of the location, where east is positive and west is negative
|
|
*/
|
|
public LocationDTO(double latitude, double longitude) {
|
|
this.latitude = latitude;
|
|
this.longitude = longitude;
|
|
}
|
|
|
|
/**
|
|
* Default constructor for creating a {@code LocationDTO} at origin (0,0).
|
|
* Required for frameworks that use default constructors.
|
|
*/
|
|
public LocationDTO() {
|
|
this(0.0, 0.0);
|
|
}
|
|
|
|
/**
|
|
* Gets the latitude of the location.
|
|
*
|
|
* @return the latitude, where positive values indicate north and negative values indicate south
|
|
*/
|
|
public double getLatitude() {
|
|
return latitude;
|
|
}
|
|
|
|
/**
|
|
* Gets the longitude of the location.
|
|
*
|
|
* @return the longitude, where positive values indicate east and negative values indicate west
|
|
*/
|
|
public double getLongitude() {
|
|
return longitude;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
LocationDTO that = (LocationDTO) o;
|
|
return Double.compare(that.latitude, latitude) == 0 &&
|
|
Double.compare(that.longitude, longitude) == 0;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(latitude, longitude);
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "LocationDTO{" +
|
|
"latitude=" + latitude +
|
|
", longitude=" + longitude +
|
|
'}';
|
|
}
|
|
} |