Skip to content

Commit

Permalink
Change getX to toX methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinqian00 committed Dec 11, 2024
1 parent 8c41e3c commit f8ea00e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
18 changes: 6 additions & 12 deletions src/main/java/com/yetanalytics/xapi/model/LangTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,21 @@ public static LangTag parse(String langTag) {
* Returns the original String version of the LangTag.
* @return LangTag as a String.
*/
@Override
@JsonValue
public String getString() {
public String toString() {
return languageTagString;
}

/**
* Returns the java.util.Locale version of the LangTag.
* Returns the java.util.Locale instance corresponding to the LangTag.
* @return The Locale.
*/
public Locale getLocale() {
public Locale toLocale() {
return languageTagLocale;
}

/**
* Alias of getString.
* @return LangTag as a String.
*/
@Override
public String toString() {
return getString();
}
// Needed due to the fact that LangTags are keys for LangMaps.

/**
* Checks that this LangTag is equal to the langTag based on the orignal
Expand All @@ -76,7 +70,7 @@ public String toString() {
@Override
public boolean equals(Object langTag) {
if (langTag instanceof LangTag) {
return languageTagString.equals(((LangTag) langTag).getString());
return languageTagString.equals(((LangTag) langTag).toString());
} else {
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/yetanalytics/model/LangTagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public class LangTagTest {
@Test
public void testLanguageTag() {
LangTag langTag = new LangTag("en-WK");
assertEquals("en-WK", langTag.getString());
assertEquals("en-WK", langTag.getLocale().toLanguageTag());
assertEquals("en-WK", langTag.toString());
assertEquals("en-WK", langTag.toLocale().toLanguageTag());

LangTag langTag2 = new LangTag("en-wk");
assertEquals("en-wk", langTag2.getString());
assertEquals("en-WK", langTag2.getLocale().toLanguageTag());
assertEquals("en-wk", langTag2.toString());
assertEquals("en-WK", langTag2.toLocale().toLanguageTag());

LangTag langTag3 = new LangTag("yu-555");
assertEquals("yu-555", langTag3.getString());
assertEquals("yu-555", langTag3.getLocale().toLanguageTag());
assertEquals("yu-555", langTag3.toString());
assertEquals("yu-555", langTag3.toLocale().toLanguageTag());
}

@Test
Expand Down

0 comments on commit f8ea00e

Please sign in to comment.