public class TypeInformation extends Object
| Constructor and Description |
|---|
TypeInformation(@Nullable Type type)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
static @NotNull TypeInformation |
fromField(@NotNull Field field)
Creates a new TypeInformation instance based on the given field's type.
|
@Nullable TypeInformation |
getGenericType(int index)
"Unwraps" the type and returns the generic type information for the given index, provided the wrapped type
contains generic information.
|
@Nullable Class<?> |
getGenericTypeAsClass(int index)
"Unwraps" the type and returns the generic type information for the given index as Class object,
provided the wrapped type contains generic information.
|
@NotNull Class<?> |
getSafeToReadClass()
Returns a
Class object of the wrapped type which is safe for reading. |
@Nullable Class<?> |
getSafeToWriteClass()
Returns a
Class object of the wrapped type which is safe for writing to. |
@Nullable Type |
getType() |
int |
hashCode() |
@NotNull String |
toString() |
public TypeInformation(@Nullable
@Nullable Type type)
type - the type the instance should wrap@NotNull public static @NotNull TypeInformation fromField(@NotNull @NotNull Field field)
field - the field to create a type information for@Nullable public @Nullable Type getType()
@Nullable public @Nullable Class<?> getSafeToWriteClass()
Class object of the wrapped type which is safe for writing to. In other words, if
this instance wraps the Type of a field, the returned Class of this method is guaranteed to be a valid
value for setting to the field.
Examples:
type = String -> result = String.classtype = List<String> -> result = List.classtype = ? super Integer -> result = Integer.classtype = ? extends Comparable -> result = null@NotNull public @NotNull Class<?> getSafeToReadClass()
Class object of the wrapped type which is safe for reading. For example, if this instance
wraps the Type of a field, then the value on the field is guaranteed to be of the Class type returned by this
method (unless the value is null). The returned Class is as specific as possible.
Examples:
type = String -> result = String.classtype = List<String> -> result = List.classtype = ? super Integer -> result = Object.classtype = ? extends Comparable -> result = Comparable.class@Nullable public @Nullable TypeInformation getGenericType(int index)
Examples for index = 0:
type = String -> result = nulltype = List<String> -> result = String.classtype = Map<List<Integer>, String> -> result = List<Integer>type = List -> result = nullindex - the index of the generic type to get (0-based)@Nullable public @Nullable Class<?> getGenericTypeAsClass(int index)
safe-to-write Class.
Examples for index = 0:
type = String -> result = nulltype = List<String> -> result = String.classtype = Map<List<Integer>, String> -> result = List.classtype = List -> result = nullindex - the index of the generic type to get (0-based)Copyright © 2016–2023 The AuthMe Team. All rights reserved.