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

com.github.saphyra.randwo.key.service.create.CreateKeyService Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.github.saphyra.randwo.key.service.create;

import java.util.UUID;

import org.springframework.stereotype.Service;

import com.github.saphyra.randwo.key.domain.Key;
import com.github.saphyra.randwo.key.repository.KeyDao;
import com.github.saphyra.randwo.key.service.KeyValueValidator;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class CreateKeyService {
    private final KeyDao keyDao;
    private final KeyFactory keyFactory;
    private final KeyValueValidator keyValueValidator;

    public UUID createKey(String keyValue) {
        keyValueValidator.validate(keyValue);

        Key key = keyFactory.create(keyValue);
        keyDao.save(key);
        return key.getKeyId();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy