public class CustomCollectionEditor extends PropertyEditorSupportSE
デフォルトでは、Set、SortedSet、List に登録されており、型がターゲットプロパティと一致しない場合に、指定されたコレクションをそれらのターゲット型の 1 つに自動的に変換します。
Collection
SE, Set
SE, SortedSet
SE, List
SEコンストラクターと説明 |
---|
CustomCollectionEditor(ClassSE<? extends CollectionSE> collectionType) 指定されたターゲット型の新しい CustomCollectionEditor を作成し、受信 null をそのまま保持します。 |
CustomCollectionEditor(ClassSE<? extends CollectionSE> collectionType, boolean nullAsEmptyCollection) 指定されたターゲット型の新しい CustomCollectionEditor を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected boolean | alwaysCreateNewCollection() 渡されたコレクションの型がすでに一致している場合でも、常に新しいコレクションを作成するかどうかを返します。 |
protected ObjectSE | convertElement(ObjectSE element) 遭遇した各コレクション / 配列要素を変換するフック。 |
protected CollectionSE<ObjectSE> | createCollection(ClassSE<? extends CollectionSE> collectionType, int initialCapacity) 指定された初期容量で、指定された型のコレクションを作成します(コレクション型でサポートされている場合)。 |
StringSE | getAsText() この実装は null を返し、適切なテキスト表現がないことを示します。 |
void | setAsText(StringSE text) 指定されたテキスト値を単一の要素を持つコレクションに変換します。 |
void | setValue(ObjectSE value) 指定された値をターゲット型のコレクションに変換します。 |
addPropertyChangeListenerSE, firePropertyChangeSE, getCustomEditorSE, getJavaInitializationStringSE, getSourceSE, getTagsSE, getValueSE, isPaintableSE, paintValueSE, removePropertyChangeListenerSE, setSourceSE, supportsCustomEditorSE
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public CustomCollectionEditor(ClassSE<? extends CollectionSE> collectionType)
null
をそのまま保持します。collectionType
- ターゲット型。コレクションのサブインターフェースまたは具象コレクションクラスである必要があります Collection
SE, ArrayList
SE, TreeSet
SE, LinkedHashSet
SEpublic CustomCollectionEditor(ClassSE<? extends CollectionSE> collectionType, boolean nullAsEmptyCollection)
入力値が指定された型の場合は、そのまま使用されます。別のコレクション型または配列の場合は、指定されたコレクション型のデフォルト実装に変換されます。値がそれ以外の場合、その単一の値を持つターゲットコレクションが作成されます。
デフォルトのコレクションの実装は、ArrayList(リスト)、TreeSet(SortedSet)、LinkedHashSet(セット)です。
collectionType
- ターゲット型。コレクションのサブインターフェースまたは具象コレクションクラスである必要があります nullAsEmptyCollection
- 受信 null
値を空のコレクションに変換するかどうか (適切な型)Collection
SE, ArrayList
SE, TreeSet
SE, LinkedHashSet
SEpublic void setAsText(StringSE text) throws IllegalArgumentExceptionSE
PropertyEditorSE
の setAsTextSE
PropertyEditorSupportSE
の setAsTextSE
IllegalArgumentExceptionSE
public void setValue(@Nullable ObjectSE value)
PropertyEditorSE
の setValueSE
PropertyEditorSupportSE
の setValueSE
protected CollectionSE<ObjectSE> createCollection(ClassSE<? extends CollectionSE> collectionType, int initialCapacity)
collectionType
- コレクションのサブインターフェース initialCapacity
- 初期容量 protected boolean alwaysCreateNewCollection()
デフォルトは "false" です。新しいコレクションの作成を強制するために、たとえば、いかなる場合でも要素を変換するためにオーバーライドできます。
protected ObjectSE convertElement(ObjectSE element)
特定の要素の変換を実行するためにオーバーライドできます。たとえば、String 配列が入って Integer オブジェクトのセットに変換する必要がある場合は、String から Integer に変換できます。
実際に新しいコレクションを作成する場合にのみ呼び出されます! これは、渡されたコレクションの型がすでに一致している場合、デフォルトでは当てはまりません。常に alwaysCreateNewCollection()
をオーバーライドして、新しいコレクションの作成を強制します。
element
- ソース要素 alwaysCreateNewCollection()
@Nullable public StringSE getAsText()
null
を返し、適切なテキスト表現がないことを示します。PropertyEditorSE
の getAsTextSE
PropertyEditorSupportSE
の getAsTextSE