FallbackStringToObjectConverter is a StringToObjectConverter
that provides a fallback conversion strategy for converting from a
String to a given target type by invoking a static factory method
or factory constructor defined in the target type.
String to the target type. Use the factory method
if present.String. Use the constructor if present.CharSequence to the target type. Use the factory
method if present.CharSequence. Use the constructor if present.If multiple suitable factory methods or constructors are discovered they will be ignored. If neither a single factory method nor a single constructor is found, this converter acts as a no-op.
ConversionSupport
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static record | FallbackStringToObjectConverter.
|
| pack-priv static record | FallbackStringToObjectConverter.
|
| Modifier and Type | Field and Description |
|---|---|
| private static final ConcurrentHashMap | factoryExecutableCache
Cache for factory methods and factory constructors. |
| private static final Function | NULL_EXECUTABLE
Implementation of the NULL Object Pattern. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canConvertTo(Class<?> targetType)
Implements org. Determine if this converter can convert from a |
| public @Nullable Object | |
| private static @Nullable Constructor | |
| private static Function | |
| private static @Nullable Function | |
| private static @Nullable Method | |
| private static boolean | isFactoryCandidate(Executable executable, Class<?> parameterType)
Determine if the supplied |
| factoryExecutableCache | back to summary |
|---|---|
| private static final ConcurrentHashMap<Class<?>, Function<String, @Nullable Object>> factoryExecutableCache Cache for factory methods and factory constructors. Searches that do not find a factory method or constructor are tracked
by the presence of a | |
| NULL_EXECUTABLE | back to summary |
|---|---|
| private static final Function<String, Object> NULL_EXECUTABLE Implementation of the NULL Object Pattern. | |
| FallbackStringToObjectConverter | back to summary |
|---|---|
| pack-priv FallbackStringToObjectConverter() | |
| canConvertTo | back to summary |
|---|---|
| public boolean canConvertTo(Class<?> targetType) Implements org. Doc from org. Determine if this converter can convert from a
| |
| convert | back to summary |
|---|---|
| public @Nullable Object convert(String source, Class<?> targetType) throws Exception Implements org. Doc from org. Convert the supplied This method will only be invoked if
| |
| findFactoryConstructor | back to summary |
|---|---|
| private static @Nullable Constructor | |
| findFactoryExecutable | back to summary |
|---|---|
| private static Function | |
| findFactoryExecutable | back to summary |
|---|---|
| private static @Nullable Function | |
| findFactoryMethod | back to summary |
|---|---|
| private static @Nullable Method findFactoryMethod(Class<?> targetType, Class<?> parameterType) | |
| isFactoryCandidate | back to summary |
|---|---|
| private static boolean isFactoryCandidate(Executable executable, Class<?> parameterType) Determine if the supplied | |
Predicate that determines if the Constructor supplied to
test(Constructor) is a non-private factory constructor for the
supplied targetType and parameterType.
| Modifier and Type | Field and Description |
|---|---|
| private final Class | parameterType
Record Component accessed by parameterType(). |
| private final Class | targetType
Record Component accessed by targetType(). |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public Class | |
| public Class | |
| public boolean | test(Constructor<?> constructor)
Implements java. Evaluates this predicate on the given argument. |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| parameterType | back to summary |
|---|---|
| private final Class<?> parameterType Record Component accessed by parameterType(). | |
| targetType | back to summary |
|---|---|
| private final Class<?> targetType Record Component accessed by targetType(). | |
| IsFactoryConstructor | back to summary |
|---|---|
| pack-priv IsFactoryConstructor(Class<?> targetType, Class<?> parameterType) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| parameterType | back to summary |
|---|---|
| public Class Record Component getter of parameterType. | |
| targetType | back to summary |
|---|---|
| public Class Record Component getter of targetType. | |
| test | back to summary |
|---|---|
| public boolean test(Constructor<?> constructor) Implements java. Doc from java. Evaluates this predicate on the given argument.
| |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
Predicate that determines if the Method supplied to
test(Method) is a non-private static factory method for the
supplied targetType and parameterType.
| Modifier and Type | Field and Description |
|---|---|
| private final Class | parameterType
Record Component accessed by parameterType(). |
| private final Class | targetType
Record Component accessed by targetType(). |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public Class | |
| public Class | |
| public boolean | test(Method method)
Implements java. Evaluates this predicate on the given argument. |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| parameterType | back to summary |
|---|---|
| private final Class<?> parameterType Record Component accessed by parameterType(). | |
| targetType | back to summary |
|---|---|
| private final Class<?> targetType Record Component accessed by targetType(). | |
| IsFactoryMethod | back to summary |
|---|---|
| pack-priv IsFactoryMethod(Class<?> targetType, Class<?> parameterType) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| parameterType | back to summary |
|---|---|
| public Class Record Component getter of parameterType. | |
| targetType | back to summary |
|---|---|
| public Class Record Component getter of targetType. | |
| test | back to summary |
|---|---|
| public boolean test(Method method) Implements java. Doc from java. Evaluates this predicate on the given argument.
| |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |