commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [2/2] commons-scxml git commit: SCXML-278 Code cleanup and Java8 alignment
Date Sun, 07 Jan 2018 15:34:34 GMT
SCXML-278 Code cleanup and Java8 alignment

- remove obsolete code, unused imports
- remove duplicate code, move repeated code up to parent class
- cleanup exception handling
- align with Java8, remove unnessesary type casting, make use of lamba's where useful
- fixup references to current/final SCXML spec urls
- apply protected, private, static, and/or final scoping of fields and methods where possible


Project: http://git-wip-us.apache.org/repos/asf/commons-scxml/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-scxml/commit/05e94b82
Tree: http://git-wip-us.apache.org/repos/asf/commons-scxml/tree/05e94b82
Diff: http://git-wip-us.apache.org/repos/asf/commons-scxml/diff/05e94b82

Branch: refs/heads/master
Commit: 05e94b8229535800e57c82a04dea764714cd4ef0
Parents: 9fb7a63
Author: Ate Douma <ate@apache.org>
Authored: Sun Jan 7 16:26:10 2018 +0100
Committer: Ate Douma <ate@apache.org>
Committed: Sun Jan 7 16:34:06 2018 +0100

----------------------------------------------------------------------
 src/changes/changes.xml                         |  6 +-
 .../apache/commons/scxml2/EvaluatorFactory.java |  2 +-
 .../scxml2/ExternalSCXMLIOProcessor.java        |  2 +-
 .../commons/scxml2/NotificationRegistry.java    |  8 +-
 .../org/apache/commons/scxml2/SCInstance.java   |  2 +-
 .../commons/scxml2/SCXMLExecutionContext.java   | 35 +++----
 .../apache/commons/scxml2/SCXMLExecutor.java    | 10 +-
 .../scxml2/SCXMLExpressionException.java        |  1 -
 .../apache/commons/scxml2/SCXMLSemantics.java   |  4 +-
 .../commons/scxml2/SCXMLSystemContext.java      |  5 +-
 .../commons/scxml2/StateConfiguration.java      |  4 +-
 .../scxml2/env/AbstractBaseEvaluator.java       | 28 +++++-
 .../scxml2/env/AbstractStateMachine.java        | 21 +----
 .../org/apache/commons/scxml2/env/LogUtils.java | 12 +--
 .../commons/scxml2/env/SimpleContext.java       | 17 +---
 .../commons/scxml2/env/SimpleDispatcher.java    | 39 +++-----
 .../commons/scxml2/env/SimpleErrorHandler.java  |  2 +-
 .../commons/scxml2/env/SimpleErrorReporter.java | 12 +--
 .../commons/scxml2/env/SimpleSCXMLListener.java |  2 +-
 .../commons/scxml2/env/SimpleXMLReporter.java   |  2 +-
 .../org/apache/commons/scxml2/env/Tracer.java   |  8 +-
 .../apache/commons/scxml2/env/URLResolver.java  |  2 +-
 .../scxml2/env/groovy/GroovyContextBinding.java |  2 +-
 .../scxml2/env/groovy/GroovyEvaluator.java      | 25 -----
 .../env/groovy/GroovyExtendableScriptCache.java | 30 ++----
 .../scxml2/env/groovy/GroovySCXMLScript.java    |  6 +-
 .../scxml2/env/javascript/JSBindings.java       |  4 +-
 .../scxml2/env/javascript/JSEvaluator.java      | 24 -----
 .../scxml2/env/javascript/init_global.js        |  2 +-
 .../commons/scxml2/env/jexl/JexlEvaluator.java  | 28 +-----
 .../commons/scxml2/invoke/InvokerException.java |  7 --
 .../scxml2/invoke/SimpleSCXMLInvoker.java       | 12 +--
 .../apache/commons/scxml2/io/ContentParser.java |  8 +-
 .../apache/commons/scxml2/io/ModelUpdater.java  | 43 ++++-----
 .../apache/commons/scxml2/io/SCXMLReader.java   | 27 +++---
 .../apache/commons/scxml2/io/SCXMLWriter.java   | 97 +++++++++-----------
 .../org/apache/commons/scxml2/model/Action.java | 11 +--
 .../apache/commons/scxml2/model/Datamodel.java  |  4 +-
 .../commons/scxml2/model/DocumentOrder.java     | 14 +--
 .../commons/scxml2/model/EnterableState.java    |  9 +-
 .../apache/commons/scxml2/model/Executable.java |  5 +-
 .../org/apache/commons/scxml2/model/Final.java  |  2 +-
 .../apache/commons/scxml2/model/Foreach.java    |  3 +-
 .../org/apache/commons/scxml2/model/If.java     |  4 +-
 .../commons/scxml2/model/NodeTextValue.java     |  2 +-
 .../org/apache/commons/scxml2/model/Param.java  |  1 -
 .../commons/scxml2/model/PayloadBuilder.java    | 10 +-
 .../commons/scxml2/model/PayloadProvider.java   | 84 -----------------
 .../org/apache/commons/scxml2/model/SCXML.java  | 32 +------
 .../org/apache/commons/scxml2/model/Send.java   |  2 +-
 .../commons/scxml2/model/SimpleTransition.java  |  9 +-
 .../apache/commons/scxml2/model/Transition.java |  2 +-
 .../commons/scxml2/model/TransitionType.java    |  4 +-
 .../commons/scxml2/model/TransitionalState.java | 19 ++--
 .../org/apache/commons/scxml2/model/Var.java    |  7 --
 .../scxml2/semantics/SCXMLSemanticsImpl.java    | 75 +++++++--------
 .../apache/commons/scxml2/semantics/Step.java   | 26 +++---
 .../commons/scxml2/test/StandaloneUtils.java    |  6 +-
 .../apache/commons/scxml2/EventDataTest.java    | 10 +-
 .../apache/commons/scxml2/SCInstanceTest.java   |  6 +-
 .../commons/scxml2/SCXMLExecutorTest.java       | 10 +-
 .../apache/commons/scxml2/SCXMLTestHelper.java  | 14 ++-
 .../org/apache/commons/scxml2/WizardsTest.java  |  3 +-
 .../scxml2/env/AbstractStateMachineTest.java    |  8 +-
 .../apache/commons/scxml2/env/StopWatch.java    |  4 +-
 .../commons/scxml2/env/StopWatchDisplay.java    |  7 +-
 .../scxml2/env/groovy/GroovyContextTest.java    |  2 +-
 .../scxml2/env/javascript/JSEvaluatorTest.java  | 39 ++++----
 .../scxml2/env/javascript/JSExampleTest.java    |  4 +-
 .../scxml2/env/jexl/JexlContextTest.java        | 13 +--
 .../scxml2/env/jexl/JexlEvaluatorTest.java      |  6 +-
 .../scxml2/invoke/InvokeParamNameTest.java      |  4 +-
 .../commons/scxml2/io/ContentParserTest.java    |  2 +-
 .../commons/scxml2/io/SCXMLReaderTest.java      | 33 +++----
 .../scxml2/io/SCXMLRequiredAttributesTest.java  |  2 +-
 .../commons/scxml2/io/SCXMLWriterTest.java      |  4 +-
 .../commons/scxml2/issues/Issue112Test.java     |  9 +-
 .../commons/scxml2/model/ActionsTest.java       |  2 +-
 .../commons/scxml2/model/CustomActionTest.java  |  8 +-
 .../org/apache/commons/scxml2/model/Hello.java  |  2 -
 .../apache/commons/scxml2/model/SendTest.java   |  4 +-
 .../semantics/SCXMLSemanticsImplTest.java       |  8 +-
 .../org/apache/commons/scxml2/w3c/W3CTests.java | 38 ++++----
 83 files changed, 392 insertions(+), 720 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6645a8b..cadc1ba 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -35,6 +35,10 @@
     <release version="2.0" date="In Git master"
       description="Latest unreleased code">
 
+      <action dev="ate" type="add" issue="SCXML-278">
+        [07-01-2018] Code cleanup and Java8 alignment
+      </action>
+
       <action dev="ate" type="add" issue="SCXML-271">
         [12-11-2017] Support Groovy for running the SCXML IRP tests
       </action>
@@ -60,7 +64,7 @@
       </action>
 
       <action dev="ate" type="add" issue="SCXML-264">
