有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Firebase无默认构造函数反序列化

我正在使用firebase和GeoFire,但我很难弄清楚如何反序列化GeoLocation类

我的结构如下: -根->;用户->;地址->;地址键->;地理定位

问题是地理定位没有默认构造函数,只有一个接收lat/long坐标

地理位置:

public final class GeoLocation {

    /** The latitude of this location in the range of [-90, 90] */
    public final double latitude;

    /** The longitude of this location in the range of [-180, 180] */
    public final double longitude;

    /**
     * Creates a new GeoLocation with the given latitude and longitude.
     *
     * @throws java.lang.IllegalArgumentException If the coordinates are not valid geo coordinates
     * @param latitude The latitude in the range of [-90, 90]
     * @param longitude The longitude in the range of [-180, 180]
     */
    public GeoLocation(double latitude, double longitude) {
        if (!GeoLocation.coordinatesValid(latitude, longitude)) {
            throw new IllegalArgumentException("Not a valid geo location: " + latitude + ", " + longitude);
        }
        this.latitude = latitude;
        this.longitude = longitude;
    }

地址:

public class Address {
    @ParcelPropertyConverter(GeoLocationParcelConverter.class)
    GeoLocation geoLocation;
}

以及要反序列化的根类:

public class User {
    String uid;
    String name;
    String email;
    String profilePic;
    String profileBgPic;
    String about;
    boolean verified;
    float rating;
    Date birthday;
    String gender;
    List<Tag> specialities;
    HashMap<String, Address> addresses;

enter image description here

我查过了Best way to retrieve/format data using Firebase Java APIJackson 3rd Party Class With No Default Constructor。 但我不知道如何让Firebase和杰克逊一起创造一个反序列化器

错误是:

Class com.firebase.geofire.GeoLocation is missing a constructor with no arguments

谢谢


共 (0) 个答案