From 44c499e6b2186b16ff1aa60ad4c9e22f7b0c64fa Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Tue, 15 Mar 2011 16:43:00 +0100 Subject: [PATCH] SONAR-2230 Refactor to decrease complexity --- .../unmarshallers/ProfileUnmarshaller.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java index 9af6118515c..00c6030d5ba 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java @@ -35,6 +35,11 @@ public class ProfileUnmarshaller extends AbstractUnmarshaller { .setParentName(utils.getString(json, "parent")) .setProvided(utils.getBoolean(json, "provided")); + parseRules(utils, profile, json); + return profile; + } + + private void parseRules(WSUtils utils, Profile profile, Object json) { Object rulesJson = utils.getField(json, "rules"); if (rulesJson != null) { for (int i = 0; i < utils.getArraySize(rulesJson); i++) { @@ -46,18 +51,21 @@ public class ProfileUnmarshaller extends AbstractUnmarshaller { rule.setSeverity(utils.getString(ruleJson, "severity")); rule.setInheritance(utils.getString(ruleJson, "inheritance")); - Object paramsJson = utils.getField(ruleJson, "params"); - if (paramsJson != null) { - for (int indexParam = 0; indexParam < utils.getArraySize(paramsJson); indexParam++) { - Object paramJson = utils.getArrayElement(paramsJson, indexParam); - rule.addParameter(utils.getString(paramJson, "key"), utils.getString(paramJson, "value")); - } - } + parseRuleParameters(utils, rule, ruleJson); profile.addRule(rule); } } } - return profile; + } + + private void parseRuleParameters(WSUtils utils, Profile.Rule rule, Object ruleJson) { + Object paramsJson = utils.getField(ruleJson, "params"); + if (paramsJson != null) { + for (int indexParam = 0; indexParam < utils.getArraySize(paramsJson); indexParam++) { + Object paramJson = utils.getArrayElement(paramsJson, indexParam); + rule.addParameter(utils.getString(paramJson, "key"), utils.getString(paramJson, "value")); + } + } } } -- 2.39.5