12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package com.example.meinwald.ui.area;
-
- import android.util.Log;
-
- import com.example.meinwald.BuildConfig;
-
- import org.json.JSONException;
- import org.json.JSONObject;
-
- public class AreaReference
- {
- private String id;
- private String path;
-
- public AreaReference(String id, String path)
- {
- this.id = id;
- this.path = path;
- }
-
- public String getId() {
- return id;
- }
-
- public String getPath() {
- return path;
- }
-
- /**
- * Creates EpiColorDto from JSON-Representation
- *
- * @param jsonRepresentation epiColorDto values as jsonObject
- */
- public AreaReference(JSONObject jsonRepresentation) {
- try {
- this.id = jsonRepresentation.getString("id");
- this.path = jsonRepresentation.getString("path");
- } catch (JSONException e) {
- if (BuildConfig.DEBUG) {
- Log.e(this.getClass().getSimpleName(),
- String.format("Error while parsing epiColorDto to JSONObject. Values of epiColorDto: %s", this.toString()));
- }
- }
- }
-
- /**
- * Returns AreaReference as JSONObject.
- *
- * @return the mapped object or null, if parsing fails
- */
- public JSONObject toJSONObject() {
- JSONObject object = new JSONObject();
- try {
- object.put("id",this.id);
- object.put("path",this.path);
- return object;
- } catch (JSONException e) {
- if (BuildConfig.DEBUG) {
- Log.e(this.getClass().getSimpleName(),
- String.format("Error while parsing epiColorDto to JSONObject. Values of epiColorDto: %s", this.toString()));
- }
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "AreaReference{" +
- "id='" + id + '\'' +
- ", path='" + path + '\'' +
- '}';
- }
- }
|