/src/main/java/ir/co/dpq/jayab/Location.java

https://gitlab.com/jahanjoo/retrofit-jahanjoo · Java · 163 lines · 111 code · 30 blank · 22 comment · 8 complexity · 8911feb7f2cbc1d6f3571979f730ab36 MD5 · raw file

  1. package ir.co.dpq.jayab;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. import com.google.gson.annotations.SerializedName;
  5. /**
  6. * Created by hadi on 6/11/15.
  7. */
  8. public class Location {
  9. // Key attributes of location
  10. long id;
  11. boolean community;
  12. String name;
  13. String description;
  14. Long reporter;
  15. Double latitude;
  16. Double longitude;
  17. // TODO Hadi 1394-07-07: دو فیلد زیر به نوع DateTime جاوا تبدیل شوند
  18. @SerializedName("creation_dtime")
  19. String creationDateTime;
  20. @SerializedName("modif_dtime")
  21. String modificationDateTime;
  22. // For cloud base system
  23. /**
  24. * مالک مکان که می‌تواند یک کاربر یا یک گروه یا یک tenant باشد.
  25. */
  26. @SerializedName("owner_id")
  27. long ownerId;
  28. /**
  29. * یکی از مقادیر user, group, tenant
  30. */
  31. @SerializedName("owner_class")
  32. String ownerClass;
  33. /**
  34. * یک نمونه جدید از این کلاس ایجاد می‌کند.
  35. */
  36. public Location(){
  37. //
  38. }
  39. public Location(Long id, Double lat, Double lon) {
  40. setId(id);
  41. setLatitude(lat);
  42. setLongitude(lon);
  43. setName(name);
  44. }
  45. public long getId() {
  46. return id;
  47. }
  48. public void setId(long id) {
  49. this.id = id;
  50. }
  51. public Double getLatitude() {
  52. return latitude;
  53. }
  54. public void setLatitude(Double latitude) {
  55. this.latitude = latitude;
  56. }
  57. public Double getLongitude() {
  58. return longitude;
  59. }
  60. public void setLongitude(Double longitude) {
  61. this.longitude = longitude;
  62. }
  63. public Long getReporter() {
  64. return reporter;
  65. }
  66. public void setReporter(Long reporter) {
  67. this.reporter = reporter;
  68. }
  69. public String getName() {
  70. return name;
  71. }
  72. public void setName(String name) {
  73. this.name = name;
  74. }
  75. public String getDescription() {
  76. return description;
  77. }
  78. public void setDescription(String description) {
  79. this.description = description;
  80. }
  81. public boolean isCommunity() {
  82. return community;
  83. }
  84. public void setCommunity(boolean community) {
  85. this.community = community;
  86. }
  87. public String getCreationDateTime() {
  88. return creationDateTime;
  89. }
  90. public void setCreationDateTime(String creationDateTime) {
  91. this.creationDateTime = creationDateTime;
  92. }
  93. public String getModificationDateTime() {
  94. return modificationDateTime;
  95. }
  96. public void setModificationDateTime(String modificationDateTime) {
  97. this.modificationDateTime = modificationDateTime;
  98. }
  99. public long getOwnerId() {
  100. return ownerId;
  101. }
  102. public void setOwnerId(long ownerId) {
  103. this.ownerId = ownerId;
  104. }
  105. public String getOwnerClass() {
  106. return ownerClass;
  107. }
  108. public void setOwnerClass(String ownerClass) {
  109. this.ownerClass = ownerClass;
  110. }
  111. /**
  112. * داده‌های کلاس را به صورت یک نگاشت می‌دهد.
  113. *
  114. * @return
  115. */
  116. public Map<String, Object> map(){
  117. HashMap<String, Object> m = new HashMap<String, Object>();
  118. if(getLatitude() != null){
  119. m.put("latitude", getLatitude());
  120. }
  121. if(getLongitude() != null){
  122. m.put("longitude", getLongitude());
  123. }
  124. if(getName() != null){
  125. m.put("name", getName());
  126. }
  127. if(getDescription() != null){
  128. m.put("description", getDescription());
  129. }
  130. // FIXME: maso, 1394: add other information.
  131. return m;
  132. }
  133. }