toObject() method is throwing IllegalArgumentException when passing custom class reference

Viewed 48

I have this web service method implementation, getAllPlays(), where I am trying to get all the documents I have in a collection in firestore. Using google-cloud-firestore-2.1.0.jar:2.1.0

I have another endpoint in this service that is getting all the documents from a different collection I have in firestore. That endpoint is using the same implementation that I have for getAllPlays(). But that endpoint is not giving me any issues when hitting that endpoint.

Here is the error:

java.lang.IllegalArgumentException: null

Here is the implementation:

public List<DocumentForPlaysDb> getAllPlays() throws ExecutionException, InterruptedException {
    Map<String, Plays> playsMap;
    List<DocumentForPlaysDb> documents;
    playsMap = db.collection(this.collections.getPlays()).get().get().getDocuments().stream()
            .collect(Collectors.toMap(QueryDocumentSnapshot::getId, queryDocumentSnapshot -> queryDocumentSnapshot.toObject()));
    documents = this.playbookDtoConverterService.fromDtoPlays(playsMap);
    return documents;
}

Here are all the classes I have for representing that data in firestore:

package com.src.game.football.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class DocumentForPlaysDb extends Plays {
    private String documentId;

    public boolean getIsSelected() {
        return isSelected;
    }

    public void setIsSelected(boolean selectValue) {
        isSelected = selectValue;
    }

    public boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(boolean selectValue) {
        isActive = selectValue;
    }

    public boolean getIsTackled() {
        return isTackled;
    }

    public void setIsTackled(boolean selectValue) {
        isTackled = selectValue;
    }
}
package com.src.game.football.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.googlecode.jmapper.annotations.JMap;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@EqualsAndHashCode(callSuper = true)
public class Plays extends PlayData {

    @JMap
    @JsonProperty
    private String formation;

    @JMap
    @JsonProperty
    public boolean isSelected;

    @JMap
    @JsonProperty
    private String name;

    @JMap
    @JsonProperty
    private PlayData playData;

    public boolean getIsSelected() {
        return isSelected;
    }

    public void setIsSelected(boolean selectValue) {
        isSelected = selectValue;
    }

    public boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(boolean selectValue) {
        isActive = selectValue;
    }

    public boolean getIsTackled() {
        return isTackled;
    }

    public void setIsTackled(boolean selectValue) {
        isTackled = selectValue;
    }

}
package com.src.game.football.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.googlecode.jmapper.annotations.JMap;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@EqualsAndHashCode(callSuper = true)
public class PlayData extends PlayerPosition {

    @JMap
    @JsonProperty
    private PlayerPosition offensiveLine;

    @JMap
    @JsonProperty
    private PlayerPosition quarterback;

    @JMap
    @JsonProperty
    private PlayerPosition runningBack;

    @JMap
    @JsonProperty
    private PlayerPosition tightEnd;

    @JMap
    @JsonProperty
    private PlayerPosition wideReceiver;

    public boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(boolean selectValue) {
        isActive = selectValue;
    }

    public boolean getIsTackled() {
        return isTackled;
    }

    public void setIsTackled(boolean selectValue) {
        isTackled = selectValue;
    }
}
package com.src.game.football.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.googlecode.jmapper.annotations.JMap;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class PlayerPosition {

    @JMap
    @JsonProperty
    public boolean isActive;

    @JMap
    @JsonProperty
    public boolean isTackled;

    @JMap
    @JsonProperty
    private String movement;

    @JMap
    @JsonProperty
    private int startingPositionX;

    @JMap
    @JsonProperty
    private int startingPositionY;

    public boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(boolean selectValue) {
        isActive = selectValue;
    }

    public boolean getIsTackled() {
        return isTackled;
    }

    public void setIsTackled(boolean selectValue) {
        isTackled = selectValue;
    }

}

I have done a lot of debugging here and can't seem to find the issue. Any help here would be greatly appreciated.

0 Answers
Related