-        [12-10-2017] Support &lt;invoke&gt; with inline (<content> body) SCXML statemachine definition
+        [12-10-2017] Support &lt;invoke&gt; with inline (&lt;content&gt; body) SCXML statemachine definition
       </action>
 
       <action dev="ate" type="fix" issue="SCXML-263">

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java b/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
index 784affa..0024d4c 100644
--- a/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
+++ b/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
@@ -54,7 +54,7 @@ import static org.apache.commons.scxml2.Evaluator.DEFAULT_DATA_MODEL;
  */
 public class EvaluatorFactory {
 
-    private static EvaluatorFactory INSTANCE = new EvaluatorFactory();
+    private static final EvaluatorFactory INSTANCE = new EvaluatorFactory();
 
     private final Map<String, EvaluatorProvider> providers = new ConcurrentHashMap<>();
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/ExternalSCXMLIOProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/ExternalSCXMLIOProcessor.java b/src/main/java/org/apache/commons/scxml2/ExternalSCXMLIOProcessor.java
index be14a3d..a68fb55 100644
--- a/src/main/java/org/apache/commons/scxml2/ExternalSCXMLIOProcessor.java
+++ b/src/main/java/org/apache/commons/scxml2/ExternalSCXMLIOProcessor.java
@@ -25,7 +25,7 @@ package org.apache.commons.scxml2;
  */
 public class ExternalSCXMLIOProcessor implements SCXMLIOProcessor {
 
-    private SCXMLIOProcessor processor;
+    private final SCXMLIOProcessor processor;
 
     public ExternalSCXMLIOProcessor(final SCXMLIOProcessor processor) {
         this.processor = processor;

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java b/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java
index 6db5836..34291ea 100644
--- a/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java
+++ b/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java
@@ -46,7 +46,7 @@ public final class NotificationRegistry {
      * Constructor.
      */
     public NotificationRegistry() {
-        this.regs = new HashMap<Integer, Set<SCXMLListener>>();
+        this.regs = new HashMap<>();
     }
 
     /**
@@ -57,11 +57,7 @@ public final class NotificationRegistry {
      */
     synchronized void addListener(final Observable source, final SCXMLListener lst) {
         if (source != null && source.getObservableId() != null) {
-            Set<SCXMLListener> entries = regs.get(source.getObservableId());
-            if (entries == null) {
-                entries = new LinkedHashSet<SCXMLListener>();
-                regs.put(source.getObservableId(), entries);
-            }
+            Set<SCXMLListener> entries = regs.computeIfAbsent(source.getObservableId(), k -> new LinkedHashSet<>());
             entries.add(lst);
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/SCInstance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCInstance.java b/src/main/java/org/apache/commons/scxml2/SCInstance.java
index c293afa..baa35e3 100644
--- a/src/main/java/org/apache/commons/scxml2/SCInstance.java
+++ b/src/main/java/org/apache/commons/scxml2/SCInstance.java
@@ -419,7 +419,7 @@ public class SCInstance implements Serializable {
      * @throws IllegalStateException Exception thrown if trying to start the state machine when in a Final state
      */
     public void start() throws IllegalStateException {
-        if (!this.running && running && currentStatus.isFinal()) {
+        if (!this.running &&  currentStatus.isFinal()) {
             throw new IllegalStateException("The state machine is in a Final state and cannot be set running again");
         }
         this.running = true;

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java b/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
index ec4dcea..6f827f1 100644
--- a/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
+++ b/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
@@ -52,7 +52,7 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
     /**
      * SCXML Execution Logger for the application.
      */
-    private Log appLog = LogFactory.getLog(SCXMLExecutionContext.class);
+    private static final Log appLog = LogFactory.getLog(SCXMLExecutionContext.class);
 
     /**
      * The action execution context instance, providing restricted access to this execution context
@@ -77,7 +77,7 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
     /**
      * The external IOProcessor for Invokers to communicate back on
      */
-    private SCXMLIOProcessor externalIOProcessor;
+    private final SCXMLIOProcessor externalIOProcessor;
 
     /**
      * The event dispatcher to interface with external documents etc.
@@ -92,32 +92,32 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
     /**
      * The notification registry.
      */
-    private NotificationRegistry notificationRegistry;
+    private final NotificationRegistry notificationRegistry;
 
     /**
      * The internal event queue
      */
-    private final Queue<TriggerEvent> internalEventQueue = new LinkedList<TriggerEvent>();
+    private final Queue<TriggerEvent> internalEventQueue = new LinkedList<>();
 
     /**
      * The Invoker classes map, keyed by invoke target types (specified using "type" attribute).
      */
-    private final Map<String, Class<? extends Invoker>> invokerClasses = new HashMap<String, Class<? extends Invoker>>();
+    private final Map<String, Class<? extends Invoker>> invokerClasses = new HashMap<>();
 
     /**
      * The map storing the unique invokeId for an Invoke with an active Invoker
      */
-    private final Map<Invoke, String> invokeIds = new HashMap<Invoke, String>();
+    private final Map<Invoke, String> invokeIds = new HashMap<>();
 
     /**
      * The Map of active Invoker, keyed by their unique invokeId.
      */
-    private final Map<String, Invoker> invokers = new HashMap<String, Invoker>();
+    private final Map<String, Invoker> invokers = new HashMap<>();
 
     /**
      * The Map of the current ioProcessors
      */
-    private final Map<String, SCXMLIOProcessor> ioProcessors = new HashMap<String, SCXMLIOProcessor>();
+    private final Map<String, SCXMLIOProcessor> ioProcessors = new HashMap<>();
 
     /**
      * Flag indicating if the SCXML configuration should be checked before execution (default = true)
@@ -211,10 +211,8 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
     }
     /**
      * (re)start the state machine.
-     *
-     * @throws ModelException if the state machine instance failed to initialize.
      */
-    public void start() throws ModelException {
+    public void start() {
         if (scInstance.isRunning()) {
             throw new IllegalStateException("The state machine has already started.");
         } else if (scInstance.getGlobalContext() == null) {
@@ -268,15 +266,6 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
     }
 
     /**
-     * The SCXML specification section "C.1.1 _ioprocessors Value" states that the SCXMLEventProcessor <em>must</em>
-     * maintain a 'location' field inside its entry in the _ioprocessors environment variable.
-     * @return the 'location' of the SCXMLEventProcessor
-     */
-    public String getLocation() {
-        return null;
-    }
-
-    /**
      * @return Returns the SCInstance
      */
     public SCInstance getScInstance() {
@@ -419,7 +408,7 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
      * @param uri
      * @return
      */
-    private final String stripTrailingSlash(final String uri) {
+    private String stripTrailingSlash(final String uri) {
         return uri.endsWith("/") ? uri.substring(0, uri.length()-1) : uri;
     }
 
@@ -458,10 +447,8 @@ public class SCXMLExecutionContext implements SCXMLIOProcessor {
         }
         try {
             return invokerClass.newInstance();
-        } catch (InstantiationException ie) {
+        } catch (InstantiationException | IllegalAccessException ie) {
             throw new InvokerException(ie.getMessage(), ie.getCause());
-        } catch (IllegalAccessException iae) {
-            throw new InvokerException(iae.getMessage(), iae.getCause());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java b/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
index 3be0c7f..5e6ad90 100644
--- a/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
+++ b/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
@@ -51,7 +51,7 @@ public class SCXMLExecutor implements SCXMLIOProcessor {
     /**
      * The Logger for the SCXMLExecutor.
      */
-    private Log log = LogFactory.getLog(SCXMLExecutor.class);
+    private static final Log log = LogFactory.getLog(SCXMLExecutor.class);
 
     /**
      * Parent SCXMLIOProcessor
@@ -61,17 +61,17 @@ public class SCXMLExecutor implements SCXMLIOProcessor {
     /**
      *  Interpretation semantics.
      */
-    private SCXMLSemantics semantics;
+    private final SCXMLSemantics semantics;
 
     /**
      * The state machine execution context
      */
-    private SCXMLExecutionContext exctx;
+    private final SCXMLExecutionContext exctx;
 
     /**
      * The external event queue
      */
-    private final Queue<TriggerEvent> externalEventQueue = new ConcurrentLinkedQueue<TriggerEvent>();
+    private final Queue<TriggerEvent> externalEventQueue = new ConcurrentLinkedQueue<>();
 
     /**
      * Convenience constructor.
@@ -468,7 +468,7 @@ public class SCXMLExecutor implements SCXMLIOProcessor {
                 while (exctx.isRunning()) {
                     triggerEvents();
                 }
-            } catch (ModelException e) {
+            } catch (ModelException ignored) {
             }
         });
         t.start();

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/SCXMLExpressionException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCXMLExpressionException.java b/src/main/java/org/apache/commons/scxml2/SCXMLExpressionException.java
index 8e3ace2..b05b54b 100644
--- a/src/main/java/org/apache/commons/scxml2/SCXMLExpressionException.java
+++ b/src/main/java/org/apache/commons/scxml2/SCXMLExpressionException.java
@@ -32,7 +32,6 @@ public class SCXMLExpressionException extends Exception {
      * @see java.lang.Exception#Exception()
      */
     public SCXMLExpressionException() {
-        super();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java b/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
index 9daca8c..15c254d 100644
--- a/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
+++ b/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
@@ -25,7 +25,7 @@ import org.apache.commons.scxml2.model.SCXML;
 
 /**
  * <p>The purpose of this interface is to separate the the
- * <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#AlgorithmforSCXMLInterpretation">
+ * <a href="https://www.w3.org/TR/2015/REC-scxml-20150901/#AlgorithmforSCXMLInterpretation">
  *     W3C SCXML Algorithm for SCXML Interpretation</a>
  * from the <code>SCXMLExecutor</code> and therefore make it pluggable.</p>
  * <p>
@@ -180,5 +180,5 @@ public interface SCXMLSemantics {
      * @param errRep ErrorReporter to report detailed error info if needed
      * @return true if a given state configuration is legal, false otherwise
      */
-    public boolean isLegalConfiguration(final Set<EnterableState> states, final ErrorReporter errRep);
+    boolean isLegalConfiguration(final Set<EnterableState> states, final ErrorReporter errRep);
 }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java b/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java
index acbcc8e..e865d9f 100644
--- a/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java
+++ b/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java
@@ -59,9 +59,8 @@ public class SCXMLSystemContext implements Context, Serializable {
     /**
      * The set of protected system variables names
      */
-    private static final Set<String> PROTECTED_NAMES = new HashSet<String>(Arrays.asList(
-            new String[] {EVENT_KEY, SESSIONID_KEY, SCXML_NAME_KEY, IOPROCESSORS_KEY, X_KEY}
-    ));
+    private static final Set<String> PROTECTED_NAMES = new HashSet<>(Arrays.asList(
+            EVENT_KEY, SESSIONID_KEY, SCXML_NAME_KEY, IOPROCESSORS_KEY, X_KEY));
 
     /**
      * The wrapped system context

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/StateConfiguration.java b/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
index 1a7ce23..f8f1322 100644
--- a/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
+++ b/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
@@ -35,13 +35,13 @@ public class StateConfiguration implements Serializable {
     /**
      * The states that are currently active.
      */
-    private final Set<EnterableState> activeStates = new HashSet<EnterableState>();
+    private final Set<EnterableState> activeStates = new HashSet<>();
     private final Set<EnterableState> activeStatesSet = Collections.unmodifiableSet(activeStates);
 
     /**
      * The atomic states that are currently active.
      */
-    private final Set<EnterableState> atomicStates = new HashSet<EnterableState>();
+    private final Set<EnterableState> atomicStates = new HashSet<>();
     private final Set<EnterableState> atomicStatesSet = Collections.unmodifiableSet(atomicStates);
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/AbstractBaseEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/AbstractBaseEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/AbstractBaseEvaluator.java
index abd96a4..44239c7 100644
--- a/src/main/java/org/apache/commons/scxml2/env/AbstractBaseEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/AbstractBaseEvaluator.java
@@ -22,8 +22,11 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
+import org.apache.commons.scxml2.Context;
 import org.apache.commons.scxml2.Evaluator;
+import org.apache.commons.scxml2.SCXMLExpressionException;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -32,6 +35,29 @@ import org.w3c.dom.NodeList;
  */
 public abstract class AbstractBaseEvaluator implements Evaluator, Serializable {
 
+    /**
+     * Unique context variable name used for temporary reference to assign data (thus must be a valid variable name)
+     */
+    private static final String ASSIGN_VARIABLE_NAME = "a"+ UUID.randomUUID().toString().replace('-','x');
+
+    /**
+     * @see Evaluator#evalAssign(Context, String, Object)
+     */
+    public void evalAssign(final Context ctx, final String location, final Object data) throws SCXMLExpressionException {
+        StringBuilder sb = new StringBuilder(location).append("=").append(ASSIGN_VARIABLE_NAME);
+        try {
+            ctx.getVars().put(ASSIGN_VARIABLE_NAME, data);
+            eval(ctx, sb.toString());
+        } catch (SCXMLExpressionException e) {
+            if (e.getCause() != null && e.getCause() != null && e.getCause().getMessage() != null) {
+                throw new SCXMLExpressionException("Error evaluating assign to location=\"" + location + "\": " + e.getCause().getMessage());
+            }
+            throw e;
+        } finally {
+            ctx.getVars().remove(ASSIGN_VARIABLE_NAME);
+        }
+    }
+
     @Override
     public Object cloneData(final Object data) {
         if (data != null) {
@@ -68,7 +94,7 @@ public abstract class AbstractBaseEvaluator implements Evaluator, Serializable {
                 return cloneUnknownDataType(data);
             }
         }
-        return data;
+        return null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java b/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
index d72ec77..eae5822 100644
--- a/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
+++ b/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
@@ -124,12 +124,8 @@ public abstract class AbstractStateMachine {
         log = LogFactory.getLog(this.getClass());
         try {
             stateMachine = SCXMLReader.read(scxmlDocument);
-        } catch (IOException ioe) {
+        } catch (IOException | XMLStreamException | ModelException ioe) {
             logError(ioe);
-        } catch (XMLStreamException xse) {
-            logError(xse);
-        } catch (ModelException me) {
-            logError(me);
         }
         initialize(stateMachine, rootCtx, evaluator);
     }
@@ -246,21 +242,10 @@ public abstract class AbstractStateMachine {
         try {
             Method method = clas.getDeclaredMethod(methodName, SIGNATURE);
             method.invoke(this, PARAMETERS);
-        } catch (SecurityException se) {
+        } catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException |
+                InvocationTargetException se) {
             logError(se);
             return false;
-        } catch (NoSuchMethodException nsme) {
-            logError(nsme);
-            return false;
-        } catch (IllegalArgumentException iae) {
-            logError(iae);
-            return false;
-        } catch (IllegalAccessException iae) {
-            logError(iae);
-            return false;
-        } catch (InvocationTargetException ite) {
-            logError(ite);
-            return false;
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/LogUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/LogUtils.java b/src/main/java/org/apache/commons/scxml2/env/LogUtils.java
index bf27a43..0faf929 100644
--- a/src/main/java/org/apache/commons/scxml2/env/LogUtils.java
+++ b/src/main/java/org/apache/commons/scxml2/env/LogUtils.java
@@ -36,13 +36,11 @@ public final class LogUtils {
      */
     public static String transToString(final TransitionTarget from,
             final TransitionTarget to, final Transition transition, String event) {
-        StringBuffer buf = new StringBuffer("(");
-        buf.append("event = ").append(event);
-        buf.append(", cond = ").append(transition.getCond());
-        buf.append(", from = ").append(getTTPath(from));
-        buf.append(", to = ").append(getTTPath(to));
-        buf.append(')');
-        return buf.toString();
+        return "(" + "event = " + event +
+                ", cond = " + transition.getCond() +
+                ", from = " + getTTPath(from) +
+                ", to = " + getTTPath(to) +
+                ')';
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java b/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java
index 50b650a..7d155d1 100644
--- a/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java
+++ b/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java
@@ -34,10 +34,9 @@ public class SimpleContext implements Context, Serializable {
     /** Serial version UID. */
     private static final long serialVersionUID = 1L;
     /** Implementation independent log category. */
-    private static final Log DEFAULT_LOG = LogFactory.getLog(Context.class);
-    private Log log = DEFAULT_LOG;
+    private static final Log log = LogFactory.getLog(Context.class);
     /** The parent Context to this Context. */
-    private Context parent;
+    private final Context parent;
     /** The Map of variables and their values in this Context. */
     private Map<String, Object> vars;
 
@@ -71,7 +70,7 @@ public class SimpleContext implements Context, Serializable {
         this.systemContext = parent instanceof SCXMLSystemContext ?
                 (SCXMLSystemContext) parent : parent != null ? parent.getSystemContext() : null;
         if (initialVars == null) {
-            setVars(new HashMap<String, Object>());
+            setVars(new HashMap<>());
         } else {
             setVars(this.vars = initialVars);
         }
@@ -199,15 +198,6 @@ public class SimpleContext implements Context, Serializable {
     }
 
     /**
-     * Set the log used by this <code>Context</code> instance.
-     *
-     * @param log The new log.
-     */
-    protected void setLog(final Log log) {
-        this.log = log;
-    }
-
-    /**
      * Get the log used by this <code>Context</code> instance.
      *
      * @return Log The log being used.
@@ -215,6 +205,5 @@ public class SimpleContext implements Context, Serializable {
     protected Log getLog() {
         return log;
     }
-
 }
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java b/src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java
index 60ae51f..eec3f17 100644
--- a/src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java
+++ b/src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java
@@ -58,17 +58,17 @@ public class SimpleDispatcher implements EventDispatcher, Serializable {
         /**
          * The ID of the &lt;send&gt; element.
          */
-        private String id;
+        private final String id;
 
         /**
          * The event
          */
-        private TriggerEvent event;
+        private final TriggerEvent event;
 
         /**
          * The target io processor
          */
-        private SCXMLIOProcessor target;
+        private final SCXMLIOProcessor target;
 
         /**
          * Constructor for events with payload.
@@ -99,13 +99,13 @@ public class SimpleDispatcher implements EventDispatcher, Serializable {
     }
 
     /** Implementation independent log category. */
-     private Log log = LogFactory.getLog(EventDispatcher.class);
+     private static final Log log = LogFactory.getLog(EventDispatcher.class);
 
     /**
      * The <code>Map</code> of active <code>Timer</code>s, keyed by
      * &lt;send&gt; element <code>id</code>s.
      */
-    private Map<String, Timer> timers = Collections.synchronizedMap(new HashMap<String, Timer>());
+    private final Map<String, Timer> timers = Collections.synchronizedMap(new HashMap<String, Timer>());
 
     /**
      * Get the log instance.
@@ -117,15 +117,6 @@ public class SimpleDispatcher implements EventDispatcher, Serializable {
     }
 
     /**
-     * Sets the log instance
-     *
-     * @param log the new log instance
-     */
-    protected void setLog(Log log) {
-        this.log = log;
-    }
-
-    /**
      * Get the current timers.
      *
      * @return The currently scheduled timers
@@ -167,16 +158,16 @@ public class SimpleDispatcher implements EventDispatcher, Serializable {
     public void send(final Map<String, SCXMLIOProcessor> ioProcessors, final String id, final String target,
             final String type, final String event, final Object data, final Object hints, final long delay) {
         if (log.isInfoEnabled()) {
-            StringBuilder buf = new StringBuilder();
-            buf.append("send ( id: ").append(id);
-            buf.append(", target: ").append(target);
-            buf.append(", type: ").append(type);
-            buf.append(", event: ").append(event);
-            buf.append(", data: ").append(String.valueOf(data));
-            buf.append(", hints: ").append(String.valueOf(hints));
-            buf.append(", delay: ").append(delay);
-            buf.append(')');
-            log.info(buf.toString());
+            final String buf =
+                    "send ( id: " + id +
+                    ", target: " + target +
+                    ", type: " + type +
+                    ", event: " + event +
+                    ", data: " + String.valueOf(data) +
+                    ", hints: " + String.valueOf(hints) +
+                    ", delay: " + delay +
+                    ')';
+            log.info(buf);
         }
 
         // We only handle the "scxml" type (which is the default too) and optionally the #_internal target

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/SimpleErrorHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/SimpleErrorHandler.java b/src/main/java/org/apache/commons/scxml2/env/SimpleErrorHandler.java
index 59fa254..90ff955 100644
--- a/src/main/java/org/apache/commons/scxml2/env/SimpleErrorHandler.java
+++ b/src/main/java/org/apache/commons/scxml2/env/SimpleErrorHandler.java
@@ -37,7 +37,7 @@ public class SimpleErrorHandler implements ErrorHandler, Serializable {
     private static final String MSG_POSTFIX = " Correct the SCXML document.";
 
     /** Log. */
-    private Log log = LogFactory.getLog(getClass());
+    private static final Log log = LogFactory.getLog(SimpleErrorHandler.class);
 
     /**
      * Constructor.

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java b/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java
index aa39d47..f51a279 100644
--- a/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java
+++ b/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java
@@ -40,7 +40,7 @@ public class SimpleErrorReporter implements ErrorReporter, Serializable {
     /** Serial version UID. */
     private static final long serialVersionUID = 1L;
     /** Log. */
-    private Log log = LogFactory.getLog(getClass());
+    private static final Log log = LogFactory.getLog(SimpleErrorReporter.class);
 
     /**
      * Constructor.
@@ -68,11 +68,11 @@ public class SimpleErrorReporter implements ErrorReporter, Serializable {
             } else if (errCtx instanceof State) {
                 //determineInitialStates
                 //determineTargetStates
-                msg.append("State " + LogUtils.getTTPath((State) errCtx));
+                msg.append("State ").append(LogUtils.getTTPath((State) errCtx));
             }
         } else if (errCode == ErrorConstants.UNKNOWN_ACTION) {
             //executeActionList
-            msg.append("Action: " + errCtx.getClass().getName());
+            msg.append("Action: ").append(errCtx.getClass().getName());
         } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) {
             //isLegalConfig
             if (errCtx instanceof Map.Entry) { //unchecked cast below
@@ -80,7 +80,7 @@ public class SimpleErrorReporter implements ErrorReporter, Serializable {
                     (Map.Entry<EnterableState, Set<EnterableState>>) errCtx;
                 EnterableState es = badConfigMap.getKey();
                 Set<EnterableState> vals = badConfigMap.getValue();
-                msg.append(LogUtils.getTTPath(es) + " : [");
+                msg.append(LogUtils.getTTPath(es)).append(" : [");
                 for (Iterator<EnterableState> i = vals.iterator(); i.hasNext();) {
                     EnterableState ex = i.next();
                     msg.append(LogUtils.getTTPath(ex));
@@ -104,11 +104,11 @@ public class SimpleErrorReporter implements ErrorReporter, Serializable {
         } else if (errCode == ErrorConstants.EXPRESSION_ERROR) {
             if (errCtx instanceof Executable) {
                 TransitionTarget parent = ((Executable) errCtx).getParent();
-                msg.append("Expression error inside " + LogUtils.getTTPath(parent));
+                msg.append("Expression error inside ").append(LogUtils.getTTPath(parent));
             }
             else if (errCtx instanceof Data) {
                 // Data expression error
-                msg.append("Expression error for data element with id "+((Data)errCtx).getId());
+                msg.append("Expression error for data element with id ").append(((Data) errCtx).getId());
             }
             else if (errCtx instanceof SCXML) {
                 // Global Script

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java b/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java
index 451bfab..4ad7730 100644
--- a/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java
+++ b/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java
@@ -34,7 +34,7 @@ public class SimpleSCXMLListener implements SCXMLListener, Serializable {
     /** Serial version UID. */
     private static final long serialVersionUID = 1L;
     /** Log. */
-    private Log log = LogFactory.getLog(getClass());
+    private static final Log log = LogFactory.getLog(SimpleSCXMLListener.class);
 
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/SimpleXMLReporter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/SimpleXMLReporter.java b/src/main/java/org/apache/commons/scxml2/env/SimpleXMLReporter.java
index e12ad02..e293c00 100644
--- a/src/main/java/org/apache/commons/scxml2/env/SimpleXMLReporter.java
+++ b/src/main/java/org/apache/commons/scxml2/env/SimpleXMLReporter.java
@@ -37,7 +37,7 @@ public class SimpleXMLReporter implements XMLReporter, Serializable {
     private static final long serialVersionUID = 1L;
 
     /** Log. */
-    private Log log = LogFactory.getLog(getClass());
+    private static final Log log = LogFactory.getLog(SimpleXMLReporter.class);
 
     /**
      * Constructor.

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/Tracer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/Tracer.java b/src/main/java/org/apache/commons/scxml2/env/Tracer.java
index 631550b..d8955f1 100644
--- a/src/main/java/org/apache/commons/scxml2/env/Tracer.java
+++ b/src/main/java/org/apache/commons/scxml2/env/Tracer.java
@@ -41,13 +41,13 @@ public class Tracer implements ErrorHandler, ErrorReporter,
     /** Serial version UID. */
     private static final long serialVersionUID = 1L;
     /** ErrorHandler delegate. */
-    private ErrorHandler errHandler;
+    private final ErrorHandler errHandler;
     /** ErrorReporter delegate. */
-    private ErrorReporter errReporter;
+    private final ErrorReporter errReporter;
     /** SCXMLListener delegate. */
-    private SCXMLListener scxmlListener;
+    private final SCXMLListener scxmlListener;
     /** XMLReporter delegate. */
-    private XMLReporter xmlReporter;
+    private final XMLReporter xmlReporter;
 
     /**
      * Constructor.

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/URLResolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/URLResolver.java b/src/main/java/org/apache/commons/scxml2/env/URLResolver.java
index ba7dc47..6e2447b 100644
--- a/src/main/java/org/apache/commons/scxml2/env/URLResolver.java
+++ b/src/main/java/org/apache/commons/scxml2/env/URLResolver.java
@@ -35,7 +35,7 @@ public class URLResolver implements PathResolver, Serializable {
     private static final long serialVersionUID = 1L;
 
     /** Implementation independent log category. */
-    private Log log = LogFactory.getLog(PathResolver.class);
+    private static final Log log = LogFactory.getLog(PathResolver.class);
 
     /** The base URL to resolve against. */
     private URL baseURL = null;

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyContextBinding.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyContextBinding.java b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyContextBinding.java
index d3ea5db..e1bf007 100644
--- a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyContextBinding.java
+++ b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyContextBinding.java
@@ -68,7 +68,7 @@ public class GroovyContextBinding extends Binding implements Serializable {
 
     @Override
     public Map<String, Object> getVariables() {
-        return new LinkedHashMap<String, Object>(context.getVars());
+        return new LinkedHashMap<>(context.getVars());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
index 111ce0c..e26aaaf 100644
--- a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
@@ -21,7 +21,6 @@ import groovy.lang.Script;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -45,11 +44,6 @@ public class GroovyEvaluator extends AbstractBaseEvaluator {
     /** Serial version UID. */
     private static final long serialVersionUID = 1L;
 
-    /**
-     * Unique context variable name used for temporary reference to assign data (thus must be a valid variable name)
-     */
-    private static final String ASSIGN_VARIABLE_NAME = "a"+UUID.randomUUID().toString().replace('-','x');
-
     public static final String SUPPORTED_DATA_MODEL = "groovy";
 
     public static class GroovyEvaluatorProvider implements EvaluatorProvider {
@@ -241,25 +235,6 @@ public class GroovyEvaluator extends AbstractBaseEvaluator {
     }
 
     /**
-     * @see Evaluator#evalAssign(Context, String, Object)
-     */
-    public void evalAssign(final Context ctx, final String location, final Object data) throws SCXMLExpressionException {
-        final StringBuilder sb = new StringBuilder(location).append("=").append(ASSIGN_VARIABLE_NAME);
-        try {
-            ctx.getVars().put(ASSIGN_VARIABLE_NAME, data);
-            eval(ctx, sb.toString());
-        } catch (SCXMLExpressionException e) {
-            if (e.getCause() != null && e.getCause() != null && e.getCause().getMessage() != null) {
-                throw new SCXMLExpressionException("Error evaluating assign to location=\"" + location + "\": " + e.getCause().getMessage());
-            }
-            throw e;
-        }
-        finally {
-            ctx.getVars().remove(ASSIGN_VARIABLE_NAME);
-        }
-    }
-
-    /**
      * @see Evaluator#evalScript(Context, String)
      */
     @Override

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyExtendableScriptCache.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyExtendableScriptCache.java b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyExtendableScriptCache.java
index e9424e0..2c8764d 100644
--- a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyExtendableScriptCache.java
+++ b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyExtendableScriptCache.java
@@ -96,18 +96,12 @@ public class GroovyExtendableScriptCache implements Serializable {
     public static final String DEFAULT_SCRIPT_CODE_BASE = "/groovy/scxml/script";
 
     /** Default factory for the Groovy parent ClassLoader, returning this class its ClassLoader */
-    public static final ParentClassLoaderFactory DEFAULT_PARENT_CLASS_LOADER_FACTORY = new ParentClassLoaderFactory() {
-        public ClassLoader getClassLoader() {
-            return GroovyExtendableScriptCache.class.getClassLoader();
-        }
-    };
+    public static final ParentClassLoaderFactory DEFAULT_PARENT_CLASS_LOADER_FACTORY =
+            (ParentClassLoaderFactory) GroovyExtendableScriptCache.class::getClassLoader;
 
     /** Default factory for the Groovy CompilerConfiguration, returning a new and unmodified CompilerConfiguration instance */
-    public static final CompilerConfigurationFactory DEFAULT_COMPILER_CONFIGURATION_FACTORY = new CompilerConfigurationFactory() {
-        public CompilerConfiguration getCompilerConfiguration() {
-            return new CompilerConfiguration();
-        }
-    };
+    public static final CompilerConfigurationFactory DEFAULT_COMPILER_CONFIGURATION_FACTORY =
+            (CompilerConfigurationFactory) CompilerConfiguration::new;
 
     protected static class ScriptCacheElement implements Serializable {
         private static final long serialVersionUID = 1L;
@@ -170,7 +164,7 @@ public class GroovyExtendableScriptCache implements Serializable {
         }
     }
 
-    private final LinkedHashMap<ScriptCacheElement, ScriptCacheElement> scriptCache = new LinkedHashMap<ScriptCacheElement, ScriptCacheElement>();
+    private final LinkedHashMap<ScriptCacheElement, ScriptCacheElement> scriptCache = new LinkedHashMap<>();
 
     private String scriptCodeBase = DEFAULT_SCRIPT_CODE_BASE;
     private String scriptBaseClass;
@@ -239,11 +233,8 @@ public class GroovyExtendableScriptCache implements Serializable {
                 compilerConfiguration.setScriptBaseClass(getScriptBaseClass());
             }
 
-            groovyClassLoader = AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
-                public GroovyClassLoader run() {
-                    return new GroovyClassLoader(getParentClassLoaderFactory().getClassLoader(), compilerConfiguration);
-                }
-            });
+            groovyClassLoader = AccessController.doPrivileged((PrivilegedAction<GroovyClassLoader>)
+                    () -> new GroovyClassLoader(getParentClassLoaderFactory().getClassLoader(), compilerConfiguration));
             if (!scriptCache.isEmpty()) {
                 // de-serialized: need to re-generate all previously compiled scripts (this can cause a hick-up...):
                 for (ScriptCacheElement element : scriptCache.keySet()) {
@@ -257,11 +248,8 @@ public class GroovyExtendableScriptCache implements Serializable {
     protected Class<Script> compileScript(final String scriptBaseClass, String scriptSource, final String scriptName) {
         final String script = preProcessScript(scriptSource);
 
-        GroovyCodeSource codeSource = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
-            public GroovyCodeSource run() {
-                return new GroovyCodeSource(script, scriptName, getScriptCodeBase());
-            }
-        });
+        GroovyCodeSource codeSource = AccessController.doPrivileged((PrivilegedAction<GroovyCodeSource>)
+                () -> new GroovyCodeSource(script, scriptName, getScriptCodeBase()));
 
         String currentScriptBaseClass = compilerConfiguration.getScriptBaseClass();
         try {

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java
index 5980211..cdd1dcb 100644
--- a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java
+++ b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java
@@ -32,8 +32,7 @@ import org.apache.commons.scxml2.Builtin;
  */
 public abstract class GroovySCXMLScript extends Script {
 
-    GroovyContext context;
-    GroovyContextBinding binding;
+    private GroovyContext context;
 
     protected GroovySCXMLScript() {
         super(null);
@@ -42,8 +41,7 @@ public abstract class GroovySCXMLScript extends Script {
     @Override
     public void setBinding(final Binding binding) {
         super.setBinding(binding);
-        this.binding = (GroovyContextBinding)binding;
-        this.context = this.binding.getContext();
+        this.context = ((GroovyContextBinding) binding).getContext();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/javascript/JSBindings.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/javascript/JSBindings.java b/src/main/java/org/apache/commons/scxml2/env/javascript/JSBindings.java
index dc9ab7c..0132142 100644
--- a/src/main/java/org/apache/commons/scxml2/env/javascript/JSBindings.java
+++ b/src/main/java/org/apache/commons/scxml2/env/javascript/JSBindings.java
@@ -147,8 +147,8 @@ public class JSBindings implements Bindings {
      * @param toMerge the map of variables to merge
      */
     @Override
-    public void putAll(Map<? extends String, ? extends Object> toMerge) {
-        for (Map.Entry<? extends String, ? extends Object> entry : toMerge.entrySet()) {
+    public void putAll(Map<? extends String, ?> toMerge) {
+        for (Map.Entry<? extends String, ?> entry : toMerge.entrySet()) {
             put(entry.getKey(), entry.getValue());
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
index 91ec4a8..1ec2d58 100644
--- a/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
@@ -19,7 +19,6 @@ package org.apache.commons.scxml2.env.javascript;
 
 import java.io.IOException;
 import java.util.List;
-import java.util.UUID;
 
 import javax.script.Bindings;
 import javax.script.ScriptContext;
@@ -55,11 +54,6 @@ import org.apache.commons.scxml2.model.SCXML;
  */
 public class JSEvaluator extends AbstractBaseEvaluator {
 
-    /**
-     * Unique context variable name used for temporary reference to assign data (thus must be a valid variable name)
-     */
-    private static final String ASSIGN_VARIABLE_NAME = "a"+UUID.randomUUID().toString().replace('-','x');
-
     public static final String SUPPORTED_DATA_MODEL = Evaluator.ECMASCRIPT_DATA_MODEL;
 
     public static class JSEvaluatorProvider implements EvaluatorProvider {
@@ -265,24 +259,6 @@ public class JSEvaluator extends AbstractBaseEvaluator {
     }
 
     /**
-     * @see Evaluator#evalAssign(Context, String, Object)
-     */
-    public void evalAssign(final Context ctx, final String location, final Object data) throws SCXMLExpressionException {
-        StringBuilder sb = new StringBuilder(location).append("=").append(ASSIGN_VARIABLE_NAME);
-        try {
-            ctx.getVars().put(ASSIGN_VARIABLE_NAME, data);
-            eval(ctx, sb.toString());
-        } catch (SCXMLExpressionException e) {
-            if (e.getCause() != null && e.getCause() != null && e.getCause().getMessage() != null) {
-                throw new SCXMLExpressionException("Error evaluating assign to location=\"" + location + "\": " + e.getCause().getMessage());
-            }
-            throw e;
-        } finally {
-            ctx.getVars().remove(ASSIGN_VARIABLE_NAME);
-        }
-    }
-
-    /**
      * Executes the Javascript script using the <code>eval()</code> method
      *
      * @param ctx    SCXML context.

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/javascript/init_global.js
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/javascript/init_global.js b/src/main/java/org/apache/commons/scxml2/env/javascript/init_global.js
index fccb6cb..cbaa1f0 100644
--- a/src/main/java/org/apache/commons/scxml2/env/javascript/init_global.js
+++ b/src/main/java/org/apache/commons/scxml2/env/javascript/init_global.js
@@ -105,7 +105,7 @@ Object.defineProperties(this, {
         },
         writable : false,
         configurable : false,
-        enumeratable : false,
+        enumeratable : false
     },
     "_event":
     {

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
index 5ff6440..ea7f5a8 100644
--- a/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
@@ -18,7 +18,6 @@ package org.apache.commons.scxml2.env.jexl;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.UUID;
 
 import org.apache.commons.jexl3.JexlBuilder;
 import org.apache.commons.jexl3.JexlExpression;
@@ -45,11 +44,6 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
     /** Serial version UID. */
     private static final long serialVersionUID = 1L;
 
-    /**
-     * Unique context variable name used for temporary reference to assign data (thus must be a valid variable name)
-     */
-    private static final String ASSIGN_VARIABLE_NAME = "a"+UUID.randomUUID().toString().replace('-','x');
-
     public static final String SUPPORTED_DATA_MODEL = "jexl";
 
     public static class JexlEvaluatorProvider implements EvaluatorProvider {
@@ -90,7 +84,7 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
     private transient volatile JexlEngine jexlEngine;
 
     /** The current JexlEngine silent mode, stored locally to be reapplied after deserialization of the engine */
-    private boolean jexlEngineSilent;
+    private final boolean jexlEngineSilent;
     /** The current JexlEngine strict mode, stored locally to be reapplied after deserialization of the engine */
     private boolean jexlEngineStrict;
 
@@ -100,7 +94,6 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
     }
 
     public JexlEvaluator(final boolean strict) {
-        super();
         jexlEngineStrict = strict;
         // create the internal JexlEngine initially
         jexlEngine = getJexlEngine();
@@ -181,25 +174,6 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
     }
 
     /**
-     * @see Evaluator#evalAssign(Context, String, Object)
-     */
-    public void evalAssign(final Context ctx, final String location, final Object data) throws SCXMLExpressionException {
-        StringBuilder sb = new StringBuilder(location).append("=").append(ASSIGN_VARIABLE_NAME);
-        try {
-            ctx.getVars().put(ASSIGN_VARIABLE_NAME, data);
-            eval(ctx, sb.toString());
-        } catch (SCXMLExpressionException e) {
-            if (e.getCause() != null && e.getCause() != null && e.getCause().getMessage() != null) {
-                throw new SCXMLExpressionException("Error evaluating assign to location=\"" + location + "\": " + e.getCause().getMessage());
-            }
-            throw e;
-        }
-        finally {
-            ctx.getVars().remove(ASSIGN_VARIABLE_NAME);
-        }
-    }
-
-    /**
      * @see Evaluator#evalScript(Context, String)
      */
     public Object evalScript(final Context ctx, final String script)

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/invoke/InvokerException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/invoke/InvokerException.java b/src/main/java/org/apache/commons/scxml2/invoke/InvokerException.java
index bb25161..937e67f 100644
--- a/src/main/java/org/apache/commons/scxml2/invoke/InvokerException.java
+++ b/src/main/java/org/apache/commons/scxml2/invoke/InvokerException.java
@@ -29,13 +29,6 @@ public class InvokerException extends Exception {
     private static final long serialVersionUID = 1L;
 
     /**
-     * @see java.lang.Exception#Exception()
-     */
-    public InvokerException() {
-        super();
-    }
-
-    /**
      * @see java.lang.Exception#Exception(java.lang.String)
      * @param message The error message
      */

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java b/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
index 9277e0a..5cdcb63 100644
--- a/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
+++ b/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
@@ -94,12 +94,8 @@ public class SimpleSCXMLInvoker implements Invoker, Serializable {
         SCXML scxml;
         try {
             scxml = SCXMLReader.read(new URL(url));
-        } catch (ModelException me) {
+        } catch (ModelException | IOException | XMLStreamException me) {
             throw new InvokerException(me.getMessage(), me.getCause());
-        } catch (IOException ioe) {
-            throw new InvokerException(ioe.getMessage(), ioe.getCause());
-        } catch (XMLStreamException xse) {
-            throw new InvokerException(xse.getMessage(), xse.getCause());
         }
         execute(scxml, params);
     }
@@ -113,12 +109,8 @@ public class SimpleSCXMLInvoker implements Invoker, Serializable {
         SCXML scxml;
         try {
             scxml = SCXMLReader.read(new StringReader(content));
-        } catch (ModelException me) {
+        } catch (ModelException | IOException | XMLStreamException me) {
             throw new InvokerException(me.getMessage(), me.getCause());
-        } catch (IOException ioe) {
-            throw new InvokerException(ioe.getMessage(), ioe.getCause());
-        } catch (XMLStreamException xse) {
-            throw new InvokerException(xse.getMessage(), xse.getCause());
         }
         execute(scxml, params);
     }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/io/ContentParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/io/ContentParser.java b/src/main/java/org/apache/commons/scxml2/io/ContentParser.java
index a4b07ad..800d082 100644
--- a/src/main/java/org/apache/commons/scxml2/io/ContentParser.java
+++ b/src/main/java/org/apache/commons/scxml2/io/ContentParser.java
@@ -53,7 +53,7 @@ public class ContentParser {
     /**
      * Jackson JSON ObjectMapper
      */
-    private ObjectMapper jsonObjectMapper;
+    private final ObjectMapper jsonObjectMapper;
 
     /**
      * Default constructor initializing a Jackson ObjectMapper allowing embedded comments, including YAML style
@@ -183,12 +183,10 @@ public class ContentParser {
      * @throws IOException
      */
     public Node parseXml(final String xmlString) throws IOException {
-        Document doc = null;
+        Document doc;
         try {
             doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlString);
-        } catch (SAXException e) {
-            throw new IOException(e);
-        } catch (ParserConfigurationException e) {
+        } catch (SAXException | ParserConfigurationException e) {
             throw new IOException(e);
         }
         return doc != null ? doc.getDocumentElement() : null;

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java b/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java
index 770cdaf..fc9a451 100644
--- a/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java
+++ b/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java
@@ -158,13 +158,7 @@ final class ModelUpdater {
 
         scxml.setInitialTransition(initialTransition);
         Map<String, TransitionTarget> targets = scxml.getTargets();
-        for (EnterableState es : scxml.getChildren()) {
-            if (es instanceof State) {
-                updateState((State) es, targets);
-            } else if (es instanceof Parallel) {
-                updateParallel((Parallel) es, targets);
-            }
-        }
+        updateEnterableStates(scxml.getChildren(), targets);
 
         scxml.getInitialTransition().setObservableId(1);
         initObservables(scxml.getChildren(), 2);
@@ -281,13 +275,7 @@ final class ModelUpdater {
             }
         }
 
-        for (EnterableState es : children) {
-            if (es instanceof State) {
-                updateState((State) es, targets);
-            } else if (es instanceof Parallel) {
-                updateParallel((Parallel) es, targets);
-            }
-        }
+        updateEnterableStates(children, targets);
     }
 
     /**
@@ -299,13 +287,7 @@ final class ModelUpdater {
      */
     private static void updateParallel(final Parallel parallel, final Map<String, TransitionTarget> targets)
             throws ModelException {
-        for (EnterableState es : parallel.getChildren()) {
-            if (es instanceof State) {
-                updateState((State) es, targets);
-            } else if (es instanceof Parallel) {
-                updateParallel((Parallel) es, targets);
-            }
-        }
+        updateEnterableStates(parallel.getChildren(), targets);
         for (Transition transition : parallel.getTransitionsList()) {
             updateTransition(transition, targets);
         }
@@ -317,6 +299,25 @@ final class ModelUpdater {
     }
 
     /**
+     * Update the EnterableState objects (part of post-read processing).
+     *
+     * @param states The EnterableState objects
+     * @param targets The global Map of all transition targets
+     * @throws ModelException If the object model is flawed
+     */
+    private static void updateEnterableStates(final List<EnterableState> states,
+                                              final Map<String, TransitionTarget> targets)
+        throws ModelException {
+        for (EnterableState es : states) {
+            if (es instanceof State) {
+                updateState((State) es, targets);
+            } else if (es instanceof Parallel) {
+                updateParallel((Parallel) es, targets);
+            }
+        }
+    }
+
+    /**
      * Update this History object (part of post-read processing).
      *
      * @param history The History object

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java b/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
index 4b3c8dd..8402725 100644
--- a/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
+++ b/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
@@ -855,13 +855,12 @@ public final class SCXMLReader {
      * @param configuration The {@link Configuration} to use while parsing.
      * @param parent The parent {@link State} for this final (null for top level state).
      *
-     * @throws IOException An IO error during parsing.
      * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
      * @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
      *                        errors in the SCXML document that may not be identified by the schema).
      */
     private static void readDoneData(final XMLStreamReader reader, final Configuration configuration, final Final parent)
-            throws XMLStreamException, ModelException, IOException {
+            throws XMLStreamException, ModelException {
 
         DoneData doneData = new DoneData();
         parent.setDoneData(doneData);
@@ -911,14 +910,11 @@ public final class SCXMLReader {
      * @param src The "src" attribute value.
      * @param ts The parent {@link TransitionalState} that specifies this "src" attribute.
      *
-     * @throws IOException An IO error during parsing.
-     * @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
-     *                        errors in the SCXML document that may not be identified by the schema).
      * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
      */
     private static void readTransitionalStateSrc(final Configuration configuration, final String src,
                                                  final TransitionalState ts)
-            throws IOException, ModelException, XMLStreamException {
+            throws ModelException {
 
         // Check for URI fragment
         String[] fragments = src.split("#", 2);
@@ -1546,7 +1542,7 @@ public final class SCXMLReader {
             throws XMLStreamException, ModelException {
 
         if (executable instanceof Finalize) {
-            // http://www.w3.org/TR/2013/WD-scxml-20130801/#finalize
+            // https://www.w3.org/TR/2015/REC-scxml-20150901/#finalize
             // [...] the executable content inside <finalize> MUST NOT raise events or invoke external actions.
             // In particular, the <send> and <raise> elements MUST NOT occur.
             reportIgnoredElement(reader, configuration, SCXMLConstants.ELEM_FINALIZE, SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_RAISE);
@@ -1751,7 +1747,7 @@ public final class SCXMLReader {
             throws XMLStreamException, ModelException {
 
         if (executable instanceof Finalize) {
-            // http://www.w3.org/TR/2013/WD-scxml-20130801/#finalize
+            // https://www.w3.org/TR/2015/REC-scxml-20150901/#finalize
             // [...] the executable content inside <finalize> MUST NOT raise events or invoke external actions.
             // In particular, the <send> and <raise> elements MUST NOT occur.
             reportIgnoredElement(reader, configuration, SCXMLConstants.ELEM_FINALIZE, SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_SEND);
@@ -1913,8 +1909,8 @@ public final class SCXMLReader {
 
     /**
      * Read the contents of the initial &lt;script&gt; element.
-     * @see <a href="http://www.w3.org/TR/2013/WD-scxml-20130801/#scxml">
-     *     http://www.w3.org/TR/2013/WD-scxml-20130801/#scxml<a> section 3.2.2
+     * @see <a href="https://www.w3.org/TR/2015/REC-scxml-20150901/#scxml">
+     *     https://www.w3.org/TR/2015/REC-scxml-20150901/#scxml<a> section 3.2.2
      *
      * @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
      * @param configuration The {@link Configuration} to use while parsing.
@@ -2016,10 +2012,12 @@ public final class SCXMLReader {
             actionWrapper.getNamespaces().putAll(namespaces);
         }
 
+        Map<String, String> attributes = new HashMap<>();
         for (int i = 0; i < reader.getAttributeCount(); i++) {
             String name = reader.getAttributeLocalName(i);
             String qname = createQualifiedName(reader.getAttributePrefix(i), name);
             String value = reader.getAttributeValue(i);
+            attributes.put(qname, value);
             String setter = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
             Method method;
             try {
@@ -2036,6 +2034,9 @@ public final class SCXMLReader {
                         + className, iae);
             }
         }
+        if (!attributes.isEmpty()) {
+            actionWrapper.setAttributes(attributes);
+        }
 
         // Add any body content if necessary
         if (action instanceof ParsedValueContainer) {
@@ -2721,7 +2722,7 @@ public final class SCXMLReader {
          */
         boolean strict;
 
-        ContentParser contentParser;
+        final ContentParser contentParser;
 
         /*
          * Public constructors
@@ -2881,7 +2882,7 @@ public final class SCXMLReader {
             this.factoryId = factoryId;
             this.factoryClassLoader = factoryClassLoader;
             this.allocator = allocator;
-            this.properties = (properties == null ? new HashMap<String, Object>() : properties);
+            this.properties = (properties == null ? new HashMap<>() : properties);
             this.resolver = resolver;
             this.reporter = reporter;
             this.encoding = encoding;
@@ -2889,7 +2890,7 @@ public final class SCXMLReader {
             this.validate = validate;
             this.pathResolver = pathResolver;
             this.parent = parent;
-            this.customActions = (customActions == null ? new ArrayList<CustomAction>() : customActions);
+            this.customActions = (customActions == null ? new ArrayList<>() : customActions);
             this.customActionClassLoader = customActionClassLoader;
             this.useContextClassLoaderForCustomActions = useContextClassLoaderForCustomActions;
             this.silent = silent;

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java b/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java
index d3f7b33..940bf4e 100644
--- a/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java
+++ b/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java
@@ -55,7 +55,6 @@ import org.apache.commons.scxml2.model.ElseIf;
 import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.JsonValue;
 import org.apache.commons.scxml2.model.NodeListValue;
-import org.apache.commons.scxml2.model.NodeTextValue;
 import org.apache.commons.scxml2.model.NodeValue;
 import org.apache.commons.scxml2.model.ParsedValue;
 import org.apache.commons.scxml2.model.Raise;
@@ -456,15 +455,7 @@ public class SCXMLWriter {
 
         // Children
         writeDatamodel(writer, scxml.getDatamodel());
-        for (EnterableState es : scxml.getChildren()) {
-            if (es instanceof Final) {
-                writeFinal(writer, (Final) es);
-            } else if (es instanceof State) {
-                writeState(writer, (State) es);
-            } else if (es instanceof Parallel) {
-                writeParallel(writer, (Parallel) es);
-            }
-        }
+        writeEnterableStates(writer, scxml.getChildren());
 
         // End
         writer.writeEndElement();
@@ -539,15 +530,7 @@ public class SCXMLWriter {
             writeInvoke(writer, inv);
         }
 
-        for (EnterableState es : state.getChildren()) {
-            if (es instanceof Final) {
-                writeFinal(writer, (Final) es);
-            } else if (es instanceof State) {
-                writeState(writer, (State) es);
-            } else if (es instanceof Parallel) {
-                writeParallel(writer, (Parallel) es);
-            }
-        }
+        writeEnterableStates(writer, state.getChildren());
 
         for (OnExit onexit : state.getOnExits()) {
             writeOnExit(writer, onexit);
@@ -583,15 +566,7 @@ public class SCXMLWriter {
             writeInvoke(writer, inv);
         }
 
-        for (EnterableState es : parallel.getChildren()) {
-            if (es instanceof Final) {
-                writeFinal(writer, (Final) es);
-            } else if (es instanceof State) {
-                writeState(writer, (State) es);
-            } else if (es instanceof Parallel) {
-                writeParallel(writer, (Parallel) es);
-            }
-        }
+        writeEnterableStates(writer, parallel.getChildren());
 
         for (OnExit onexit : parallel.getOnExits()) {
             writeOnExit(writer, onexit);
@@ -620,13 +595,7 @@ public class SCXMLWriter {
         }
         if (end.getDoneData() != null) {
             writer.writeStartElement(SCXMLConstants.ELEM_DONEDATA);
-            for (Param p : end.getDoneData().getParams()) {
-                writer.writeStartElement(SCXMLConstants.ELEM_PARAM);
-                writeAV(writer, SCXMLConstants.ATTR_NAME, p.getName());
-                writeAV(writer, SCXMLConstants.ATTR_LOCATION, p.getLocation());
-                writeAV(writer, SCXMLConstants.ATTR_EXPR, escapeXML(p.getExpr()));
-                writer.writeEndElement();
-            }
+            writeParams(writer, end.getDoneData().getParams());
             writeContent(writer, end.getDoneData().getContent());
             writer.writeEndElement();
         }
@@ -634,6 +603,27 @@ public class SCXMLWriter {
     }
 
     /**
+     * Write out the {@link EnterableState} objects into its serialization.
+     *
+     * @param writer The {@link XMLStreamWriter} in use for the serialization.
+     * @param states The {@link EnterableState}s to serialize.
+     *
+     * @throws XMLStreamException An exception processing the underlying {@link XMLStreamWriter}.
+     */
+    private static void writeEnterableStates(final XMLStreamWriter writer, final List<EnterableState> states)
+            throws XMLStreamException {
+        for (EnterableState es : states) {
+            if (es instanceof Final) {
+                writeFinal(writer, (Final) es);
+            } else if (es instanceof State) {
+                writeState(writer, (State) es);
+            } else if (es instanceof Parallel) {
+                writeParallel(writer, (Parallel) es);
+            }
+        }
+    }
+
+    /**
      * Write out this {@link Initial} object into its serialization as the corresponding &lt;initial&gt; element.
      *
      * @param writer The {@link XMLStreamWriter} in use for the serialization.
@@ -765,13 +755,7 @@ public class SCXMLWriter {
         writeAV(writer, SCXMLConstants.ATTR_AUTOFORWARD, invoke.getAutoForward());
         writeAV(writer, SCXMLConstants.ATTR_NAMELIST, invoke.getNamelist());
 
-        for (Param p : invoke.getParams()) {
-            writer.writeStartElement(SCXMLConstants.ELEM_PARAM);
-            writeAV(writer, SCXMLConstants.ATTR_NAME, p.getName());
-            writeAV(writer, SCXMLConstants.ATTR_LOCATION, p.getLocation());
-            writeAV(writer, SCXMLConstants.ATTR_EXPR, escapeXML(p.getExpr()));
-            writer.writeEndElement();
-        }
+        writeParams(writer, invoke.getParams());
         writeFinalize(writer, invoke.getFinalize());
         writeContent(writer, invoke.getContent());
 
@@ -911,16 +895,29 @@ public class SCXMLWriter {
         writeAV(writer, SCXMLConstants.ATTR_NAMELIST, send.getNamelist());
         writeAV(writer, SCXMLConstants.ATTR_HINTS, send.getHints());
 
-        for (Param p : send.getParams()) {
+        writeParams(writer, send.getParams());
+        writeContent(writer, send.getContent());
+
+        writer.writeEndElement();
+    }
+
+    /**
+     * Write out the {@link Param} objects into its serialization.
+     *
+     * @param writer The {@link XMLStreamWriter} in use for the serialization.
+     * @param params The {@link Param}s to serialize.
+     *
+     * @throws XMLStreamException An exception processing the underlying {@link XMLStreamWriter}.
+     */
+    private static void writeParams(final XMLStreamWriter writer, final List<Param> params)
+            throws XMLStreamException {
+        for (Param p : params) {
             writer.writeStartElement(SCXMLConstants.ELEM_PARAM);
             writeAV(writer, SCXMLConstants.ATTR_NAME, p.getName());
             writeAV(writer, SCXMLConstants.ATTR_LOCATION, p.getLocation());
             writeAV(writer, SCXMLConstants.ATTR_EXPR, escapeXML(p.getExpr()));
             writer.writeEndElement();
         }
-        writeContent(writer, send.getContent());
-
-        writer.writeEndElement();
     }
 
     /**
@@ -1202,14 +1199,10 @@ public class SCXMLWriter {
             TransformerFactory tfFactory = TransformerFactory.newInstance();
             transformer = tfFactory.newTransformer();
             transformer.setOutputProperties(outputProps);
-        } catch (TransformerFactoryConfigurationError t) {
+        } catch (TransformerFactoryConfigurationError | TransformerConfigurationException t) {
             org.apache.commons.logging.Log log = LogFactory.getLog(SCXMLWriter.class);
             log.error(t.getMessage(), t);
             return null;
-        } catch (TransformerConfigurationException e) {
-            org.apache.commons.logging.Log log = LogFactory.getLog(SCXMLWriter.class);
-            log.error(e.getMessage(), e);
-            return null;
         }
         return transformer;
     }
@@ -1359,7 +1352,7 @@ public class SCXMLWriter {
 
             this.factoryId = factoryId;
             this.factoryClassLoader = factoryClassLoader;
-            this.properties = (properties == null ? new HashMap<String, Object>() : properties);
+            this.properties = (properties == null ? new HashMap<>() : properties);
             this.encoding = encoding;
             this.usePrettyPrint = usePrettyPrint;
             this.closeUnderlyingWhenDone = closeUnderlyingWhenDone;

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Action.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Action.java b/src/main/java/org/apache/commons/scxml2/model/Action.java
index ee2f401..ed32bde 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Action.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Action.java
@@ -17,7 +17,6 @@
 package org.apache.commons.scxml2.model;
 
 import java.io.Serializable;
-import java.util.Map;
 
 import org.apache.commons.scxml2.ActionExecutionContext;
 import org.apache.commons.scxml2.SCXMLExpressionException;
@@ -79,15 +78,7 @@ public abstract class Action implements Serializable {
             throw new ModelException("Action "
                     + this.getClass().getName() + " instance missing required parent TransitionTarget");
         }
-        TransitionTarget tt = parent.getParent();
-        if (tt instanceof EnterableState) {
-            return (EnterableState)tt;
-        } else if (tt instanceof History) {
-            return ((History)tt).getParent();
-        } else {
-            throw new ModelException("Unknown TransitionTarget subclass:"
-                    + (tt != null ? tt.getClass().getName() : "(null)"));
-        }
+        return parent.getParent();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Datamodel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Datamodel.java b/src/main/java/org/apache/commons/scxml2/model/Datamodel.java
index d3b9a53..0394e9f 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Datamodel.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Datamodel.java
@@ -36,13 +36,13 @@ public class Datamodel implements Serializable {
     * The set of &lt;data&gt; elements, parsed as Elements, that are
     * children of this &lt;datamodel&gt; element.
     */
-   private List<Data> data;
+   private final List<Data> data;
 
    /**
     * Constructor.
     */
    public Datamodel() {
-       this.data = new ArrayList<Data>();
+       this.data = new ArrayList<>();
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java b/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
index e469e91..80f0c85 100644
--- a/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
+++ b/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
@@ -29,19 +29,9 @@ import java.util.Comparator;
  */
 public interface DocumentOrder {
 
-    Comparator<DocumentOrder> documentOrderComparator = new Comparator<DocumentOrder>() {
-        @Override
-        public int compare(final DocumentOrder o1, final DocumentOrder o2) {
-            return o1.getOrder() - o2.getOrder();
-        }
-    };
+    Comparator<DocumentOrder> documentOrderComparator = Comparator.comparingInt(DocumentOrder::getOrder);
 
-    Comparator<DocumentOrder> reverseDocumentOrderComparator = new Comparator<DocumentOrder>() {
-        @Override
-        public int compare(final DocumentOrder o1, final DocumentOrder o2) {
-            return o2.getOrder() - o1.getOrder();
-        }
-    };
+    Comparator<DocumentOrder> reverseDocumentOrderComparator = (o1, o2) -> o2.getOrder() - o1.getOrder();
 
     /**
      * @return the relative document order within the SCXML document of this element

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/EnterableState.java b/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
index cba7fb6..39f5917 100644
--- a/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
+++ b/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
@@ -33,18 +33,17 @@ public abstract class EnterableState extends TransitionTarget implements Documen
      * List of optional OnEntry elements holding executable content to be run upon
      * entering this transition target.
      */
-    private List<OnEntry> onEntries;
+    private final List<OnEntry> onEntries;
 
     /**
      * List of optional OnExit elements holding executable content to be run upon
      * exiting this transition target.
      */
-    private List<OnExit> onExits;
+    private final List<OnExit> onExits;
 
     public EnterableState() {
-        super();
-        onEntries = new ArrayList<OnEntry>();
-        onExits = new ArrayList<OnExit>();
+        onEntries = new ArrayList<>();
+        onExits = new ArrayList<>();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Executable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Executable.java b/src/main/java/org/apache/commons/scxml2/model/Executable.java
index eb5eec6..a141bde 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Executable.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Executable.java
@@ -31,7 +31,7 @@ public abstract class Executable implements Serializable {
      * The set of executable elements (those that inheriting from
      * Action) that are contained in this Executable.
      */
-    private List<Action> actions;
+    private final List<Action> actions;
 
     /**
      * The parent container, for traceability.
@@ -42,8 +42,7 @@ public abstract class Executable implements Serializable {
      * Constructor.
      */
     public Executable() {
-        super();
-        this.actions = new ArrayList<Action>();
+        this.actions = new ArrayList<>();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Final.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Final.java b/src/main/java/org/apache/commons/scxml2/model/Final.java
index ff8f95d..bfc0a8e 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Final.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Final.java
@@ -90,7 +90,7 @@ public class Final extends EnterableState {
                 Context ctx = exctx.getScInstance().getGlobalContext();
                 if (content != null) {
                     if (content.getExpr() != null) {
-                        Object evalResult = null;
+                        Object evalResult;
                         try {
                             evalResult = eval.eval(ctx, content.getExpr());
                         } catch (SCXMLExpressionException e) {

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Foreach.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Foreach.java b/src/main/java/org/apache/commons/scxml2/model/Foreach.java
index 9f15beb..73ace8f 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Foreach.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Foreach.java
@@ -46,10 +46,9 @@ public class Foreach extends Action implements ActionsContainer {
      * The set of executable elements (those that inheriting from
      * Action) that are contained in this &lt;if&gt; element.
      */
-    private List<Action> actions;
+    private final List<Action> actions;
 
     public Foreach() {
-        super();
         this.actions = new ArrayList<>();
     }
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/If.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/If.java b/src/main/java/org/apache/commons/scxml2/model/If.java
index 7f90ade..0243bd9 100644
--- a/src/main/java/org/apache/commons/scxml2/model/If.java
+++ b/src/main/java/org/apache/commons/scxml2/model/If.java
@@ -51,7 +51,7 @@ public class If extends Action implements ActionsContainer {
      * The set of executable elements (those that inheriting from
      * Action) that are contained in this &lt;if&gt; element.
      */
-    private List<Action> actions;
+    private final List<Action> actions;
 
     /**
      * The boolean value that dictates whether the particular child action
@@ -64,7 +64,7 @@ public class If extends Action implements ActionsContainer {
      */
     public If() {
         super();
-        this.actions = new ArrayList<Action>();
+        this.actions = new ArrayList<>();
         this.execute = false;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/NodeTextValue.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/NodeTextValue.java b/src/main/java/org/apache/commons/scxml2/model/NodeTextValue.java
index af1c9b5..a798699 100644
--- a/src/main/java/org/apache/commons/scxml2/model/NodeTextValue.java
+++ b/src/main/java/org/apache/commons/scxml2/model/NodeTextValue.java
@@ -24,7 +24,7 @@ public class NodeTextValue implements ParsedValue {
     /**
      * the XML node as text
      */
-    private String nodeText;
+    private final String nodeText;
 
     public NodeTextValue(final String nodeText) {
         this.nodeText = nodeText;


Mime
View raw message