Boolean not appearing in Firestore object












0














I have a Firebase Collection that keeps track of a user's message threads by storing objects called MessageThreads as documents. Here are that object's class/constructors:



public class MessageThread {
private String partnerName;
private String partnerID;
private String threadID;
private Message lastMessage;
private boolean notificationsOn;


public MessageThread() {

}


public MessageThread(String partnerName, String partnerID, String threadID, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.notificationsOn = notificationsOn;
}


public MessageThread(String partnerName, String partnerID, String threadID, Message lastMessage, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.lastMessage = lastMessage;
this.notificationsOn = notificationsOn;
}

public String getPartnerID() {
return partnerID;
}

public void setPartnerID(String partnerID) {
this.partnerID = partnerID;
}

public String getThreadID() {
return threadID;
}

public void setThreadID(String threadID) {
this.threadID = threadID;
}

public boolean areNotificationsOn() {
return notificationsOn;
}

public void setNotificationsOn(boolean notificationsOn) {
this.notificationsOn = notificationsOn;
}

public String getPartnerName() {
return partnerName;
}

public void setPartnerName(String user1) {
this.partnerName = user1;
}


public Message getLastMessage() {
return lastMessage;
}

public void setLastMessage(Message lastMessage) {
this.lastMessage = lastMessage;
}

}


When the messaging activity is launched for a new thread, the notificationsOn boolean is set to true and a Thread object is created using the second (4 argument) constructor:



 private void getSetThreadDetails(final String convoID) {

final DocumentReference threadReference = mFirestore.collection("users").document(mSignedInUserID).collection("threads").document(convoID);


threadReference.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot snapshot = task.getResult();

if (!snapshot.exists()) {
notificationsOn = true;
Log.d(TAG,"notifications when thread details set: " +String.valueOf(notificationsOn));
MessageThread newMessageThread = new MessageThread(mPartnerName, mPartnerID, convoID, notificationsOn);
threadReference.set(newMessageThread);

}



}
}
});


}


However, in Firebase, the stored MessageThread is not showing an entry for notificationsOn even as it is set to true right before being sent to Firebase. Where does it go?










share|improve this question
























  • Is that your entire MessageThread object? If so, I would expect nothing to be stored, since all your member variables are private. If you have getters and setters, please edit the question to show them.
    – Doug Stevenson
    Nov 20 at 22:45










  • Removed them for brevity. Edited them back in.
    – aedgar777
    Nov 20 at 23:05
















0














I have a Firebase Collection that keeps track of a user's message threads by storing objects called MessageThreads as documents. Here are that object's class/constructors:



public class MessageThread {
private String partnerName;
private String partnerID;
private String threadID;
private Message lastMessage;
private boolean notificationsOn;


public MessageThread() {

}


public MessageThread(String partnerName, String partnerID, String threadID, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.notificationsOn = notificationsOn;
}


public MessageThread(String partnerName, String partnerID, String threadID, Message lastMessage, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.lastMessage = lastMessage;
this.notificationsOn = notificationsOn;
}

public String getPartnerID() {
return partnerID;
}

public void setPartnerID(String partnerID) {
this.partnerID = partnerID;
}

public String getThreadID() {
return threadID;
}

public void setThreadID(String threadID) {
this.threadID = threadID;
}

public boolean areNotificationsOn() {
return notificationsOn;
}

public void setNotificationsOn(boolean notificationsOn) {
this.notificationsOn = notificationsOn;
}

public String getPartnerName() {
return partnerName;
}

public void setPartnerName(String user1) {
this.partnerName = user1;
}


public Message getLastMessage() {
return lastMessage;
}

public void setLastMessage(Message lastMessage) {
this.lastMessage = lastMessage;
}

}


When the messaging activity is launched for a new thread, the notificationsOn boolean is set to true and a Thread object is created using the second (4 argument) constructor:



 private void getSetThreadDetails(final String convoID) {

final DocumentReference threadReference = mFirestore.collection("users").document(mSignedInUserID).collection("threads").document(convoID);


threadReference.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot snapshot = task.getResult();

if (!snapshot.exists()) {
notificationsOn = true;
Log.d(TAG,"notifications when thread details set: " +String.valueOf(notificationsOn));
MessageThread newMessageThread = new MessageThread(mPartnerName, mPartnerID, convoID, notificationsOn);
threadReference.set(newMessageThread);

}



}
}
});


}


However, in Firebase, the stored MessageThread is not showing an entry for notificationsOn even as it is set to true right before being sent to Firebase. Where does it go?










share|improve this question
























  • Is that your entire MessageThread object? If so, I would expect nothing to be stored, since all your member variables are private. If you have getters and setters, please edit the question to show them.
    – Doug Stevenson
    Nov 20 at 22:45










  • Removed them for brevity. Edited them back in.
    – aedgar777
    Nov 20 at 23:05














0












0








0







I have a Firebase Collection that keeps track of a user's message threads by storing objects called MessageThreads as documents. Here are that object's class/constructors:



