@Encoding.Naming(value = "setIterable*") @Encoding.Init void setIterable( final Iterable<T> elements) { this.set = HashSet.ofAll(elements); }
@Encoding.Naming(standard = Encoding.StandardNaming.ADD) @Encoding.Init void add( final T element) { this.set = this.set.add(element); }
@Encoding.Naming(standard = Encoding.StandardNaming.ADD_ALL) @Encoding.Init void addAll( final Iterable<T> element) { this.set = this.set.addAll(element); }
/** * sort components re. their natural order (begin from the end, i.e., component without output components) * * @param components original components set * @return */ private static javaslang.collection.List<Component> sortComponents(final Set<Component> components) { final Optional<Component> optionalLastComponent = components.stream() .filter(component -> { final Set<Component> outputComponents = component.getOutputComponents(); return outputComponents == null || outputComponents.isEmpty(); }) .findFirst(); if (!optionalLastComponent.isPresent()) { return javaslang.collection.List.ofAll(components); } final Component lastComponent = optionalLastComponent.get(); final javaslang.collection.List<Component> lastComponentList = javaslang.collection.List.of(lastComponent); final javaslang.collection.Map<String, Component> componentMap = javaslang.collection.HashSet.ofAll(components) .toMap(component -> Tuple.of(component.getUuid(), component)); final javaslang.collection.List<Component> emptyComponentList = javaslang.collection.List.empty(); return addComponents(lastComponentList, componentMap, emptyComponentList); }
@Encoding.Naming(value = "setIterable*") @Encoding.Init void setIterable( final Iterable<T> elements) { this.set = HashSet.ofAll(elements); }