ca.gc.aafc.dina.mapper.DinaFieldAdapterHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dina-base-api Show documentation
Show all versions of dina-base-api Show documentation
Base DINA API package for Java built on SpringBoot and Crnk
The newest version!
package ca.gc.aafc.dina.mapper;
import io.crnk.core.queryspec.FilterSpec;
import lombok.SneakyThrows;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
/**
* Handles the mapping of fields between entities and Dto's using {@link DinaFieldAdapter}.
*
* @param - Dto class
*/
public class DinaFieldAdapterHandler {
private final Set> adapters;
private final Class extends D> dtoClass;
public DinaFieldAdapterHandler(Class extends D> dtoClass) {
this.dtoClass = dtoClass;
this.adapters = initAdapters(dtoClass);
}
@SneakyThrows
@SuppressWarnings("unchecked")
private Set> initAdapters(Class extends D> dtoClass) {
Set> set = new HashSet<>();
if (dtoClass.isAnnotationPresent(CustomFieldAdapter.class)) {
for (Class extends DinaFieldAdapter, ?, ?, ?>> aClass :
dtoClass.getAnnotation(CustomFieldAdapter.class).adapters()) {
set.add(
(DinaFieldAdapter
© 2015 - 2024 Weber Informatics LLC | Privacy Policy