Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

AnnotatedType support

オープン
#25 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
devtools

調査の方向性

まず ResolvedType と既存の typeParametersFor(List.class) の動作を読み、その後 Java 8 の AnnotatedType および AnnotatedParameterizedType と比較します。解決済みの型パラメーターが関連するアノテーションをどのように公開するかを定義し、適切な互換性スイッチによって Java 7 のサポートを維持します。完了の条件は、例に対して @Null ではなく @NotNull が取得されることです。

索引モデルが issue の本文から書いたものです。

説明

New to Java 8, the AnnotatedType class carries annotations bind to types in Generic expressions.
So if I write

@MaxLength(3) List<@NotNull Integer> myField;

I can get the @NotNull annotation via something like:

Field f = MyClass.class.getDeclaredField("myField");
AnnotatedParameterizedType annType = (AnnotatedParameterizedType) field.getAnnotatedType();
AnnotatedType[] childAnnotatedTypes = annType.getAnnotatedActualTypeArguments();

But then I have to assume the parameter I want is the first in the returned array. But maybe I have something like

class MyFunnyList<T> implements List<@NotNull Integer> {}
// ...
private MyFunnyList<@Null String> myFunnyField;

Using ResolvedType, I can call type.typeParametersFor(List.class).get(0) to get the correct parameter type (Integer rather than String). It'd be nice to have also a way to retrieve the annotations associated with it (@NotNull rather than @Null). Note that this feature must not break support for Java 7, so some type of switch will probably need to be used.

主要言語
Java
スター
266
フォーク
47
平均マージ
1時間 42分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

FasterXML/java-classmate のほかの issue

FasterXML/java-classmate の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。