diff --git a/pom.xml b/pom.xml
index 4ea96f5..5e89a55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,5 +162,11 @@
gson
${gson.version}
+
+ org.projectlombok
+ lombok
+ 1.18.4
+ provided
+
diff --git a/src/main/java/net/gpedro/integrations/slack/SlackAction.java b/src/main/java/net/gpedro/integrations/slack/SlackAction.java
index b05664d..a7c99c4 100644
--- a/src/main/java/net/gpedro/integrations/slack/SlackAction.java
+++ b/src/main/java/net/gpedro/integrations/slack/SlackAction.java
@@ -1,10 +1,14 @@
package net.gpedro.integrations.slack;
import com.google.gson.JsonObject;
+import lombok.Data;
+import lombok.experimental.Accessors;
/**
* @author Galimov Ruslan
*/
+@Data
+@Accessors(chain = true)
public class SlackAction {
private static final String NAME = "name";
@@ -32,46 +36,6 @@ public SlackAction(String name, String text, SlackActionType type, String value)
this.value = value;
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public SlackActionType getType() {
- return type;
- }
-
- public void setType(SlackActionType type) {
- this.type = type;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public SlackActionStyle getStyle() {
- return style;
- }
-
- public void setStyle(SlackActionStyle style) {
- this.style = style;
- }
-
public JsonObject toJson() {
final JsonObject data = new JsonObject();
data.addProperty(NAME, name);
diff --git a/src/main/java/net/gpedro/integrations/slack/SlackAttachment.java b/src/main/java/net/gpedro/integrations/slack/SlackAttachment.java
index dbc1cc8..7dd0597 100644
--- a/src/main/java/net/gpedro/integrations/slack/SlackAttachment.java
+++ b/src/main/java/net/gpedro/integrations/slack/SlackAttachment.java
@@ -9,6 +9,8 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
+import lombok.Data;
+import lombok.experimental.Accessors;
/**
* Represents an attachment in a slack webhook JSON message.
@@ -17,6 +19,8 @@
* @author David Webb
* @author Galimov Ruslan
*/
+@Data
+@Accessors(chain = true)
public class SlackAttachment {
private static final String HEX_REGEX = "^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$";
@@ -148,102 +152,6 @@ public SlackAttachment setColor(String color) {
return this;
}
- public SlackAttachment setFallback(String fallback) {
- this.fallback = fallback;
-
- return this;
- }
-
- public SlackAttachment setCallbackId(String callbackId) {
- this.callbackId = callbackId;
-
- return this;
- }
-
- public SlackAttachment setFields(List fields) {
- this.fields = fields;
-
- return this;
- }
-
- public SlackAttachment setPretext(String pretext) {
- this.pretext = pretext;
-
- return this;
- }
-
- public SlackAttachment setText(String text) {
- this.text = text;
-
- return this;
- }
-
- public SlackAttachment setAuthorName(String authorName) {
- this.authorName = authorName;
-
- return this;
- }
-
- public SlackAttachment setAuthorLink(String authorLink) {
- this.authorLink = authorLink;
-
- return this;
- }
-
- public SlackAttachment setAuthorIcon(String authorIcon) {
- this.authorIcon = authorIcon;
-
- return this;
- }
-
- public SlackAttachment setTitle(String title) {
- this.title = title;
-
- return this;
- }
-
- public SlackAttachment setTitleLink(String titleLink) {
- this.titleLink = titleLink;
-
- return this;
- }
-
- public SlackAttachment setImageUrl(String imageUrl) {
- this.imageUrl = imageUrl;
-
- return this;
- }
-
- public SlackAttachment setThumbUrl(String thumbUrl) {
- this.thumbUrl = thumbUrl;
-
- return this;
- }
-
- public SlackAttachment setTimestamp(Long timestamp) {
- this.timestamp = timestamp;
-
- return this;
- }
-
- public SlackAttachment setTimestamp(Date date) {
- this.timestamp = date.getTime() / 1000;
-
- return this;
- }
-
- public SlackAttachment setFooter(String footer) {
- this.footer = footer;
-
- return this;
- }
-
- public SlackAttachment setFooterIcon(String footerIcon) {
- this.footerIcon = footerIcon;
-
- return this;
- }
-
public JsonObject toJson() {
JsonObject data = new JsonObject();
diff --git a/src/main/java/net/gpedro/integrations/slack/SlackField.java b/src/main/java/net/gpedro/integrations/slack/SlackField.java
index b7dfa9c..45c04b2 100644
--- a/src/main/java/net/gpedro/integrations/slack/SlackField.java
+++ b/src/main/java/net/gpedro/integrations/slack/SlackField.java
@@ -6,7 +6,11 @@
import java.util.ArrayList;
import java.util.List;
+import lombok.Data;
+import lombok.experimental.Accessors;
+@Data
+@Accessors(chain = true)
public class SlackField {
private static final String TITLE = "title";
@@ -33,10 +37,6 @@ public void addAllowedMarkdown(String field) {
}
}
- public boolean isShorten() {
- return shorten;
- }
-
private JsonArray prepareMarkdown() {
JsonArray data = new JsonArray();
for (String item : this.allowMarkdown) {
@@ -46,27 +46,6 @@ private JsonArray prepareMarkdown() {
return data;
}
- public void setAllowedMarkdown(ArrayList allowMarkdown) {
- if (allowMarkdown != null) {
- this.allowMarkdown = allowMarkdown;
- }
- }
-
- public SlackField setShorten(boolean shorten) {
- this.shorten = shorten;
- return this;
- }
-
- public SlackField setTitle(String title) {
- this.title = title;
- return this;
- }
-
- public SlackField setValue(String value) {
- this.value = value;
- return this;
- }
-
public JsonObject toJson() {
final JsonObject data = new JsonObject();
data.addProperty(TITLE, title);
@@ -78,38 +57,4 @@ public JsonObject toJson() {
return data;
}
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- final SlackField that = (SlackField) o;
-
- if (shorten != that.shorten)
- return false;
- if (allowMarkdown != null ? !allowMarkdown.equals(that.allowMarkdown) : that.allowMarkdown != null)
- return false;
- if (title != null ? !title.equals(that.title) : that.title != null)
- return false;
- return !(value != null ? !value.equals(that.value) : that.value != null);
-
- }
-
- @Override
- public int hashCode() {
- int result = allowMarkdown != null ? allowMarkdown.hashCode() : 0;
- result = 31 * result + (shorten ? 1 : 0);
- result = 31 * result + (title != null ? title.hashCode() : 0);
- result = 31 * result + (value != null ? value.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "SlackField{" + "allowMarkdown=" + allowMarkdown + ", shorten=" + shorten + ", title='" + title + '\''
- + ", value='" + value + '\'' + '}';
- }
}
diff --git a/src/main/java/net/gpedro/integrations/slack/SlackMessage.java b/src/main/java/net/gpedro/integrations/slack/SlackMessage.java
index d8d57c7..0eb88d4 100644
--- a/src/main/java/net/gpedro/integrations/slack/SlackMessage.java
+++ b/src/main/java/net/gpedro/integrations/slack/SlackMessage.java
@@ -5,7 +5,11 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+import lombok.Data;
+import lombok.experimental.Accessors;
+@Data
+@Accessors(chain = true)
public class SlackMessage {
private static final String CHANNEL = "channel";
@@ -115,12 +119,6 @@ public SlackMessage removeAttachment(int index) {
return this;
}
- public SlackMessage setAttachments(List attach) {
- this.attach = attach;
-
- return this;
- }
-
public SlackMessage setChannel(String channel) {
if (channel != null) {
this.channel = channel;
@@ -159,70 +157,4 @@ public SlackMessage setUsername(String username) {
return this;
}
-
- public SlackMessage setUnfurlMedia(boolean unfurlMedia) {
- this.unfurlMedia = unfurlMedia;
-
- return this;
- }
-
- public SlackMessage setUnfurlLinks(boolean unfurlLinks) {
- this.unfurlLinks = unfurlLinks;
-
- return this;
- }
-
- public SlackMessage setLinkNames(boolean linkNames) {
- this.linkNames = linkNames;
-
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- final SlackMessage that = (SlackMessage) o;
-
- if (unfurlMedia != that.unfurlMedia)
- return false;
- if (unfurlLinks != that.unfurlLinks)
- return false;
- if (linkNames != that.linkNames)
- return false;
- if (attach != null ? !attach.equals(that.attach) : that.attach != null)
- return false;
- if (channel != null ? !channel.equals(that.channel) : that.channel != null)
- return false;
- if (icon != null ? !icon.equals(that.icon) : that.icon != null)
- return false;
- if (text != null ? !text.equals(that.text) : that.text != null)
- return false;
-
- return !(username != null ? !username.equals(that.username) : that.username != null);
-
- }
-
- @Override
- public int hashCode() {
- int result = attach != null ? attach.hashCode() : 0;
- result = 31 * result + (channel != null ? channel.hashCode() : 0);
- result = 31 * result + (icon != null ? icon.hashCode() : 0);
- result = 31 * result + (text != null ? text.hashCode() : 0);
- result = 31 * result + (username != null ? username.hashCode() : 0);
- result = 31 * result + (unfurlMedia ? 1 : 0);
- result = 31 * result + (unfurlLinks ? 1 : 0);
- result = 31 * result + (linkNames ? 1 : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "SlackMessage{" + "attach=" + attach + ", channel='" + channel + '\'' + ", icon='" + icon + '\''
- + ", slackMessage=" + slackMessage + ", text='" + text + '\'' + ", username='" + username + '\''
- + ", unfurlMedia=" + unfurlMedia + ", unfurlLinks=" + unfurlLinks + ", linkNames=" + linkNames + '}';
- }
}