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

io.github.dronesecurity.userapplication.application.user.UserManagerImpl Maven / Gradle / Ivy

/*
 * Copyright (c) 2021-2022, Mirko Felice & Maxim Derevyanchenko. All rights reserved.
 * Licensed under the MIT license. See LICENSE file in the project root for details.
 */

package io.github.dronesecurity.userapplication.application.user;

import io.github.dronesecurity.userapplication.domain.user.entities.contracts.Courier;
import io.github.dronesecurity.userapplication.domain.user.entities.contracts.Maintainer;
import io.github.dronesecurity.userapplication.domain.user.entities.contracts.Role;
import io.github.dronesecurity.userapplication.domain.user.objects.Username;
import io.github.dronesecurity.userapplication.domain.user.repo.UserRepository;
import io.github.dronesecurity.userapplication.domain.user.services.UserManager;

import java.util.Optional;

/**
 * Implementation of {@link UserManager}.
 */
public final class UserManagerImpl implements UserManager {

    private final UserRepository repository;

    /**
     * Build the user manager.
     * @param repository {@link UserRepository} to retrieve entities
     */
    public UserManagerImpl(final UserRepository repository) {
        this.repository = repository;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Optional retrieveCourierByUsername(final Username username) {
        return this.repository.retrieveCourierByUsername(username);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Optional retrieveMaintainerByUsername(final Username username) {
        return this.repository.retrieveMaintainerByUsername(username);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Optional checkLoggedUserRole() {
        return this.repository.checkLoggedUserRole();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Optional retrieveLoggedCourierIfPresent() {
        return this.repository.retrieveLoggedCourierIfPresent();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Optional retrieveLoggedMaintainerIfPresent() {
        return this.repository.retrieveLoggedMaintainerIfPresent();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy