View Javadoc
1   package com.kodexa.client.pipeline;
2   
3   import lombok.Getter;
4   import org.apache.commons.lang3.SerializationUtils;
5   
6   import java.util.HashMap;
7   import java.util.Map;
8   
9   /**
10   * A simple structure for capturing the options for a Kodexa
11   * Cloud Action in Java
12   */
13  public class Options {
14  
15      @Getter
16      private final Map<String, Object> map = new HashMap<>();
17  
18      @Getter
19      private boolean attachSource = false;
20  
21      @Getter
22      private boolean enabled = true;
23  
24      @Getter
25      private boolean parameterized;
26  
27      @Getter
28      private String condition;
29  
30      public Options set(String name, Object value) {
31          map.put(name, value);
32          return this;
33      }
34  
35      public static Options start() {
36          return new Options();
37      }
38  
39      public Options enabled(boolean enabled) {
40          this.enabled = enabled;
41          return this;
42      }
43  
44      public Options parameterized(boolean parameterized) {
45          this.parameterized = parameterized;
46          return this;
47      }
48  
49      public Options condition(String condition) {
50          this.condition = condition;
51          return this;
52      }
53  
54      public Options attachSource() {
55          this.attachSource = true;
56          return this;
57      }
58  
59      public Map<String, Object> get() {
60          return map;
61      }
62  
63      public Options createClone() {
64          Options newOptions = Options.start();
65          newOptions.condition(this.condition);
66          newOptions.enabled(this.enabled);
67          if (this.isAttachSource()) {
68              newOptions.attachSource();
69          }
70  
71          this.getMap().forEach((k, v) -> {
72              newOptions.set(k, v);
73          });
74  
75          return newOptions;
76      }
77  }