diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-15 16:43:00 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-15 16:43:00 +0100 |
commit | 44c499e6b2186b16ff1aa60ad4c9e22f7b0c64fa (patch) | |
tree | fbb81625675567ff678fc0dc17f3101998cca57f /sonar-ws-client/src/main/java/org/sonar/wsclient | |
parent | 73a5f721a6b3a56bf1b7edc1f3e69350138e113b (diff) | |
download | sonarqube-44c499e6b2186b16ff1aa60ad4c9e22f7b0c64fa.tar.gz sonarqube-44c499e6b2186b16ff1aa60ad4c9e22f7b0c64fa.zip |
SONAR-2230 Refactor to decrease complexity
Diffstat (limited to 'sonar-ws-client/src/main/java/org/sonar/wsclient')
-rw-r--r-- | sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java | 24 |
1 files 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<Profile> { .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<Profile> { 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")); + } + } } } |