X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fso%2Fclient%2Fgraphinventory%2Fentities%2Furi%2Fparsers%2FUriParserSpringImpl.java;h=14a46c243b4fe257d93bd902b326fa6704c43d01;hb=f47919f1fe367b612fa9c96d34c59f01a541e882;hp=b4cf8eb949ea8688995c99814fb90ab592b04218;hpb=54452b80a1cf4d22ef750bc1377f8c1b05431d57;p=so.git diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java index b4cf8eb949..14a46c243b 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java @@ -19,6 +19,7 @@ */ package org.onap.so.client.graphinventory.entities.uri.parsers; + import java.io.UnsupportedEncodingException; import java.util.Collections; import java.util.LinkedHashMap; @@ -26,39 +27,38 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; - import org.springframework.web.util.UriTemplate; import org.springframework.web.util.UriUtils; public class UriParserSpringImpl implements UriParser { - private final UriTemplate uriTemplate; + private final UriTemplate uriTemplate; + + public UriParserSpringImpl(final String template) { + this.uriTemplate = new UriTemplate(template); + } - public UriParserSpringImpl(final String template) { - this.uriTemplate = new UriTemplate(template); - } + @Override + public Map parse(final String uri) { + final boolean match = this.uriTemplate.matches(uri); + if (!match) { + return new LinkedHashMap<>(); + } + return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri))); + } - @Override - public Map parse(final String uri) { - final boolean match = this.uriTemplate.matches(uri); - if (!match) { - return new LinkedHashMap<>(); + @Override + public Set getVariables() { + return Collections.unmodifiableSet(new LinkedHashSet(this.uriTemplate.getVariableNames())); } - return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri))); - } - @Override - public Set getVariables() { - return Collections.unmodifiableSet(new LinkedHashSet(this.uriTemplate.getVariableNames())); - } - - protected Map decodeParams(Map map) { - final Map result = new LinkedHashMap<>(); - - for (Entry entry : map.entrySet()) { - result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); - } - - return result; - } + protected Map decodeParams(Map map) { + final Map result = new LinkedHashMap<>(); + + for (Entry entry : map.entrySet()) { + result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); + } + + return result; + } }