Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kelvinqian00
Copy link
Contributor

Implement a LangTag class that wraps the original language tag string and a java.util.Locale instance. Use it as LangMap keys and for the context.language property.

* @param languageCode RFC 5646 Language Tag
*/
public void remove(String languageCode) {
public void remove(LangTag languageCode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wanted string overloads for everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So have both (in this case) remove(String str) and remove(LangTag langTag)? And if that's so shouldn't the same be applied to the Extensions class with URIs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes have both. And yeah extensions would be nice too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note how in addition to adding the overloaded methods for both LangMaps and extensions, I also added the IFreeMap interface so that we can:

  • enforce the contract of needing not just get, put, and remove, but overloaded variants of each
  • have a single FreeMapSerializer instead of two separate serializers

@JsonCreator
public LangTag(String langTagStr) throws IllformedLocaleException {
Builder builder = new Builder();
languageTagLocale = builder.setLanguageTag(langTagStr).build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a static helper for this. Builder doesnt even need to be imported.

https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Locale.html#forLanguageTag(java.lang.String)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah now I know why I used the Builder class instead of forLanguageTag. The former throws an exception on invalid language tags; the latter doesn't, and that is why CI is failing now.

@kelvinqian00 kelvinqian00 requested a review from phleven December 12, 2024 16:39
@cliffcaseyyet cliffcaseyyet changed the base branch from uri-for-iris to main May 7, 2025 13:54
@cliffcaseyyet cliffcaseyyet merged commit c5e8958 into main May 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants