Fix wrong implementation of hasImageEqualTo

This commit is contained in:
Clément Fournier committed 2018-05-18 20:54:43 +02:00
1 parent 9eefc901e4
commit d1ce28d0c9
2 files changed
+12 -1

No files matched your search

@@ -7,6 +7,7 @@ package net.sourceforge.pmd.lang.ast;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -134,7 +135,7 @@ public abstract class AbstractNode implements Node {
@Override
public boolean hasImageEqualTo(String image) {
return this.getImage() != null && this.getImage().equals(image);
return Objects.equals(this.image, image);
}
@Override
@@ -90,10 +90,20 @@ public interface Node {
int jjtGetId();
/**
* Returns a string token, usually filled-in by the parser, which describes some textual
* characteristic of this node. This is usually an identifier.
*/
String getImage();
void setImage(String image);
/**
* Returns true if this node's image is equal to the given string.
*
* @param image The image to check
*/
boolean hasImageEqualTo(String image);
int getBeginLine();