aboutsummaryrefslogtreecommitdiffstats
path: root/entity/merge.go
diff options
context:
space:
mode:
Diffstat (limited to 'entity/merge.go')
-rw-r--r--entity/merge.go37
1 files changed, 25 insertions, 12 deletions
diff --git a/entity/merge.go b/entity/merge.go
index 7d1f3f43..1b68b4de 100644
--- a/entity/merge.go
+++ b/entity/merge.go
@@ -24,10 +24,10 @@ type MergeResult struct {
Id Id
Status MergeStatus
- // Only set for invalid status
+ // Only set for Invalid status
Reason string
- // Not set for invalid status
+ // Only set for New or Updated status
Entity Interface
}
@@ -48,29 +48,42 @@ func (mr MergeResult) String() string {
}
}
-func NewMergeError(err error, id Id) MergeResult {
+// TODO: Interface --> *Entity ?
+func NewMergeNewStatus(id Id, entity Interface) MergeResult {
return MergeResult{
- Err: err,
Id: id,
- Status: MergeStatusError,
+ Status: MergeStatusNew,
+ Entity: entity,
}
}
-// TODO: Interface --> *Entity ?
-func NewMergeStatus(status MergeStatus, id Id, entity Interface) MergeResult {
+func NewMergeInvalidStatus(id Id, reason string) MergeResult {
return MergeResult{
Id: id,
- Status: status,
+ Status: MergeStatusInvalid,
+ Reason: reason,
+ }
+}
- // Entity is not set for an invalid merge result
+func NewMergeUpdatedStatus(id Id, entity Interface) MergeResult {
+ return MergeResult{
+ Id: id,
+ Status: MergeStatusUpdated,
Entity: entity,
}
}
-func NewMergeInvalidStatus(id Id, reason string) MergeResult {
+func NewMergeNothingStatus(id Id) MergeResult {
return MergeResult{
Id: id,
- Status: MergeStatusInvalid,
- Reason: reason,
+ Status: MergeStatusNothing,
+ }
+}
+
+func NewMergeError(err error, id Id) MergeResult {
+ return MergeResult{
+ Id: id,
+ Status: MergeStatusError,
+ Err: err,
}
}