List of usage examples for java.util.stream Stream findAny
Optional<T> findAny();
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public static boolean isValidSIADAPUnit(Unit unit, int year) { final AccountabilityType unitRelations = SiadapYearConfiguration.getSiadapYearConfiguration(year) .getUnitRelations();//from ww w . j av a2 s. c o m final java.util.function.Predicate<Accountability> predicate = AccountabilityPredicate .byType(unitRelations); // let's get the unit and check to see if it has a unit relationship // with some other unit or not final Stream<Accountability> children = unit.getChildAccountabilityStream().filter(predicate); final Stream<Accountability> parents = unit.getParentAccountabilityStream().filter(predicate); return (children.findAny().orElse(null) != null || parents.findAny().orElse(null) != null) && new UnitSiadapWrapper(unit, year).isConnectedToTopUnit(unitRelations); }