diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java new file mode 100644 index 0000000000000000000000000000000000000000..5d85537f49296ef94c6d7468535fc9ede6002868 --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java @@ -0,0 +1,31 @@ +package com.ctrip.framework.apollo.portal.entity.vo; + +import com.ctrip.framework.apollo.portal.enums.ChangeType; + +public class Change { + + private ChangeType type; + private EntityPair entity; + + public Change(ChangeType type, EntityPair entity) { + this.type = type; + this.entity = entity; + } + + public ChangeType getType() { + return type; + } + + public void setType(ChangeType type) { + this.type = type; + } + + public EntityPair getEntity() { + return entity; + } + + public void setEntity( + EntityPair entity) { + this.entity = entity; + } +} diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java index f3eeac40d114687aee8836e1fc28c7ed2a5c5b2a..bad3377ff0bcce052ecbdddc8017bb875334b6ae 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java @@ -1,5 +1,7 @@ package com.ctrip.framework.apollo.portal.entity.vo; +import com.ctrip.framework.apollo.portal.enums.ChangeType; + import java.util.LinkedList; import java.util.List; @@ -19,35 +21,4 @@ public class ReleaseCompareResult { this.changes = changes; } - public class Change { - - private ChangeType type; - private EntityPair entity; - - public Change(ChangeType type, EntityPair entity) { - this.type = type; - this.entity = entity; - } - - public ChangeType getType() { - return type; - } - - public void setType(ChangeType type) { - this.type = type; - } - - public EntityPair getEntity() { - return entity; - } - - public void setEntity( - EntityPair entity) { - this.entity = entity; - } - } - - public enum ChangeType { - ADD, MODIFY, DELETE - } } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java new file mode 100644 index 0000000000000000000000000000000000000000..f063fc1dfb66f4cde3937063910f553fc2c7b2a6 --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java @@ -0,0 +1,5 @@ +package com.ctrip.framework.apollo.portal.enums; + +public enum ChangeType { + ADD, MODIFY, DELETE +} diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java index e9a49e2851f1ed95ebec6b3129bac3c03caf76e9..154b8080ea4bec1c4c9187047258fd420494a8bc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java @@ -12,6 +12,7 @@ import com.ctrip.framework.apollo.portal.entity.form.NamespaceReleaseModel; import com.ctrip.framework.apollo.portal.entity.vo.KVEntity; import com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult; import com.ctrip.framework.apollo.portal.entity.vo.ReleaseVO; +import com.ctrip.framework.apollo.portal.enums.ChangeType; import com.dianping.cat.Cat; import org.springframework.beans.factory.annotation.Autowired; @@ -100,10 +101,10 @@ public class ReleaseService { String secondValue = secondItems.get(key); //added if (secondValue == null) { - compareResult.addEntityPair(ReleaseCompareResult.ChangeType.DELETE, new KVEntity(key, firstValue), + compareResult.addEntityPair(ChangeType.DELETE, new KVEntity(key, firstValue), new KVEntity(key, secondValue)); } else if (!Objects.equal(firstValue, secondValue)) { - compareResult.addEntityPair(ReleaseCompareResult.ChangeType.MODIFY, new KVEntity(key, firstValue), + compareResult.addEntityPair(ChangeType.MODIFY, new KVEntity(key, firstValue), new KVEntity(key, secondValue)); } @@ -115,7 +116,7 @@ public class ReleaseService { String value = entry.getValue(); if (firstItems.get(key) == null) { compareResult - .addEntityPair(ReleaseCompareResult.ChangeType.ADD, new KVEntity(key, ""), new KVEntity(key, value)); + .addEntityPair(ChangeType.ADD, new KVEntity(key, ""), new KVEntity(key, value)); } }