public abstract class Converter<From,To>
extends java.lang.Object
Validator
working on one type (such as String
)
to a Validator
of a different type, such as javax.swing.text.Document
.
In this way, it is possible to write only validators
for String
s, but use them against javax.swing.text.Document
s (for validating
JTextField
and JTextArea
components), etc.Modifier | Constructor and Description |
---|---|
protected |
Converter(java.lang.Class<From> from,
java.lang.Class<To> to) |
Modifier and Type | Method and Description |
---|---|
Validator<To> |
convert(Validator<From>... froms)
Will merge the chain of passed validators to one, and then convert it to
the requested type.
|
abstract Validator<To> |
convert(Validator<From> from)
|
boolean |
equals(java.lang.Object obj) |
static <From,To> Converter<From,To> |
find(java.lang.Class<From> from,
java.lang.Class<To> to)
Find a converter to create validators for one type from validators for
another type.
|
java.lang.Class<From> |
from() |
int |
hashCode() |
static void |
register(Converter<?,?> converter)
Register a converter
|
java.lang.Class<To> |
to() |
public final java.lang.Class<From> from()
public final java.lang.Class<To> to()
public abstract Validator<To> convert(Validator<From> from)
Validator
for type To
from a validator for type
From
. For example, a converter that is a factory for Validators
of javax.swing.text.Document
s from a validator
that only handles Strings may be created. (Convert would simply return a
Validatorfrom
- The original validator.public final Validator<To> convert(Validator<From>... froms)
convert(org.netbeans.validation.api.Validator)
froms
- A chain of validator to convert.public static void register(Converter<?,?> converter)
From
- To
- from
- to
- converter
- public static <From,To> Converter<From,To> find(java.lang.Class<From> from, java.lang.Class<To> to)
From
- The type of object we get from a component, such as a
javax.swing.text.Document
To
- The type of object we want to process, such as a
java.lang.String
from
- A class, such as Document.class
to
- A class such as String.class
From
and produce validators for type To
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object