Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB

  1. package eu.faircode.email;
  2. /*
  3. This file is part of FairEmail.
  4. FairEmail is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. NetGuard is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
  14. Copyright 2018 by Marcel Bokhorst (M66B)
  15. */
  16. import org.json.JSONException;
  17. import org.json.JSONObject;
  18. import java.io.Serializable;
  19. import androidx.annotation.NonNull;
  20. import androidx.room.Entity;
  21. import androidx.room.PrimaryKey;
  22. // https://developer.android.com/training/data-storage/room/defining-data
  23. @Entity(
  24. tableName = EntityAnswer.TABLE_NAME,
  25. foreignKeys = {
  26. },
  27. indices = {
  28. }
  29. )
  30. public class EntityAnswer implements Serializable {
  31. static final String TABLE_NAME = "answer";
  32. @PrimaryKey(autoGenerate = true)
  33. public Long id;
  34. @NonNull
  35. public String name;
  36. @NonNull
  37. public String text;
  38. public JSONObject toJSON() throws JSONException {
  39. JSONObject json = new JSONObject();
  40. json.put("name", name);
  41. json.put("text", text);
  42. return json;
  43. }
  44. public static EntityAnswer fromJSON(JSONObject json) throws JSONException {
  45. EntityAnswer answer = new EntityAnswer();
  46. answer.name = json.getString("name");
  47. answer.text = json.getString("text");
  48. return answer;
  49. }
  50. @Override
  51. public boolean equals(Object obj) {
  52. if (obj instanceof EntityAnswer) {
  53. EntityAnswer other = (EntityAnswer) obj;
  54. return (this.name.equals(other.name) &&
  55. this.text.equals(other.text)
  56. );
  57. }
  58. return false;
  59. }
  60. }