class CarDto {
    public final String color;
    public final String ownerName;
    public final Integer ownerAge;
    public final String ownerCity;

    public CarDto(Car car) {
        this.color = car.getColor();
        Owner owner = car.getOwner();
        if (owner != null) {
            this.ownerName = owner.getName();
            this.ownerAge = owner.getAge();
            if (owner.getAddress() != null) {
                this.ownerCity = owner.getAddress().getCity();
            }
        }
    }
}