Comparable Arns
- 主要言語
- Java
- スター
- 2.6k
- フォーク
- 1k
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 51
説明
### Describe the feature
It'd be nice if [Arn](https://github.com/aws/aws-sdk-java-v2/blob/master/core/arns/src/main/java/software/amazon/awssdk/arns/Arn.java) implemented `Comparable`.
This would make Arns usable in sorted collection types, etc.
### Is your Feature Request related to a problem?
Not really.
- We can use `HashMap` instead of `TreeMap`, etc.
- We can sort Arns by converting to strings, sorting, then converting back to Arns.
So this would just make Arns more flexible.
### Proposed Solution
Here is a straightforward implementation:
public static final Comparator COMPARATOR =
Comparator.comparing(Arn::toString);
@Override
public int compareTo(Arn rhs) {
return COMPARATOR.compare(this, rhs);
}
Here is a more elaborate one, which may be more efficient by avoiding the String construction:
public static final Comparator COMPARATOR =
Comparator.comparing(Arn::partition)
.thenComparing(Arn::service)
.thenComparing(x -> x.region, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(x -> x.accountId, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(Arn::resourceAsString);
@Override
public int compareTo(Arn rhs) {
return COMPARATOR.compare(this, rhs);
}
### Describe alternatives you've considered
_No response_
### Acknowledge
- [X] I may be able to implement this feature request
### AWS Java SDK version used
aws-sdk-java-v2 c0eb030fceaa9ccb64ad8acd74445f4e5ee3a547
### JDK version used
openjdk version "1.8.0_312"
### Operating System and version
MacOS Big Sur Version 11.6.2 (20G314)
コントリビューションガイド
調査の方向性
Issue で指定されているエントリーポイントである Arn.java から始め、ARN コンポーネントと文字列表現がどのように公開されているかを確認します。提案されている順序付けのアプローチのいずれかを使用して、要求された比較可能な動作を実装し、その後、Arn インスタンスをソート済みコレクションで使用できること、および順序付けに一貫性があることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 38/100