Currently trying to get an ArrayList of a Java Object from the MutableData in a Firebase Realtime Database. However, I am receiving null and I'm unsure on if I am passing the class argument properly. I'm currently using the class argument as ArrayList.class but I don't think it will be able to handle the custom java objects within it.
public Transaction.Result doTransaction(MutableData mutableData) {
ArrayList<Friend> friends = mutableData.getValue(ArrayList.class);
if (friends != null) {
User.getInstance().setFriendList(friends);
return Transaction.success(mutableData);
} else {
Log.e("DAO", "Failed to load user friends list.");
User.getInstance().setFriendList(new ArrayList<>());
return Transaction.abort();
}
}
This is the Friend pojo:
public class Friend {
public Friend(String displayName, String uid){
this.name = displayName;
this.uid = uid;
}
private String name;
public String getUID() {
return uid;
}
public void setUID(String uid) {
this.uid = uid;
}
private String uid;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}