java - Can I prefix a function with "get" in Springboot -
i have mcq class associated mongorepository, , want instance of mcq apply several changes (answers shuffle, questions draw, etc). declared function "mymcq.getinstance()", can't because every time want send mcq in responseentity there error in json output because springboot thinks there "instance" property in class.
here java class :
@document(collection = "mcqs") public class mcq { @id public string id; @dbref public user creator; public string title; public string categoryid; public list<mcqchapter> chapterlist = new arraylist<>(); public difficulty difficulty; public mcq() {} public mcq(string title) { this(); this.title = title; } public arraylist<string> getquestionsids() { arraylist<string> result = new arraylist<>(); (mcqchapter chapter : chapterlist) result.addall(chapter.getquestionids()); return result; } public mcqinstance getinstance() { return new mcqinstance(this); } }
to prevent error add jsonignoretype getinstance():
@jsonignore public mcqinstance getinstance() { return new mcqinstance(this); }
Comments
Post a Comment