private Set<SType<?>> getDependentTypesInternal() { if (dependentTypes == null) { return superType == null ? null : superType.getDependentTypes(); } Set<SType<?>> resultSuper = superType.getDependentTypesInternal(); if (resultSuper == null) { return dependentTypes; } Set<SType<?>> sum = new LinkedHashSet<>(resultSuper.size() + dependentTypes.size()); sum.addAll(resultSuper); sum.addAll(dependentTypes); return sum; }
private static Predicate<SInstance> isDependantOf(SInstance i) { return (x) -> i.getType().getDependentTypes().contains(x.getType()); }
private Set<SType<?>> getDependentTypesInternal() { if (dependentTypes == null) { return superType == null ? null : superType.getDependentTypes(); } Set<SType<?>> resultSuper = superType.getDependentTypesInternal(); if (resultSuper == null) { return dependentTypes; } Set<SType<?>> sum = new LinkedHashSet<>(resultSuper.size() + dependentTypes.size()); sum.addAll(resultSuper); sum.addAll(dependentTypes); return sum; }
private static Predicate<SInstance> isDependantOf(SInstance i) { return (x) -> i.getType().getDependentTypes().contains(x.getType()); }
/** * Verifica se o tipo atual tem todos os tipos informados como campos dependentes e mais nenhum campo. */ public AssertionsSType dependentsTypesAre(SType<?>... types) { Set<SType<?>> expectedSet = new LinkedHashSet<>(Arrays.asList(types)); Set<SType<?>> currentSet = getTarget().getDependentTypes(); isDependentType(types); for (SType<?> type : types) { if (!currentSet.contains(type)) { throw new AssertionError(errorMsg("A lista de dependente de " + getTarget() + " não contêm " + type)); } } for (SType<?> type : currentSet) { if (!expectedSet.contains(type)) { throw new AssertionError(errorMsg( "O tipo " + type + " foi encontrado como dependente de " + getTarget() + ", mas isso não era esperado")); } } return this; }
private static void validate(Component component, AjaxRequestTarget target, SInstance fieldInstance) { if (!isSkipValidationOnRequest()) { final InstanceValidationContext validationContext; // Validação do valor do componente validationContext = new InstanceValidationContext(); validationContext.validateSingle(fieldInstance); // limpa erros de instancias dependentes, e limpa o valor caso de este não seja válido para o provider for (SType<?> dependentType : fieldInstance.getType().getDependentTypes()) { fieldInstance .findNearest(dependentType) .ifPresent(it -> { it.getDocument().clearValidationErrors(it.getId()); //Executa validações que dependem do valor preenchido if (!it.isEmptyOfData()) { validationContext.validateSingle(it); } }); } WicketBuildContext .findNearest(component) .flatMap(ctx -> Optional.of(ctx.getRootContext())) .flatMap(ctx -> Optional.of(Stream.builder().add(ctx.getRootContainer()).add(ctx.getExternalContainer()).build())) .ifPresent(containers -> containers.forEach(container -> { updateValidationFeedbackOnDescendants(target, (MarkupContainer) container); })); } }