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.

AreaReference.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.example.meinwald.ui.area;
  2. import android.util.Log;
  3. import com.example.meinwald.BuildConfig;
  4. import org.json.JSONException;
  5. import org.json.JSONObject;
  6. public class AreaReference
  7. {
  8. private String id;
  9. private String path;
  10. public AreaReference(String id, String path)
  11. {
  12. this.id = id;
  13. this.path = path;
  14. }
  15. public String getId() {
  16. return id;
  17. }
  18. public String getPath() {
  19. return path;
  20. }
  21. /**
  22. * Creates EpiColorDto from JSON-Representation
  23. *
  24. * @param jsonRepresentation epiColorDto values as jsonObject
  25. */
  26. public AreaReference(JSONObject jsonRepresentation) {
  27. try {
  28. this.id = jsonRepresentation.getString("id");
  29. this.path = jsonRepresentation.getString("path");
  30. } catch (JSONException e) {
  31. if (BuildConfig.DEBUG) {
  32. Log.e(this.getClass().getSimpleName(),
  33. String.format("Error while parsing epiColorDto to JSONObject. Values of epiColorDto: %s", this.toString()));
  34. }
  35. }
  36. }
  37. /**
  38. * Returns AreaReference as JSONObject.
  39. *
  40. * @return the mapped object or null, if parsing fails
  41. */
  42. public JSONObject toJSONObject() {
  43. JSONObject object = new JSONObject();
  44. try {
  45. object.put("id",this.id);
  46. object.put("path",this.path);
  47. return object;
  48. } catch (JSONException e) {
  49. if (BuildConfig.DEBUG) {
  50. Log.e(this.getClass().getSimpleName(),
  51. String.format("Error while parsing epiColorDto to JSONObject. Values of epiColorDto: %s", this.toString()));
  52. }
  53. return null;
  54. }
  55. }
  56. @Override
  57. public String toString() {
  58. return "AreaReference{" +
  59. "id='" + id + '\'' +
  60. ", path='" + path + '\'' +
  61. '}';
  62. }
  63. }