no.unit.nva.PublicationMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nva-datamodel-java Show documentation
Show all versions of nva-datamodel-java Show documentation
The java version of the NVA datamodel
package no.unit.nva;
import static no.unit.nva.DatamodelConfig.dataModelObjectMapper;
import static no.unit.nva.api.PublicationContext.getContext;
import com.fasterxml.jackson.databind.JsonNode;
import no.unit.nva.model.Publication;
public final class PublicationMapper {
private PublicationMapper() {
}
/**
* Maps a publication and context to specified type.
*
* @param publication publication.
* @param context jsonld context.
* @param Type to be converted to.
* @param responseType Class to be converted to.
* @return publication response
*/
public static R convertValue(
Publication publication, JsonNode context, Class responseType) {
R response = dataModelObjectMapper.convertValue(publication, responseType);
response.setContext(context);
return response;
}
/**
* Maps a publication to specified type with default context.
*
* @param publication publication.
* @param Type to be converted to.
* @param responseType Class to be converted to.
* @return publication response
*/
public static R convertValue(
Publication publication, Class responseType) {
return convertValue(publication, getContext(publication), responseType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy