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

com.vaadin.flow.component.treegrid.demo.service.AccountService Maven / Gradle / Ivy

There is a newer version: 23.0.16
Show newest version
package com.vaadin.flow.component.treegrid.demo.service;

import com.vaadin.flow.component.treegrid.demo.data.AccountData;
import com.vaadin.flow.component.treegrid.demo.entity.Account;

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

public class AccountService {
    private AccountData accountData = new AccountData();
    private List accountList = accountData.getAccounts();

    public long getChildCount(Account parent) {
        return accountList.stream()
                .filter(account -> Objects.equals(parent, account.getParent()))
                .count();
    }

    public Boolean hasChildren(Account parent) {

        return accountList.stream().anyMatch(
                account -> Objects.equals(parent, account.getParent()));
    }

    public List fetchChildren(Account parent) {

        return accountList.stream()
                .filter(account -> Objects.equals(parent, account.getParent()))
                .collect(Collectors.toList());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy