changeset 829:97154448d880

refactoring
author Devel 1
date Fri, 19 Jan 2018 11:49:07 +0100
parents f59c62ed5c4b
children 611ffdc69f04
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java
diffstat 1 files changed, 6 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java	Fri Jan 19 11:45:08 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java	Fri Jan 19 11:49:07 2018 +0100
@@ -45,8 +45,8 @@
         return null;
     }
 
-    private Operation createNameValueOperation(CTupleNode nodeTuple, Errors errors, Class<? extends Operation> clazz) {
-        Operation op = null;
+    private AbstractNameValueOperation createNameValueOperation(CTupleNode nodeTuple, Errors errors, Class<? extends AbstractNameValueOperation> clazz) {
+        AbstractNameValueOperation op = null;
         if (validateType(nodeTuple.getNode(), NodeType.MAP, errors)) {
             List<CTupleNode> tuples = ((CMapNode) nodeTuple.getNode()).getChildren();
             boolean escape = true;
@@ -85,21 +85,18 @@
                     op = clazz
                             .getConstructor(CharSequence.class, ValueExtractor.class)
                             .newInstance(field, valueTransformer);
+                    op.setEscape(escape);
                 } catch (Exception e) {
                     throw new RuntimeException(e.getMessage(), e);
                 }
             }
-
-            if (op instanceof AbstractNameValueOperation) {
-                ((AbstractNameValueOperation) op).setEscape(escape);
-            }
         }
 
         return op;
     }
 
-    private Operation createAddParamOperation(CTupleNode nodeTuple, Errors errors, Class<? extends Operation> clazz) {
-        Operation op = null;
+    private AddParamOperation createAddParamOperation(CTupleNode nodeTuple, Errors errors, Class<? extends AddParamOperation> clazz) {
+        AddParamOperation op = null;
         if (validateType(nodeTuple.getNode(), NodeType.MAP, errors)) {
             List<CTupleNode> tuples = ((CMapNode) nodeTuple.getNode()).getChildren();
             boolean escape = true;
@@ -130,6 +127,7 @@
                             op = clazz
                                     .getConstructor(CharSequence.class, Object.class)
                                     .newInstance(tuple.getName(), value);
+                            op.setEscape(escape);
                         } catch (Exception e) {
                             throw new RuntimeException(e.getMessage(), e);
                         }
@@ -141,10 +139,6 @@
                     break;
                 }
             }
-
-            if (op instanceof AddParamOperation) {
-                ((AddParamOperation) op).setEscape(escape);
-            }
         }
 
         return op;