Commits
md_5 authored d4962298d9b Merge
63 63 | return patternType; |
64 64 | } |
65 65 | |
66 66 | private static final Map<String, PatternType> byString = new HashMap<String, PatternType>(); |
67 67 | |
68 68 | /** |
69 69 | * Returns the identifier used to represent |
70 70 | * this pattern type |
71 71 | * |
72 72 | * @return the pattern's identifier |
73 + | * @see #getKey |
74 + | * @deprecated magic value |
73 75 | */ |
74 76 | |
77 + | |
75 78 | public abstract String getIdentifier(); |
76 79 | |
77 80 | /** |
78 81 | * Returns the pattern type which matches the passed |
79 82 | * identifier or null if no matches are found |
80 83 | * |
81 84 | * @param identifier the identifier |
82 85 | * @return the matched pattern type or null |
86 + | * @see Registry#BANNER_PATTERN |
87 + | * @deprecated magic value, use {@link Registry#get(NamespacedKey)} instead |
83 88 | */ |
84 89 | "null -> null") | (
85 90 | |
91 + | |
86 92 | public static PatternType getByIdentifier( String identifier) { |
87 93 | if (identifier == null) { |
88 94 | return null; |
89 95 | } |
90 96 | |
91 - | return byString.computeIfAbsent(identifier, id -> { |
92 - | for (PatternType patternType : Registry.BANNER_PATTERN) { |
93 - | if (identifier.equals(patternType.getIdentifier())) { |
94 - | return patternType; |
95 - | } |
97 + | PatternType patternType = byString.get(identifier); |
98 + | if (patternType != null) { |
99 + | return patternType; |
100 + | } |
101 + | |
102 + | for (PatternType type : Registry.BANNER_PATTERN) { |
103 + | if (identifier.equals(type.getIdentifier())) { |
104 + | byString.put(identifier, type); |
105 + | return type; |
96 106 | } |
107 + | } |
97 108 | |
98 - | return null; |
99 - | }); |
109 + | return null; |
100 110 | } |
101 111 | |
102 112 | /** |
103 113 | * @return an array of all known pattern types. |
104 114 | * @deprecated use {@link Registry#iterator()}. |
105 115 | */ |
106 116 | |
107 117 | |
108 118 | public static PatternType[] values() { |
109 119 | return Lists.newArrayList(Registry.BANNER_PATTERN).toArray(new PatternType[0]); |