View Javadoc

1   package com.atlassian.plugins.rest.doclet.generators.schema.beans.issue;
2   
3   import com.atlassian.annotations.ExperimentalApi;
4   import com.google.common.base.Objects;
5   import org.codehaus.jackson.annotate.JsonIgnoreProperties;
6   import org.codehaus.jackson.annotate.JsonProperty;
7   import org.codehaus.jackson.map.annotate.JsonSerialize;
8   
9   /**
10   * Represents a identifiable participant in the metadata history. This might be a remote system, an event that caused
11   * the change to occur, or a user on a remote system.
12   *
13   * @since JIRA 6.3
14   */
15  @ExperimentalApi
16  @JsonSerialize (include = JsonSerialize.Inclusion.NON_NULL)
17  @JsonIgnoreProperties (ignoreUnknown = true)
18  public final class HistoryMetadataParticipant
19  {
20      @JsonProperty
21      String id;
22  
23      @JsonProperty
24      String displayName;
25  
26      @JsonProperty
27      String displayNameKey;
28  
29      @JsonProperty
30      String type;
31  
32      @JsonProperty
33      String avatarUrl;
34  
35      @JsonProperty
36      String url;
37  
38      // for jackson
39      private HistoryMetadataParticipant()
40      {}
41  
42      private HistoryMetadataParticipant(final HistoryMetadataParticipantBuilder builder)
43      {
44          this.id = builder.id;
45          this.displayName = builder.displayName;
46          this.displayNameKey = builder.displayNameKey;
47          this.type = builder.type;
48          this.avatarUrl = builder.avatarUrl;
49          this.url = builder.url;
50      }
51  
52      /**
53       * The identifier of this participant
54       */
55      public String getId()
56      {
57          return id;
58      }
59  
60      /**
61       * The user readable name of the participant
62       */
63      public String getDisplayName()
64      {
65          return displayName;
66      }
67  
68      /**
69       * i18n key for the  user readable name of the participant, will be used before displayName if present
70       */
71      public String getDisplayNameKey()
72      {
73          return displayNameKey;
74      }
75  
76      /**
77       * The type of the participant
78       */
79      public String getType()
80      {
81          return type;
82      }
83  
84      /**
85       * The avatar image url of the participant
86       */
87      public String getAvatarUrl()
88      {
89          return avatarUrl;
90      }
91  
92      /**
93       * The url to this participant's details page
94       */
95      public String getUrl()
96      {
97          return url;
98      }
99  
100     /**
101      * This method is implemented for usage in Unit Tests.
102      */
103     @Override
104     public int hashCode()
105     {
106         return Objects.hashCode(id, displayName, displayNameKey, type, avatarUrl, url);
107     }
108 
109     /**
110      * This method is implemented for usage in Unit Tests.
111      */
112     @Override
113     public boolean equals(final Object obj)
114     {
115         if (this == obj) {return true;}
116         if (obj == null || getClass() != obj.getClass()) {return false;}
117         final HistoryMetadataParticipant other = (HistoryMetadataParticipant) obj;
118         return Objects.equal(this.id, other.id) && Objects.equal(this.displayName, other.displayName) &&
119                 Objects.equal(this.displayNameKey, other.displayNameKey) && Objects.equal(this.type, other.type) &&
120                 Objects.equal(this.avatarUrl, other.avatarUrl) && Objects.equal(this.url, other.url);
121     }
122 
123     /**
124      * @param id the id of the participant being created
125      * @param type the type of the participant being created
126      * @return a builder for a HistoryMetadataParticipant object
127      */
128     public static HistoryMetadataParticipantBuilder builder(String id, String type)
129     {
130         return new HistoryMetadataParticipantBuilder(id, type);
131     }
132 
133     @ExperimentalApi
134     public static class HistoryMetadataParticipantBuilder
135     {
136         private String id;
137         private String type;
138 
139         private String displayName;
140         private String displayNameKey;
141         private String avatarUrl;
142         private String url;
143 
144         private HistoryMetadataParticipantBuilder(String id, String type)
145         {
146             this.id = id;
147             this.type = type;
148         }
149 
150         public HistoryMetadataParticipantBuilder displayName(String displayName)
151         {
152             this.displayName = displayName;
153             return this;
154         }
155 
156         public HistoryMetadataParticipantBuilder displayNameKey(String displayNameKey)
157         {
158             this.displayNameKey = displayNameKey;
159             return this;
160         }
161 
162         public HistoryMetadataParticipantBuilder avatarUrl(String avatarUrl)
163         {
164             this.avatarUrl = avatarUrl;
165             return this;
166         }
167 
168         public HistoryMetadataParticipantBuilder url(String url)
169         {
170             this.url = url;
171             return this;
172         }
173 
174         public HistoryMetadataParticipant build()
175         {
176             return new HistoryMetadataParticipant(this);
177         }
178     }
179 }