Commit c15bcb5e authored by Greg Messner's avatar Greg Messner
Browse files

Mods related to making EventChanges abstract (#362).

parent 78c3a0c4
...@@ -10,18 +10,36 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; ...@@ -10,18 +10,36 @@ import com.fasterxml.jackson.annotation.JsonAnySetter;
import org.gitlab4j.api.models.Assignee; import org.gitlab4j.api.models.Assignee;
import org.gitlab4j.api.utils.JacksonJson; import org.gitlab4j.api.utils.JacksonJson;
public class EventChanges { public abstract class EventChanges {
private ChangeContainer<String> state; private ChangeContainer<Integer> authorId;
private ChangeContainer<Date> createdAt;
private ChangeContainer<Date> updatedAt; private ChangeContainer<Date> updatedAt;
private ChangeContainer<Integer> updatedById; private ChangeContainer<Integer> updatedById;
private ChangeContainer<Date> dueDate; private ChangeContainer<String> title;
private ChangeContainer<String> description;
private ChangeContainer<String> state;
private ChangeContainer<Integer> milestoneId; private ChangeContainer<Integer> milestoneId;
private ChangeContainer<List<EventLabel>> labels; private ChangeContainer<List<EventLabel>> labels;
private ChangeContainer<List<Assignee>> assignees; private ChangeContainer<List<Assignee>> assignees;
private ChangeContainer<Integer> totalTimeSpent; private ChangeContainer<Integer> totalTimeSpent;
private ChangeContainer<Boolean> confidential; private Map<String, ChangeContainer<Object>> otherProperties = new LinkedHashMap<>();
private LinkedHashMap<String, ChangeContainer<Object>> otherProperties = new LinkedHashMap<>();
public ChangeContainer<Integer> getAuthorId() {
return authorId;
}
public void setAuthorId(ChangeContainer<Integer> authorId) {
this.authorId = authorId;
}
public ChangeContainer<Date> getCreatedAt() {
return createdAt;
}
public void setCreatedAt(ChangeContainer<Date> createdAt) {
this.createdAt = createdAt;
}
public ChangeContainer<Date> getUpdatedAt() { public ChangeContainer<Date> getUpdatedAt() {
return updatedAt; return updatedAt;
...@@ -39,12 +57,28 @@ public class EventChanges { ...@@ -39,12 +57,28 @@ public class EventChanges {
this.updatedById = updatedById; this.updatedById = updatedById;
} }
public ChangeContainer<Date> getDueDate() { public ChangeContainer<String> getTitle() {
return dueDate; return title;
}
public void setTitle(ChangeContainer<String> title) {
this.title = title;
}
public ChangeContainer<String> getDescription() {
return description;
} }
public void setDueDate(ChangeContainer<Date> dueDate) { public void setDescription(ChangeContainer<String> description) {
this.dueDate = dueDate; this.description = description;
}
public ChangeContainer<String> getState() {
return state;
}
public void setState(ChangeContainer<String> state) {
this.state = state;
} }
public ChangeContainer<Integer> getMilestoneId() { public ChangeContainer<Integer> getMilestoneId() {
...@@ -79,27 +113,13 @@ public class EventChanges { ...@@ -79,27 +113,13 @@ public class EventChanges {
this.totalTimeSpent = totalTimeSpent; this.totalTimeSpent = totalTimeSpent;
} }
public ChangeContainer<Boolean> getConfidential() { @SuppressWarnings("unchecked")
return confidential;
}
public void setConfidential(ChangeContainer<Boolean> confidential) {
this.confidential = confidential;
}
public ChangeContainer<String> getState() {
return state;
}
public void setState(ChangeContainer<String> state) {
this.state = state;
}
public <T> ChangeContainer<T> get(String property){ public <T> ChangeContainer<T> get(String property){
if(otherProperties.containsKey(property)){ if(otherProperties.containsKey(property)){
try { try {
final ChangeContainer<Object> container = otherProperties.get(property); final ChangeContainer<Object> container = otherProperties.get(property);
//noinspection unchecked It's duty from caller to be sure to do that // noinspection unchecked : It's duty from caller to be sure to do that
return container != null ? (ChangeContainer<T>) container : null; return container != null ? (ChangeContainer<T>) container : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
return null; return null;
......
...@@ -18,7 +18,7 @@ public class IssueEvent extends AbstractEvent { ...@@ -18,7 +18,7 @@ public class IssueEvent extends AbstractEvent {
private List<Assignee> assignees; private List<Assignee> assignees;
private Assignee assignee; private Assignee assignee;
private List<EventLabel> labels; private List<EventLabel> labels;
private EventChanges changes; private IssueChanges changes;
public String getObjectKind() { public String getObjectKind() {
return (OBJECT_KIND); return (OBJECT_KIND);
...@@ -77,11 +77,11 @@ public class IssueEvent extends AbstractEvent { ...@@ -77,11 +77,11 @@ public class IssueEvent extends AbstractEvent {
this.labels = labels; this.labels = labels;
} }
public EventChanges getChanges() { public IssueChanges getChanges() {
return changes; return changes;
} }
public void setChanges(EventChanges changes) { public void setChanges(IssueChanges changes) {
this.changes = changes; this.changes = changes;
} }
......
...@@ -15,7 +15,7 @@ public class MergeRequestEvent extends AbstractEvent { ...@@ -15,7 +15,7 @@ public class MergeRequestEvent extends AbstractEvent {
private EventRepository repository; private EventRepository repository;
private ObjectAttributes objectAttributes; private ObjectAttributes objectAttributes;
private List<EventLabel> labels; private List<EventLabel> labels;
private EventChanges changes; private MergeRequestChanges changes;
public String getObjectKind() { public String getObjectKind() {
return (OBJECT_KIND); return (OBJECT_KIND);
...@@ -66,11 +66,11 @@ public class MergeRequestEvent extends AbstractEvent { ...@@ -66,11 +66,11 @@ public class MergeRequestEvent extends AbstractEvent {
this.labels = labels; this.labels = labels;
} }
public EventChanges getChanges() { public MergeRequestChanges getChanges() {
return changes; return changes;
} }
public void setChanges(EventChanges changes) { public void setChanges(MergeRequestChanges changes) {
this.changes = changes; this.changes = changes;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment