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

net.n2oapp.security.admin.impl.service.UserLevelServiceImpl Maven / Gradle / Ivy

There is a newer version: 8.0.1
Show newest version
package net.n2oapp.security.admin.impl.service;

import net.n2oapp.security.admin.api.model.UserLevel;
import net.n2oapp.security.admin.api.service.UserLevelService;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import static java.util.Objects.isNull;

/**
 * Сервис уровней пользователя
 */
public class UserLevelServiceImpl implements UserLevelService {

    private List userLevels;
    private List userLevelsForFilter;

    public UserLevelServiceImpl(List userLevels) {
        this.userLevels = userLevels;
        userLevelsForFilter = new ArrayList<>(userLevels);
        userLevelsForFilter.add(UserLevel.NOT_SET);
    }

    @Override
    public List getAll() {
        return userLevels;
    }

    @Override
    public List getAllForFilter(String name) {
        if (isNull(name))
            return userLevelsForFilter;
        List result = new ArrayList<>();
        result.addAll(userLevelsForFilter.stream().filter(userLevel -> userLevel.getDesc().toLowerCase().contains(name.toLowerCase())).collect(Collectors.toList()));
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy