MohammadMu99 commented on code in PR #7259:
URL: https://github.com/apache/incubator-kie/pull/7259#discussion_r4534672924


##########
kogito-jbpm/jbpm-flow-migration/src/main/java/org/jbpm/flow/migration/model/VariableMigrationPlan.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.jbpm.flow.migration.model;
+
+import java.util.Objects;
+
+/**
+ * A rule that changes a process instance variable while the instance is 
migrated.
+ * Which fields are used depends on the {@link VariableMigrationAction}:
+ * <ul>
+ * <li>{@code rename}: {@code from} and {@code to}</li>
+ * <li>{@code default}: {@code name} and {@code value}</li>
+ * <li>{@code remove}: {@code name}</li>
+ * </ul>
+ */
+public class VariableMigrationPlan {
+
+    private VariableMigrationAction action;
+    private String name;
+    private String from;
+    private String to;
+    private Object value;
+
+    public VariableMigrationPlan() {
+        // do nothing
+    }
+
+    public VariableMigrationPlan(VariableMigrationAction action, String name, 
String from, String to, Object value) {
+        this.action = action;
+        this.name = name;
+        this.from = from;
+        this.to = to;
+        this.value = value;
+    }
+
+    public VariableMigrationAction getAction() {
+        return action;
+    }
+
+    public void setAction(VariableMigrationAction action) {
+        this.action = action;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public String getTo() {
+        return to;
+    }
+
+    public void setTo(String to) {
+        this.to = to;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    /**
+     * Checks that the fields required by the action are present.
+     *
+     * @throws IllegalArgumentException if the action or one of its required 
fields is missing
+     */
+    public void validate() {
+        if (action == null) {
+            throw new IllegalArgumentException("Variable migration plan 
without action: " + this);
+        }
+        switch (action) {
+            case RENAME:
+                requireField("from", from);
+                requireField("to", to);

Review Comment:
   Done, `validate()` now throws for a `rename` whose `from` and `to` are the 
same, so the `.mpf` fails to load. Covered by 
`testReadingVariableMigrationPlanRenamingToItself`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to