Skip to content

Commit

Permalink
Add missing Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 28, 2024
1 parent 7c8f3d6 commit 4b32c49
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions src/main/java/org/apache/commons/codec/language/bm/Languages.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ public class Languages {
*/
public abstract static class LanguageSet {

public static LanguageSet from(final Set<String> langs) {
return langs.isEmpty() ? NO_LANGUAGES : new SomeLanguages(langs);
/**
* Gets a language set for the given languages.
*
* @param languages a language set.
* @return a LanguageSet.
*/
public static LanguageSet from(final Set<String> languages) {
return languages.isEmpty() ? NO_LANGUAGES : new SomeLanguages(languages);
}

/**
Expand All @@ -81,16 +87,43 @@ public LanguageSet() {
// empty
}

/**
* Tests whether this instance contains the given value.
*
* @param language the value to test.
* @return whether this instance contains the given value.
*/
public abstract boolean contains(String language);

/**
* Gets any of this instance's element.
*
* @return any of this instance's element.
*/
public abstract String getAny();

/**
* Tests whether this instance is empty.
*
* @return whether this instance is empty.
*/
public abstract boolean isEmpty();

/**
* Tests whether this instance contains a single element.
*
* @return whether this instance contains a single element.
*/
public abstract boolean isSingleton();

abstract LanguageSet merge(LanguageSet other);

/**
* Returns an instance restricted to this instances and the given values'.
*
* @param other The other instance.
* @return an instance restricted to this instances and the given values'.
*/
public abstract LanguageSet restrictTo(LanguageSet other);
}

Expand All @@ -114,6 +147,11 @@ public String getAny() {
return this.languages.iterator().next();
}

/**
* Gets the language strings
*
* @return the languages strings.
*/
public Set<String> getLanguages() {
return this.languages;
}
Expand Down Expand Up @@ -161,6 +199,9 @@ public String toString() {

}

/**
* Marker for any language.
*/
public static final String ANY = "any";

private static final Map<NameType, Languages> LANGUAGES = new EnumMap<>(NameType.class);
Expand Down Expand Up @@ -253,10 +294,22 @@ public String toString() {
}
}

/**
* Gets an instance for the given name type.
*
* @param nameType The name type to lookup.
* @return an instance for the given name type.
*/
public static Languages getInstance(final NameType nameType) {
return LANGUAGES.get(nameType);
}

/**
* Gets a new instance for the given resource name.
*
* @param languagesResourceName the resource name to lookup.
* @return a new instance.
*/
public static Languages getInstance(final String languagesResourceName) {
// read languages list
final Set<String> ls = new HashSet<>();
Expand Down Expand Up @@ -289,6 +342,11 @@ private Languages(final Set<String> languages) {
this.languages = languages;
}

/**
* Gets the language set.
*
* @return the language set.
*/
public Set<String> getLanguages() {
return this.languages;
}
Expand Down

0 comments on commit 4b32c49

Please sign in to comment.