Skip to content

Commit 78d10cd

Browse files
committed
refactor(yaml-reader): rename variable anchors to anchorMap
Makes the name more descriptive and readable. By reading the name you can tell it's a hashmap which was not clear previously.
1 parent 7a31a96 commit 78d10cd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/com/esotericsoftware/yamlbeans/YamlReader.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
public class YamlReader implements AutoCloseable {
5050
private final YamlConfig config;
5151
Parser parser;
52-
private final Map<String, Object> anchors = new HashMap();
52+
private final Map<String, Object> anchorMap = new HashMap();
5353

5454
public YamlReader (Reader reader) {
5555
this(reader, new YamlConfig());
@@ -75,16 +75,16 @@ public YamlConfig getConfig () {
7575
/** Return the object with the given alias, or null. This is only valid after objects have been read and before
7676
* {@link #close()} */
7777
public Object get (String alias) {
78-
return anchors.get(alias);
78+
return anchorMap.get(alias);
7979
}
8080

8181
private void addAnchor (String key, Object value) {
82-
if (config.readConfig.anchors) anchors.put(key, value);
82+
if (config.readConfig.anchors) anchorMap.put(key, value);
8383
}
8484

8585
public void close () throws IOException {
8686
parser.close();
87-
anchors.clear();
87+
anchorMap.clear();
8888
}
8989

9090
/** Reads the next YAML document and deserializes it into an object. The type of object is defined by the YAML tag. If there is
@@ -107,7 +107,7 @@ public <T> T read (Class<T> type) throws YamlException {
107107
* @param type The type of object to read. If null, behaves the same as {{@link #read()}.
108108
* @throws YamlReaderException if the YAML data specifies a type that is incompatible with the specified type. */
109109
public <T> T read (Class<T> type, Class elementType) throws YamlException {
110-
anchors.clear();
110+
anchorMap.clear();
111111
try {
112112
while (true) {
113113
Event event = parser.getNextEvent();
@@ -160,7 +160,7 @@ protected Object readValue (Class type, Class elementType, Class defaultType)
160160
case ALIAS:
161161
parser.getNextEvent();
162162
anchor = ((AliasEvent)event).anchor;
163-
Object value = anchors.get(anchor);
163+
Object value = anchorMap.get(anchor);
164164
if (value == null && config.readConfig.anchors) throw new YamlReaderException("Unknown anchor: " + anchor);
165165
return value;
166166
case MAPPING_START:

0 commit comments

Comments
 (0)