All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.rest.mappers.policyAgreement.PolicyAgreementConfigurationMapper Maven / Gradle / Ivy

/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.rest.mappers.policyAgreement;

import java.util.Optional;

import io.imunity.rest.api.types.policyAgreement.RestPolicyAgreementConfiguration;
import io.imunity.rest.mappers.I18nStringMapper;
import pl.edu.icm.unity.base.policy_agreement.PolicyAgreementConfiguration;
import pl.edu.icm.unity.base.policy_agreement.PolicyAgreementPresentationType;

public class PolicyAgreementConfigurationMapper
{
	public static RestPolicyAgreementConfiguration map(PolicyAgreementConfiguration policyAgreementConfiguration)
	{
		return RestPolicyAgreementConfiguration.builder()
				.withDocumentsIdsToAccept(Optional.ofNullable(policyAgreementConfiguration.documentsIdsToAccept)
						.orElse(null))
				.withPresentationType(policyAgreementConfiguration.presentationType.name())
				.withText(Optional.ofNullable(policyAgreementConfiguration.text)
						.map(I18nStringMapper::map)
						.orElse(null))
				.build();
	}

	public static PolicyAgreementConfiguration map(RestPolicyAgreementConfiguration restPolicyAgreementConfiguration)
	{
		return new PolicyAgreementConfiguration(restPolicyAgreementConfiguration.documentsIdsToAccept,
				PolicyAgreementPresentationType.valueOf(restPolicyAgreementConfiguration.presentationType),
				Optional.ofNullable(restPolicyAgreementConfiguration.text)
						.map(I18nStringMapper::map)
						.orElse(null));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy