Skip to content

Commit f452d79

Browse files
Bugfix-765: Code refactoring
1 parent 504cbab commit f452d79

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/com/magento/idea/magento2plugin/linemarker/php/WebApiLineMarkerProvider.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ public void collectSlowLineMarkers(
8383
/**
8484
* Web API config nodes collector for service methods and classes. Has built in caching.
8585
*/
86-
@SuppressWarnings("PMD.AvoidDoubleBraceInitializationCheck")
8786
private static class WebApiRoutesCollector {
8887

8988
private final Map<String, List<XmlTag>> routesCache = new HashMap<>();
90-
private static final Map<String, Integer> HTTP_METHODS_SORT_ORDER = new HashMap<>() {
91-
{
92-
put("GET", 1);
93-
put("PUT", 2);
94-
put("POS", 3);
95-
put("DEL", 4);
96-
}
97-
};
89+
private final Map<String, Integer> httpMethodsSortOrder;
90+
91+
public WebApiRoutesCollector() {
92+
httpMethodsSortOrder = new HashMap<>();
93+
httpMethodsSortOrder.put("GET", 1);
94+
httpMethodsSortOrder.put("PUT", 2);
95+
httpMethodsSortOrder.put("POS", 3);
96+
httpMethodsSortOrder.put("DEL", 4);
97+
}
9898

9999
/**
100100
* Get sorted list of Web API routes related to the specified class.
@@ -182,8 +182,8 @@ private void sortRoutes(final List<XmlTag> routes) {
182182
routes.sort(
183183
(firstTag, secondTag) -> {
184184
final String substring = firstTag.getName().substring(2, 5);
185-
final Integer firstSortOrder = HTTP_METHODS_SORT_ORDER.get(substring);
186-
final Integer secondSortOrder = HTTP_METHODS_SORT_ORDER.get(
185+
final Integer firstSortOrder = httpMethodsSortOrder.get(substring);
186+
final Integer secondSortOrder = httpMethodsSortOrder.get(
187187
secondTag.getName().substring(2, 5)
188188
);
189189
if (firstSortOrder.compareTo(secondSortOrder) == 0) {

0 commit comments

Comments
 (0)