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

com.github.nagyesta.lowkeyvault.mapper.common.VaultFakeToVaultModelConverter Maven / Gradle / Ivy

package com.github.nagyesta.lowkeyvault.mapper.common;

import com.github.nagyesta.lowkeyvault.model.management.VaultModel;
import com.github.nagyesta.lowkeyvault.service.vault.VaultFake;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class VaultFakeToVaultModelConverter implements Converter {

    @Override
    public VaultModel convert(@Nullable final VaultFake source) {
        return Optional.ofNullable(source)
                .map(this::convertNonNull)
                .orElse(null);
    }

    @NonNull
    public VaultModel convertNonNull(@NonNull final VaultFake fake) {
        final VaultModel model = new VaultModel();
        model.setBaseUri(fake.baseUri());
        model.setAliases(fake.aliases());
        model.setRecoveryLevel(fake.getRecoveryLevel());
        model.setRecoverableDays(fake.getRecoverableDays());
        model.setCreatedOn(fake.getCreatedOn());
        model.setDeletedOn(fake.getDeletedOn());
        return model;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy