}
if (identifier == null) {
throw new IllegalArgumentException("identifier cannot be null");
}
Path path = context.getCurrentPath();
Definition definition = (Definition) definitions.get(identifier);
if (definition == null) {
definition = new Definition(source, path);
definitions.put(identifier, definition);
} else if (definition.getPath().getAsString().equals(path.getAsString())) {
// Redefining the same object twice so just ignore it.
} else {
// Duplicate definitions found. If the definition is not already
// marked as duplicated then mark it and report it as a duplicate.
if (!definition.isDuplicated()) {
SourceLocation firstSource = definition.getSource();
Path firstPath = definition.getPath();
reportDuplicate(context, firstSource, firstPath, identifier);
definition.setDuplicated(true);
}