Skip to content

Commit

Permalink
cleanup: make the whole class final instead of some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnaber committed Mar 14, 2015
1 parent 5091ed9 commit f92bf06
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions languagetool-core/src/main/java/org/languagetool/AnalyzedToken.java
Expand Up @@ -29,19 +29,14 @@
*
* @author Daniel Naber
*/
public class AnalyzedToken {
public final class AnalyzedToken {

private final String token;
private final String posTag;
private final String lemma;

/**
* used only for matching with Elements
*/
private final String tokenInflected;
private final String tokenInflected; // used only for matching with Elements

private boolean isWhitespaceBefore;

private boolean hasNoPOSTag;

public AnalyzedToken(final String token, final String posTag, final String lemma) {
Expand All @@ -58,46 +53,47 @@ public AnalyzedToken(final String token, final String posTag, final String lemma
|| JLanguageTool.PARAGRAPH_END_TAGNAME.equals(posTag));
}

public final String getToken() {
public String getToken() {
return token;
}

/**
* @return the token's part-of-speech tag {@code null}
*/
@Nullable
public final String getPOSTag() {
public String getPOSTag() {
return posTag;
}

/**
* @return the token's lemma or {@code null}
*/
@Nullable
public final String getLemma() {
public String getLemma() {
return lemma;
}

/**
* Like {@link #getLemma()}, but returns the token if the lemma is {@code null}
*/
@Nullable
public final String getTokenInflected() {
public String getTokenInflected() {
return tokenInflected;
}

public final void setWhitespaceBefore(final boolean isWhite) {
isWhitespaceBefore = isWhite;
public void setWhitespaceBefore(boolean whitespaceBefore) {
isWhitespaceBefore = whitespaceBefore;
}

public final boolean isWhitespaceBefore() {
public boolean isWhitespaceBefore() {
return isWhitespaceBefore;
}


/**
* @param an AnalyzedToken to test
* @return true if all of the non-null values (lemma, POS, token) of AnalyzedToken match this token
* @since 1.5
*/
public final boolean matches(final AnalyzedToken an) {
public boolean matches(final AnalyzedToken an) {
if (this.equals(an)) {
return true;
}
Expand All @@ -123,7 +119,7 @@ public final boolean matches(final AnalyzedToken an) {
* @return true if the AnalyzedToken has no real POS tag (= is not null or a special tag)
* @since 1.5
*/
public final boolean hasNoTag() {
public boolean hasNoTag() {
return hasNoPOSTag;
}

Expand All @@ -134,7 +130,7 @@ public final boolean hasNoTag() {
* cases.
* @since 1.5
*/
public final void setNoPOSTag(final boolean noTag) {
public void setNoPOSTag(boolean noTag) {
hasNoPOSTag = noTag;
}

Expand All @@ -144,12 +140,12 @@ public String toString() {
}

@Override
public final int hashCode() {
public int hashCode() {
return new HashCodeBuilder().append(isWhitespaceBefore).append(lemma).append(posTag).append(token).toHashCode();
}

@Override
public final boolean equals(final Object obj) {
public boolean equals(final Object obj) {
if (obj == null) { return false; }
if (obj == this) { return true; }
if (obj.getClass() != getClass()) {
Expand Down

0 comments on commit f92bf06

Please sign in to comment.