Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/main/java/org/gitlab4j/api/models/SystemHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SystemHook {
private Boolean pushEvents;
private Boolean tagPushEvents;
private Boolean enableSslVerification;
private Boolean repositoryUpdateEvents;

public Integer getId() {
return id;
Expand Down Expand Up @@ -64,4 +65,27 @@ public Boolean getEnableSslVerification() {
public void setEnableSslVerification(Boolean enableSslVerification) {
this.enableSslVerification = enableSslVerification;
}

public void setRepositoryUpdateEvents(Boolean repositoryUpdateEvents) {
this.repositoryUpdateEvents = repositoryUpdateEvents;
}

public Boolean getRepositoryUpdateEvents() {
return repositoryUpdateEvents;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("SystemHook{");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer not to override toString() like this, these often become out of sync. An option here would be to implementtoString() using something like this:

@Override
public String toString() {
    return (new org.gitlab4j.api.utils.JacksonJson().marshal(this));
}

This way the output is always in-sync with the class and outputs strings in the expected format, specifically the dates.

We could also consider adding a singleton JacksonJson instance to use for this and elsewhere. For example, the SystemHookManager class has it's own private instance of JacksonJson, which could use the singleton instance also.

sb.append("id=").append(id);
sb.append(", url='").append(url).append('\'');
sb.append(", createdAt=").append(createdAt);
sb.append(", pushEvents=").append(pushEvents);
sb.append(", tagPushEvents=").append(tagPushEvents);
sb.append(", enableSslVerification=").append(enableSslVerification);
sb.append(", repositoryUpdateEvents=").append(repositoryUpdateEvents);
sb.append('}');
return sb.toString();
}

}