@Api public abstract class TypeBase<T> extends Object implements Type<T>
Type base. Provides common type logic.| Modifier and Type | Class and Description |
|---|---|
static interface |
TypeBase.Convert<A,T>
Conversion between aliased type and base type.
|
| Modifier and Type | Field and Description |
|---|---|
protected static Class<?>[] |
NO_ALIASES |
| Constructor and Description |
|---|
TypeBase(Class<T> javaType,
T defaultValue) |
| Modifier and Type | Method and Description |
|---|---|
protected <S> void |
aliasType(Class<S> type,
TypeBase.Convert<S,T> aliased) |
abstract T |
convert(String value)
Returns string value converted to Object of this type
|
T |
defaultValue()
Returns default value for this type.
|
protected <I,O> O |
doReadAs(I value,
Class<I> in,
Class<O> out) |
protected boolean |
isAssignable(Class<?> source,
Class<?> target) |
protected boolean |
isForceInstanceWhenReading() |
boolean |
isInstance(Class<?> type)
Checks if given class instances will be considered an instance of this type
Type.isInstance(Object). |
boolean |
isInstance(Object value)
Checks if given value is instance of this type.
|
Class<T> |
javaType()
Returns Java
Class that represents value of this type. |
T |
read(Object value)
Reads given value as this type base java type
Type.javaType(). |
<I,O> O |
readAs(I value,
Class<O> type)
Reads given value as specified type instance.
|
protected void |
setForceInstanceWhenReading(boolean forceInstanceWhenReading) |
String |
toString() |
protected static final Class<?>[] NO_ALIASES
protected void setForceInstanceWhenReading(boolean forceInstanceWhenReading)
protected boolean isForceInstanceWhenReading()
public Class<T> javaType()
TypeClass that represents value of this type.public T defaultValue()
TypedefaultValue in interface Type<T>public boolean isInstance(Object value)
TypeisInstance in interface Type<T>value - any valueprotected <S> void aliasType(Class<S> type, TypeBase.Convert<S,T> aliased)
public boolean isInstance(Class<?> type)
TypeType.isInstance(Object).isInstance in interface Type<T>type - classpublic T read(Object value)
TypeType.javaType(). Specified value must be
an instance of this type (Type.isInstance(Object)).read in interface Type<T>value - any value that is instance of this typeType.javaType() classpublic <I,O> O readAs(I value,
Class<O> type)
TypeType.isInstance(Class) requirements.Copyright © 2022 Suncode. All rights reserved.