public class MessageThread {
private String partnerName;
private String partnerID;
private String threadID;
private Message lastMessage;
private boolean notificationsOn;


public MessageThread() {

}


public MessageThread(String partnerName, String partnerID, String threadID, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.notificationsOn = notificationsOn;
}


public MessageThread(String partnerName, String partnerID, String threadID, Message lastMessage, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.lastMessage = lastMessage;
this.notificationsOn = notificationsOn;
}

public String getPartnerID() {
return partnerID;
}

public void setPartnerID(String partnerID) {
this.partnerID = partnerID;
}

public String getThreadID() {
return threadID;
}

public void setThreadID(String threadID) {
this.threadID = threadID;
}

public boolean areNotificationsOn() {
return notificationsOn;
}

public void setNotificationsOn(boolean notificationsOn) {
this.notificationsOn = notificationsOn;
}

public String getPartnerName() {
return partnerName;
}

public void setPartnerName(String user1) {
this.partnerName = user1;
}


public Message getLastMessage() {
return lastMessage;
}

public void setLastMessage(Message lastMessage) {
this.lastMessage = lastMessage;
}

}


When the messaging activity is launched for a new thread, the notificationsOn boolean is set to true and a Thread object is created using the second (4 argument) constructor:



 private void getSetThreadDetails(final String convoID) {

final DocumentReference threadReference = mFirestore.collection("users").document(mSignedInUserID).collection("threads").document(convoID);


threadReference.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot snapshot = task.getResult();

if (!snapshot.exists()) {
notificationsOn = true;
Log.d(TAG,"notifications when thread details set: " +String.valueOf(notificationsOn));
MessageThread newMessageThread = new MessageThread(mPartnerName, mPartnerID, convoID, notificationsOn);
threadReference.set(newMessageThread);

}



}
}
});


}


However, in Firebase, the stored MessageThread is not showing an entry for notificationsOn even as it is set to true right before being sent to Firebase. Where does it go?










share|improve this question















I have a Firebase Collection that keeps track of a user's message threads by storing objects called MessageThreads as documents. Here are that object's class/constructors:



public class MessageThread {
private String partnerName;
private String partnerID;
private String threadID;
private Message lastMessage;
private boolean notificationsOn;


public MessageThread() {

}


public MessageThread(String partnerName, String partnerID, String threadID, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.notificationsOn = notificationsOn;
}


public MessageThread(String partnerName, String partnerID, String threadID, Message lastMessage, boolean notificationsOn) {
this.partnerName = partnerName;
this.partnerID = partnerID;
this.threadID = threadID;
this.lastMessage = lastMessage;
this.notificationsOn = notificationsOn;
}

public String getPartnerID() {
return partnerID;
}

public void setPartnerID(String partnerID) {
this.partnerID = partnerID;
}

public String getThreadID() {
return threadID;
}

public void setThreadID(String threadID) {
this.threadID = threadID;
}

public boolean areNotificationsOn() {
return notificationsOn;
}

public void setNotificationsOn(boolean notificationsOn) {
this.notificationsOn = notificationsOn;
}

public String getPartnerName() {
return partnerName;
}

public void setPartnerName(String user1) {
this.partnerName = user1;
}


public Message getLastMessage() {
return lastMessage;
}

public void setLastMessage(Message lastMessage) {
this.lastMessage = lastMessage;
}

}


When the messaging activity is launched for a new thread, the notificationsOn boolean is set to true and a Thread object is created using the second (4 argument) constructor:



 private void getSetThreadDetails(final String convoID) {

final DocumentReference threadReference = mFirestore.collection("users").document(mSignedInUserID).collection("threads").document(convoID);


threadReference.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot snapshot = task.getResult();

if (!snapshot.exists()) {
notificationsOn = true;
Log.d(TAG,"notifications when thread details set: " +String.valueOf(notificationsOn));
MessageThread newMessageThread = new MessageThread(mPartnerName, mPartnerID, convoID, notificationsOn);
threadReference.set(newMessageThread);

}



}
}
});


}


However, in Firebase, the stored MessageThread is not showing an entry for notificationsOn even as it is set to true right before being sent to Firebase. Where does it go?







android firebase google-cloud-firestore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 23:19









Doug Stevenson

69.3k880101




69.3k880101










asked Nov 20 at 20:16









aedgar777

5412




5412












  • Is that your entire MessageThread object? If so, I would expect nothing to be stored, since all your member variables are private. If you have getters and setters, please edit the question to show them.
    – Doug Stevenson
    Nov 20 at 22:45










  • Removed them for brevity. Edited them back in.
    – aedgar777
    Nov 20 at 23:05


















  • Is that your entire MessageThread object? If so, I would expect nothing to be stored, since all your member variables are private. If you have getters and setters, please edit the question to show them.
    – Doug Stevenson
    Nov 20 at 22:45










  • Removed them for brevity. Edited them back in.
    – aedgar777
    Nov 20 at 23:05
















