This is an automated email from the ASF dual-hosted git repository.
liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new d1d98032f6 refactor: extract base data for plugin, selector and rule
data class (#6215)
d1d98032f6 is described below
commit d1d98032f6ad0da388557beeb6b984fb3c49d06f
Author: shown <[email protected]>
AuthorDate: Tue Nov 4 13:39:15 2025 +0800
refactor: extract base data for plugin, selector and rule data class (#6215)
* refactor: extract base data for plugin, selector and rule data class
Signed-off-by: yuluo-yx <[email protected]>
* fix: fix ut
Signed-off-by: yuluo-yx <[email protected]>
* fix: fix checksyle error
Signed-off-by: yuluo-yx <[email protected]>
---------
Signed-off-by: yuluo-yx <[email protected]>
Co-authored-by: aias00 <[email protected]>
---
.../WebsocketDataChangedListenerTest.java | 25 ++--
.../org/apache/shenyu/common/dto/BaseData.java | 151 +++++++++++++++++++
.../org/apache/shenyu/common/dto/PluginData.java | 150 +++----------------
.../org/apache/shenyu/common/dto/RuleData.java | 160 +++++++--------------
.../org/apache/shenyu/common/dto/SelectorData.java | 140 +++---------------
5 files changed, 256 insertions(+), 370 deletions(-)
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/websocket/WebsocketDataChangedListenerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/websocket/WebsocketDataChangedListenerTest.java
index b8a38fca71..27721ffa99 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/websocket/WebsocketDataChangedListenerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/websocket/WebsocketDataChangedListenerTest.java
@@ -72,8 +72,8 @@ public final class WebsocketDataChangedListenerTest {
*/
@Test
public void testOnPluginChanged() {
- String message =
"{\"groupType\":\"PLUGIN\",\"eventType\":\"UPDATE\",\"data\":[{\"id\":\"2\",\"name\":\"waf\","
- +
"\"config\":\"{\\\\\\\"model\\\\\\\":\\\\\\\"black\\\\\\\"}\",\"role\":\"1\",\"enabled\":true,\"namespaceId\":\"649330b6-c2d7-4edc-be8e-8a54df9eb385\"}]}";
+ String message =
"{\"groupType\":\"PLUGIN\",\"eventType\":\"UPDATE\",\"data\":[{\"config\":\"{\\\\\\\"model\\\\\\\":\\\\\\\"black\\\\\\\"}\","
+ +
"\"role\":\"1\",\"id\":\"2\",\"name\":\"waf\",\"enabled\":true,\"namespaceId\":\"649330b6-c2d7-4edc-be8e-8a54df9eb385\"}]}";
MockedStatic.Verification verification = () ->
WebsocketCollector.send(Constants.SYS_DEFAULT_NAMESPACE_ID, message,
DataEventTypeEnum.UPDATE);
try (MockedStatic<WebsocketCollector> mockedStatic =
mockStatic(WebsocketCollector.class)) {
mockedStatic.when(verification).thenAnswer((Answer<Void>)
invocation -> null);
@@ -88,19 +88,25 @@ public final class WebsocketDataChangedListenerTest {
@Test
public void testOnSelectorChanged() {
String message =
"{\"groupType\":\"SELECTOR\",\"eventType\":\"UPDATE\",\"data\":"
- +
"[{\"id\":\"1336329408516136960\",\"pluginId\":\"5\",\"pluginName\":\"divide\",\"name\":"
- +
"\"/http\",\"matchMode\":0,\"type\":1,\"sort\":1,\"enabled\":true,\"logged\":true,"
+ + "[{\"pluginId\":\"5\",\"pluginName\":\"divide\","
+ + "\"matchMode\":0,\"type\":1,\"logged\":true,"
+
"\"continued\":true,\"handle\":\"[{\\\\\\\"upstreamHost\\\\\\\":\\\\\\\"localhost\\\\\\\","
+
"\\\\\\\"protocol\\\\\\\":\\\\\\\"http://\\\\\\\",\\\\\\\"upstreamUrl\\\\\\\":"
+
"\\\\\\\"127.0.0.1:8187\\\\\\\",\\\\\\\"weight\\\\\\\":\\\\\\\"51\\\\\\\"},"
+
"{\\\\\\\"upstreamHost\\\\\\\":\\\\\\\"localhost\\\\\\\",\\\\\\\"protocol\\\\\\\":"
+
"\\\\\\\"http://\\\\\\\",\\\\\\\"upstreamUrl\\\\\\\":\\\\\\\"127.0.0.1:8188\\\\\\\","
+
"\\\\\\\"weight\\\\\\\":\\\\\\\"49\\\\\\\"}]\",\"conditionList\":[{\"paramType\":\"uri\","
- +
"\"operator\":\"match\",\"paramName\":\"/\",\"paramValue\":\"/http/**\"}],\"namespaceId\":\"649330b6-c2d7-4edc-be8e-8a54df9eb385\"}]}";
+ +
"\"operator\":\"match\",\"paramName\":\"/\",\"paramValue\":\"/http/**\"}],\"id\":\"1336329408516136960\","
+ +
"\"name\":\"/http\",\"enabled\":true,\"sort\":1,\"namespaceId\":\"649330b6-c2d7-4edc-be8e-8a54df9eb385\"}]}";
MockedStatic.Verification verification = () ->
WebsocketCollector.send(Constants.SYS_DEFAULT_NAMESPACE_ID, message,
DataEventTypeEnum.UPDATE);
+
try (MockedStatic<WebsocketCollector> mockedStatic =
mockStatic(WebsocketCollector.class)) {
mockedStatic.when(verification).thenAnswer((Answer<Void>)
invocation -> null);
+
+ // 调用被测试的方法
websocketDataChangedListener.onSelectorChanged(selectorDataList,
DataEventTypeEnum.UPDATE);
+
+ // 验证
mockedStatic.verify(verification);
}
}
@@ -110,12 +116,13 @@ public final class WebsocketDataChangedListenerTest {
*/
@Test
public void testOnRuleChanged() {
- String message =
"{\"groupType\":\"RULE\",\"eventType\":\"UPDATE\",\"data\":[{\"id\":\"1336350040008105984\","
- +
"\"name\":\"test\",\"pluginName\":\"waf\",\"selectorId\":\"1336349806465064960\","
- +
"\"matchMode\":1,\"sort\":1,\"enabled\":true,\"loged\":true,\"handle\":"
+ String message =
"{\"groupType\":\"RULE\",\"eventType\":\"UPDATE\",\"data\":[{"
+ +
"\"pluginName\":\"waf\",\"selectorId\":\"1336349806465064960\","
+ + "\"matchMode\":1,\"loged\":true,\"handle\":"
+
"\"{\\\\\\\"permission\\\\\\\":\\\\\\\"reject\\\\\\\",\\\\\\\"statusCode\\\\\\\":"
+
"\\\\\\\"503\\\\\\\"}\",\"conditionDataList\":[{\"paramType\":\"header\",\"operator\":"
- +
"\"\\u003d\",\"paramName\":\"test\",\"paramValue\":\"a\"}],\"namespaceId\":\"649330b6-c2d7-4edc-be8e-8a54df9eb385\"}]}";
+ +
"\"\\u003d\",\"paramName\":\"test\",\"paramValue\":\"a\"}],\"id\":\"1336350040008105984\",\"name\":\"test\","
+ +
"\"enabled\":true,\"sort\":1,\"namespaceId\":\"649330b6-c2d7-4edc-be8e-8a54df9eb385\"}]}";
MockedStatic.Verification verification = () ->
WebsocketCollector.send(Constants.SYS_DEFAULT_NAMESPACE_ID, message,
DataEventTypeEnum.UPDATE);
try (MockedStatic<WebsocketCollector> mockedStatic =
mockStatic(WebsocketCollector.class)) {
mockedStatic.when(verification).thenAnswer((Answer<Void>)
invocation -> null);
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/BaseData.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/BaseData.java
new file mode 100644
index 0000000000..65fc3a0e36
--- /dev/null
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/BaseData.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.common.dto;
+
+/**
+ * Base class for common data transfer objects.
+ * Contains common fields shared across SelectorData, RuleData, and PluginData.
+ */
+
+public class BaseData {
+
+ /**
+ * primary key id.
+ */
+ private String id;
+
+ /**
+ * name.
+ */
+ private String name;
+
+ /**
+ * whether enabled.
+ */
+ private Boolean enabled;
+
+ /**
+ * sort order.
+ */
+ private Integer sort;
+
+ /**
+ * namespace id.
+ */
+ private String namespaceId;
+
+ /**
+ * get id.
+ *
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * set id.
+ *
+ * @param id id
+ * @return this
+ */
+ public BaseData setId(final String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * get name.
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * set name.
+ *
+ * @param name name
+ * @return this
+ */
+ public BaseData setName(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * get enabled.
+ *
+ * @return enabled
+ */
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ /**
+ * set enabled.
+ *
+ * @param enabled enabled
+ * @return this
+ */
+ public BaseData setEnabled(final Boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ /**
+ * get sort.
+ *
+ * @return sort
+ */
+ public Integer getSort() {
+ return sort;
+ }
+
+ /**
+ * set sort.
+ *
+ * @param sort sort
+ * @return this
+ */
+ public BaseData setSort(final Integer sort) {
+ this.sort = sort;
+ return this;
+ }
+
+ /**
+ * get namespaceId.
+ *
+ * @return namespaceId
+ */
+ public String getNamespaceId() {
+ return namespaceId;
+ }
+
+ /**
+ * set namespaceId.
+ *
+ * @param namespaceId namespaceId
+ * @return this
+ */
+ public BaseData setNamespaceId(final String namespaceId) {
+ this.namespaceId = namespaceId;
+ return this;
+ }
+}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java
index 1ed11aa14a..a93e39e3f6 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java
@@ -24,24 +24,14 @@ import java.util.Objects;
*
* @since 2.0.0
*/
-public class PluginData {
-
- private String id;
-
- private String name;
+public class PluginData extends BaseData {
private String config;
private String role;
- private Boolean enabled;
-
- private Integer sort;
-
private String pluginJar;
- private String namespaceId;
-
/**
* no args constructor.
*/
@@ -58,11 +48,11 @@ public class PluginData {
* @param enabled enabled
*/
public PluginData(final String id, final String name, final String config,
final String role, final Boolean enabled, final String pluginJar) {
- this.id = id;
- this.name = name;
+ this.setId(id);
+ this.setName(name);
this.config = config;
this.role = role;
- this.enabled = enabled;
+ this.setEnabled(enabled);
this.pluginJar = pluginJar;
}
@@ -78,30 +68,15 @@ public class PluginData {
*/
public PluginData(final String id, final String name, final String config,
final String role, final Boolean enabled,
final Integer sort, final String pluginJar) {
- this.id = id;
- this.name = name;
+ this.setId(id);
+ this.setName(name);
this.config = config;
this.role = role;
- this.enabled = enabled;
- this.sort = sort;
+ this.setEnabled(enabled);
+ this.setSort(sort);
this.pluginJar = pluginJar;
}
- /**
- * builder constructor.
- *
- * @param builder builder
- */
- private PluginData(final Builder builder) {
- this.id = builder.id;
- this.name = builder.name;
- this.config = builder.config;
- this.role = builder.role;
- this.enabled = builder.enabled;
- this.sort = builder.sort;
- this.pluginJar = builder.pluginJar;
- }
-
/**
* all args constructor.
*
@@ -113,14 +88,14 @@ public class PluginData {
* @param sort sort
*/
public PluginData(final String id, final String name, final String config,
final String role, final Boolean enabled, final Integer sort, final String
pluginJar, final String namespaceId) {
- this.id = id;
- this.name = name;
+ this.setId(id);
+ this.setName(name);
this.config = config;
this.role = role;
- this.enabled = enabled;
- this.sort = sort;
+ this.setEnabled(enabled);
+ this.setSort(sort);
this.pluginJar = pluginJar;
- this.namespaceId = namespaceId;
+ this.setNamespaceId(namespaceId);
}
/**
@@ -132,42 +107,6 @@ public class PluginData {
return new Builder();
}
- /**
- * get id.
- *
- * @return id
- */
- public String getId() {
- return id;
- }
-
- /**
- * set id.
- *
- * @param id id
- */
- public void setId(final String id) {
- this.id = id;
- }
-
- /**
- * get name.
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-
- /**
- * set name.
- *
- * @param name name
- */
- public void setName(final String name) {
- this.name = name;
- }
-
/**
* get config.
*
@@ -204,15 +143,6 @@ public class PluginData {
this.role = role;
}
- /**
- * get enabled.
- *
- * @return enabled
- */
- public Boolean getEnabled() {
- return enabled;
- }
-
/**
* get pluginJar.
*
@@ -231,52 +161,6 @@ public class PluginData {
this.pluginJar = pluginJar;
}
- /**
- * get sort.
- *
- * @return enabled
- */
- public Integer getSort() {
- return sort;
- }
-
-
- /**
- * set sort.
- *
- * @param sort sort value
- */
- public void setSort(final Integer sort) {
- this.sort = sort;
- }
-
- /**
- * set enabled.
- *
- * @param enabled enabled
- */
- public void setEnabled(final Boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * get namespaceId.
- *
- * @return namespaceId
- */
- public String getNamespaceId() {
- return namespaceId;
- }
-
- /**
- * set namespaceId.
- *
- * @param namespaceId namespaceId
- */
- public void setNamespaceId(final String namespaceId) {
- this.namespaceId = namespaceId;
- }
-
@Override
public boolean equals(final Object o) {
if (this == o) {
@@ -286,14 +170,14 @@ public class PluginData {
return false;
}
PluginData that = (PluginData) o;
- return Objects.equals(id, that.id) && Objects.equals(name, that.name)
&& Objects.equals(config, that.config)
- && Objects.equals(role, that.role) && Objects.equals(enabled,
that.enabled) && Objects.equals(sort, that.sort)
- && Objects.equals(pluginJar, that.pluginJar) &&
Objects.equals(namespaceId, that.namespaceId);
+ return Objects.equals(getId(), that.getId()) &&
Objects.equals(getName(), that.getName()) && Objects.equals(config, that.config)
+ && Objects.equals(role, that.role) &&
Objects.equals(getEnabled(), that.getEnabled()) && Objects.equals(getSort(),
that.getSort())
+ && Objects.equals(pluginJar, that.pluginJar) &&
Objects.equals(getNamespaceId(), that.getNamespaceId());
}
@Override
public int hashCode() {
- return Objects.hash(id, name, config, role, enabled, sort, pluginJar,
namespaceId);
+ return Objects.hash(getId(), getName(), config, role, getEnabled(),
getSort(), pluginJar, getNamespaceId());
}
public static final class Builder {
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java
index 2e2efa05d4..ec3fef65f6 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java
@@ -25,11 +25,7 @@ import java.util.Objects;
*
* @since 2.0.0
*/
-public class RuleData {
-
- private String id;
-
- private String name;
+public class RuleData extends BaseData {
private String pluginName;
@@ -40,10 +36,6 @@ public class RuleData {
*/
private Integer matchMode;
- private Integer sort;
-
- private Boolean enabled;
-
private Boolean loged;
/**
@@ -59,11 +51,6 @@ public class RuleData {
* match restful.
*/
private Boolean matchRestful;
-
- /**
- * namespaceId.
- */
- private String namespaceId;
/**
* no args constructor.
@@ -77,19 +64,19 @@ public class RuleData {
* @param builder builder
*/
private RuleData(final Builder builder) {
- this.id = builder.id;
- this.name = builder.name;
+ this.setId(builder.id);
+ this.setName(builder.name);
this.pluginName = builder.pluginName;
this.selectorId = builder.selectorId;
this.matchMode = builder.matchMode;
- this.sort = builder.sort;
- this.enabled = builder.enabled;
+ this.setSort(builder.sort);
+ this.setEnabled(builder.enabled);
this.loged = builder.loged;
this.handle = builder.handle;
this.conditionDataList = builder.conditionDataList;
this.beforeConditionDataList = builder.beforeConditionDataList;
this.matchRestful = builder.matchRestful;
- this.namespaceId = builder.namespaceId;
+ this.setNamespaceId(builder.namespaceId);
}
/**
@@ -102,32 +89,34 @@ public class RuleData {
}
/**
- * get id.
+ * get pluginName.
*
- * @return id
+ * @return pluginName
*/
- public String getId() {
- return id;
+ public String getPluginName() {
+ return pluginName;
}
/**
- * set id.
+ * set pluginName.
*
- * @param id id
+ * @param pluginName pluginName
* @return this
*/
- public RuleData setId(final String id) {
- this.id = id;
+ public RuleData setPluginName(final String pluginName) {
+ this.pluginName = pluginName;
return this;
}
/**
- * get name.
+ * set id.
*
- * @return name
+ * @param id id
+ * @return this
*/
- public String getName() {
- return name;
+ public RuleData setId(final String id) {
+ super.setId(id);
+ return this;
}
/**
@@ -137,27 +126,40 @@ public class RuleData {
* @return this
*/
public RuleData setName(final String name) {
- this.name = name;
+ super.setName(name);
return this;
}
/**
- * get pluginName.
+ * set sort.
*
- * @return pluginName
+ * @param sort sort
+ * @return this
*/
- public String getPluginName() {
- return pluginName;
+ public RuleData setSort(final Integer sort) {
+ super.setSort(sort);
+ return this;
}
/**
- * set pluginName.
+ * set enabled.
*
- * @param pluginName pluginName
+ * @param enabled enabled
* @return this
*/
- public RuleData setPluginName(final String pluginName) {
- this.pluginName = pluginName;
+ public RuleData setEnabled(final Boolean enabled) {
+ super.setEnabled(enabled);
+ return this;
+ }
+
+ /**
+ * set namespaceId.
+ *
+ * @param namespaceId namespaceId
+ * @return this
+ */
+ public RuleData setNamespaceId(final String namespaceId) {
+ super.setNamespaceId(namespaceId);
return this;
}
@@ -201,46 +203,6 @@ public class RuleData {
return this;
}
- /**
- * get sort.
- *
- * @return sort
- */
- public Integer getSort() {
- return sort;
- }
-
- /**
- * set sort.
- *
- * @param sort sort
- * @return this
- */
- public RuleData setSort(final Integer sort) {
- this.sort = sort;
- return this;
- }
-
- /**
- * get enabled.
- *
- * @return enabled
- */
- public Boolean getEnabled() {
- return enabled;
- }
-
- /**
- * set enabled.
- *
- * @param enabled enabled
- * @return this
- */
- public RuleData setEnabled(final Boolean enabled) {
- this.enabled = enabled;
- return this;
- }
-
/**
* get loged.
*
@@ -337,22 +299,6 @@ public class RuleData {
this.matchRestful = matchRestful;
}
- /**
- * get namespaceId.
- * @return namespaceId
- */
- public String getNamespaceId() {
- return namespaceId;
- }
-
- /**
- * set namespaceId.
- * @param namespaceId namespaceId
- */
- public void setNamespaceId(final String namespaceId) {
- this.namespaceId = namespaceId;
- }
-
@Override
public boolean equals(final Object o) {
if (this == o) {
@@ -362,35 +308,35 @@ public class RuleData {
return false;
}
final RuleData ruleData = (RuleData) o;
- return Objects.equals(id, ruleData.id)
- && Objects.equals(name, ruleData.name)
+ return Objects.equals(getId(), ruleData.getId())
+ && Objects.equals(getName(), ruleData.getName())
&& Objects.equals(pluginName, ruleData.pluginName)
&& Objects.equals(selectorId, ruleData.selectorId)
&& Objects.equals(matchMode, ruleData.matchMode)
- && Objects.equals(sort, ruleData.sort)
- && Objects.equals(enabled, ruleData.enabled)
+ && Objects.equals(getSort(), ruleData.getSort())
+ && Objects.equals(getEnabled(), ruleData.getEnabled())
&& Objects.equals(loged, ruleData.loged)
&& Objects.equals(handle, ruleData.handle)
&& Objects.equals(conditionDataList,
ruleData.conditionDataList)
&& Objects.equals(beforeConditionDataList,
ruleData.beforeConditionDataList)
&& Objects.equals(matchRestful, ruleData.matchRestful)
- && Objects.equals(namespaceId, ruleData.namespaceId);
+ && Objects.equals(getNamespaceId(), ruleData.getNamespaceId());
}
@Override
public int hashCode() {
- return Objects.hash(id, name, pluginName, selectorId, matchMode, sort,
enabled, loged, handle, conditionDataList,
- beforeConditionDataList, matchRestful, namespaceId);
+ return Objects.hash(getId(), getName(), pluginName, selectorId,
matchMode, getSort(), getEnabled(), loged, handle, conditionDataList,
+ beforeConditionDataList, matchRestful, getNamespaceId());
}
@Override
public String toString() {
return "RuleData{"
+ "id='"
- + id
+ + getId()
+ '\''
+ ", name='"
- + name
+ + getName()
+ '\''
+ ", pluginName='"
+ pluginName
@@ -401,9 +347,9 @@ public class RuleData {
+ ", matchMode="
+ matchMode
+ ", sort="
- + sort
+ + getSort()
+ ", enabled="
- + enabled
+ + getEnabled()
+ ", loged="
+ loged
+ ", handle='"
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java
index 616154c1a1..c6aec37add 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java
@@ -25,9 +25,7 @@ import java.util.Objects;
*
* @since 2.0.0
*/
-public class SelectorData {
-
- private String id;
+public class SelectorData extends BaseData {
private String pluginId;
@@ -36,8 +34,6 @@ public class SelectorData {
*/
private String pluginName;
- private String name;
-
/**
* matchMode(0 and 1 or).
*/
@@ -48,10 +44,6 @@ public class SelectorData {
*/
private Integer type;
- private Integer sort;
-
- private Boolean enabled;
-
private Boolean logged;
private Boolean continued = Boolean.TRUE;
@@ -67,11 +59,6 @@ public class SelectorData {
*/
private Boolean matchRestful;
- /**
- * namespaceId.
- */
- private String namespaceId;
-
/**
* no args constructor.
*/
@@ -84,21 +71,21 @@ public class SelectorData {
* @param builder builder
*/
private SelectorData(final Builder builder) {
- this.id = builder.id;
+ this.setId(builder.id);
this.pluginId = builder.pluginId;
this.pluginName = builder.pluginName;
- this.name = builder.name;
+ this.setName(builder.name);
this.matchMode = builder.matchMode;
this.type = builder.type;
- this.sort = builder.sort;
- this.enabled = builder.enabled;
+ this.setSort(builder.sort);
+ this.setEnabled(builder.enabled);
this.logged = builder.logged;
this.continued = builder.continued;
this.handle = builder.handle;
this.conditionList = builder.conditionList;
this.matchRestful = builder.matchRestful;
this.beforeConditionList = builder.beforeConditionList;
- this.namespaceId = builder.namespaceId;
+ this.setNamespaceId(builder.namespaceId);
}
/**
@@ -110,24 +97,6 @@ public class SelectorData {
return new Builder();
}
- /**
- * get id.
- *
- * @return id
- */
- public String getId() {
- return id;
- }
-
- /**
- * set id.
- *
- * @param id id
- */
- public void setId(final String id) {
- this.id = id;
- }
-
/**
* get pluginId.
*
@@ -164,24 +133,6 @@ public class SelectorData {
this.pluginName = pluginName;
}
- /**
- * get name.
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-
- /**
- * set name.
- *
- * @param name name
- */
- public void setName(final String name) {
- this.name = name;
- }
-
/**
* get matchMode.
*
@@ -218,42 +169,6 @@ public class SelectorData {
this.type = type;
}
- /**
- * get sort.
- *
- * @return sort
- */
- public Integer getSort() {
- return sort;
- }
-
- /**
- * set sort.
- *
- * @param sort sort
- */
- public void setSort(final Integer sort) {
- this.sort = sort;
- }
-
- /**
- * get enabled.
- *
- * @return enabled
- */
- public Boolean getEnabled() {
- return enabled;
- }
-
- /**
- * set enabled.
- *
- * @param enabled enabled
- */
- public void setEnabled(final Boolean enabled) {
- this.enabled = enabled;
- }
-
/**
* get logged.
*
@@ -365,24 +280,6 @@ public class SelectorData {
this.beforeConditionList = beforeConditionList;
}
- /**
- * get namespaceId.
- *
- * @return namespaceId
- */
- public String getNamespaceId() {
- return namespaceId;
- }
-
- /**
- * set namespaceId.
- *
- * @param namespaceId namespaceId
- */
- public void setNamespaceId(final String namespaceId) {
- this.namespaceId = namespaceId;
- }
-
@Override
public boolean equals(final Object o) {
if (this == o) {
@@ -392,24 +289,25 @@ public class SelectorData {
return false;
}
SelectorData that = (SelectorData) o;
- return Objects.equals(id, that.id) && Objects.equals(pluginId,
that.pluginId) && Objects.equals(pluginName, that.pluginName)
- && Objects.equals(name, that.name) &&
Objects.equals(matchMode, that.matchMode) && Objects.equals(type, that.type)
- && Objects.equals(sort, that.sort) && Objects.equals(enabled,
that.enabled) && Objects.equals(logged, that.logged)
+ return Objects.equals(getId(), that.getId()) &&
Objects.equals(pluginId, that.pluginId) && Objects.equals(pluginName,
that.pluginName)
+ && Objects.equals(getName(), that.getName()) &&
Objects.equals(matchMode, that.matchMode) && Objects.equals(type, that.type)
+ && Objects.equals(getSort(), that.getSort()) &&
Objects.equals(getEnabled(), that.getEnabled()) && Objects.equals(logged,
that.logged)
&& Objects.equals(continued, that.continued) &&
Objects.equals(handle, that.handle) && Objects.equals(conditionList,
that.conditionList)
&& Objects.equals(beforeConditionList,
that.beforeConditionList) && Objects.equals(matchRestful, that.matchRestful)
- && Objects.equals(namespaceId, that.namespaceId);
+ && Objects.equals(getNamespaceId(), that.getNamespaceId());
}
@Override
public int hashCode() {
- return Objects.hash(id, pluginId, pluginName, name, matchMode, type,
sort, enabled, logged, continued, handle, conditionList, beforeConditionList,
matchRestful, namespaceId);
+ return Objects.hash(getId(), pluginId, pluginName, getName(),
matchMode, type, getSort(), getEnabled(), logged, continued, handle,
+ conditionList, beforeConditionList, matchRestful,
getNamespaceId());
}
@Override
public String toString() {
return "SelectorData{"
+ "id='"
- + id
+ + getId()
+ '\''
+ ", pluginId='"
+ pluginId
@@ -418,16 +316,16 @@ public class SelectorData {
+ pluginName
+ '\''
+ ", name='"
- + name
+ + getName()
+ '\''
+ ", matchMode="
+ matchMode
+ ", type="
+ type
+ ", sort="
- + sort
+ + getSort()
+ ", enabled="
- + enabled
+ + getEnabled()
+ ", logged="
+ logged
+ ", continued="
@@ -440,7 +338,7 @@ public class SelectorData {
+ ", matchRestful="
+ matchRestful
+ ", namespaceId="
- + namespaceId
+ + getNamespaceId()
+ '}';
}
@@ -451,12 +349,12 @@ public class SelectorData {
private String id;
+ private String name;
+
private String pluginId;
private String pluginName;
- private String name;
-
private Integer matchMode;
private Integer type;