Package org.apache.ignite.table.mapper
Class RecordSupportInternal
java.lang.Object
org.apache.ignite.table.mapper.RecordSupportInternal
Enables access to
RecordSupport without reflection to provides utility methods to support records in Java 11.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Constructor<T>getCanonicalConstructor(Class<T> clazz) Java 11 compatible, reflection based alternative to find the record canonical constructor.static booleanJava 11 compatible, reflection based alternative, that returns true if and only if this class is a record class.
-
Method Details
-
isRecord
Java 11 compatible, reflection based alternative, that returns true if and only if this class is a record class.Without reflection:
Class<?> clazz; clazz.isRecord();- Parameters:
clazz- Class to check.- Returns:
trueif and only if the given class is a record class.- Throws:
IllegalAccessException- If the record support methods could not be accessed.
-
getCanonicalConstructor
public static <T> Constructor<T> getCanonicalConstructor(Class<T> clazz) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException Java 11 compatible, reflection based alternative to find the record canonical constructor.Without reflection:
static <T extends Record> Constructor<T> getCanonicalConstructor(Class<T> cls) throws NoSuchMethodException { Class<?>[] paramTypes = Arrays.stream(cls.getRecordComponents()) .map(RecordComponent::getType) .toArray(Class<?>[]::new); return cls.getDeclaredConstructor(paramTypes); }- Type Parameters:
T- Type of the record class.- Parameters:
clazz- Record class to find the canonical constructor for.- Returns:
- Canonical constructor of the given record class.
- Throws:
NoSuchMethodException- If the canonical constructor could not be found.InvocationTargetException- If a reflective record support method threw an exception.IllegalAccessException- If a reflective record support method could not be accessed.ClassNotFoundException- Ifjava.lang.reflect.RecordComponentcould not be resolved.
-