Is that your entire MessageThread object? If so, I would expect nothing to be stored, since all your member variables are private. If you have getters and setters, please edit the question to show them.
– Doug Stevenson
Nov 20 at 22:45




Is that your entire MessageThread object? If so, I would expect nothing to be stored, since all your member variables are private. If you have getters and setters, please edit the question to show them.
– Doug Stevenson
Nov 20 at 22:45












Removed them for brevity. Edited them back in.
– aedgar777
Nov 20 at 23:05




Removed them for brevity. Edited them back in.
– aedgar777
Nov 20 at 23:05












1 Answer
1






active

oldest

votes


















2














You have a setter for notificationsOn, but you don't have a getter. Firestore (by way of JavaBean convention) needs to find the method by its correct name:



public boolean getNotificationsOn() {
return this.notificationsOn;
}





share|improve this answer





















  • Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
    – Frank van Puffelen
    Nov 20 at 23:21










  • @FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
    – Doug Stevenson
    Nov 20 at 23:38










  • This is valuable information. Thank you.
    – aedgar777
    Nov 20 at 23:44










  • @Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
    – Frank van Puffelen
    Nov 21 at 0:45










  • @FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
    – Doug Stevenson
    Nov 21 at 0:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400871%2fboolean-not-appearing-in-firestore-object%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You have a setter for notificationsOn, but you don't have a getter. Firestore (by way of JavaBean convention) needs to find the method by its correct name:



public boolean getNotificationsOn() {
return this.notificationsOn;
}





share|improve this answer





















  • Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
    – Frank van Puffelen
    Nov 20 at 23:21










  • @FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
    – Doug Stevenson
    Nov 20 at 23:38










  • This is valuable information. Thank you.
    – aedgar777
    Nov 20 at 23:44










  • @Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
    – Frank van Puffelen
    Nov 21 at 0:45










  • @FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
    – Doug Stevenson
    Nov 21 at 0:56
















2














You have a setter for notificationsOn, but you don't have a getter. Firestore (by way of JavaBean convention) needs to find the method by its correct name:



public boolean getNotificationsOn() {
return this.notificationsOn;
}





share|improve this answer





















  • Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
    – Frank van Puffelen
    Nov 20 at 23:21










  • @FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
    – Doug Stevenson
    Nov 20 at 23:38










  • This is valuable information. Thank you.
    – aedgar777
    Nov 20 at 23:44










  • @Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
    – Frank van Puffelen
    Nov 21 at 0:45










  • @FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
    – Doug Stevenson
    Nov 21 at 0:56














2












2








2






You have a setter for notificationsOn, but you don't have a getter. Firestore (by way of JavaBean convention) needs to find the method by its correct name:



public boolean getNotificationsOn() {
return this.notificationsOn;
}





share|improve this answer












You have a setter for notificationsOn, but you don't have a getter. Firestore (by way of JavaBean convention) needs to find the method by its correct name:



public boolean getNotificationsOn() {
return this.notificationsOn;
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 at 23:18









Doug Stevenson

69.3k880101




69.3k880101












  • Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
    – Frank van Puffelen
    Nov 20 at 23:21










  • @FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
    – Doug Stevenson
    Nov 20 at 23:38










  • This is valuable information. Thank you.
    – aedgar777
    Nov 20 at 23:44










  • @Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
    – Frank van Puffelen
    Nov 21 at 0:45










  • @FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
    – Doug Stevenson
    Nov 21 at 0:56


















  • Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
    – Frank van Puffelen
    Nov 20 at 23:21










  • @FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
    – Doug Stevenson
    Nov 20 at 23:38










  • This is valuable information. Thank you.
    – aedgar777
    Nov 20 at 23:44










  • @Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
    – Frank van Puffelen
    Nov 21 at 0:45










  • @FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
    – Doug Stevenson
    Nov 21 at 0:56
















Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
– Frank van Puffelen
Nov 20 at 23:21




Alternatively, just mark the field as public and remove the getter and setter: public class MessageThread { ... public boolean notificationsOn;
– Frank van Puffelen
Nov 20 at 23:21












@FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
– Doug Stevenson
Nov 20 at 23:38




@FrankvanPuffelen but then there would be one public field commingled with 4 other private fields that have proper getters and setters in this example. :-(
– Doug Stevenson
Nov 20 at 23:38












This is valuable information. Thank you.
– aedgar777
Nov 20 at 23:44




This is valuable information. Thank you.
– aedgar777
Nov 20 at 23:44












@Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
– Frank van Puffelen
Nov 21 at 0:45




@Doug: yeah, I'd probably make all of them public fields at that point and drop all getters/setters. ;-)
– Frank van Puffelen
Nov 21 at 0:45












@FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
– Doug Stevenson
Nov 21 at 0:56




@FrankvanPuffelen I won't argue with you about why using getters and setters and never exposing member variables is a better engineering practice. :-)
– Doug Stevenson
Nov 21 at 0:56


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400871%2fboolean-not-appearing-in-firestore-object%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'