Tabnine Logo
SInstance.findNearest
Code IndexAdd Tabnine to your IDE (free)

How to use
findNearest
method
in
org.opensingular.form.SInstance

Best Java code snippets using org.opensingular.form.SInstance.findNearest (Showing top 12 results out of 315)

origin: org.opensingular/singular-form-core

/**
 * Do the same search as in {@link this#findNearest(SType)} but return {@link SInstance#getValue} instead of the SInstance
 * @param targetType
 * @param <V>
 * @return
 */
@SuppressWarnings("unchecked")
public <V> Optional<V> findNearestValue(SType<?> targetType) {
  return (Optional<V>) findNearest(targetType).map(SInstance::getValueWithDefault);
}
origin: org.opensingular/singular-form-core

private static SInstance getInstance(SInstance instance, SType target) {
  return (SInstance) instance.findNearest(target).orElse(null);
}
origin: org.opensingular/form-core

private static SInstance getInstance(SInstance instancia, SType target) {
  return (SInstance) instancia.findNearest(target).orElse(null);
}
origin: org.opensingular/singular-form-core

public static <T extends SInstance> Predicate<SInstance> atLeastOneFilled(int quantity, SType<T>... types) {
  return i -> {
    int count = 0;
    for (SType<T> sType : types) {
      if (!i.findNearest(sType).filter(SInstance::isEmptyOfData).isPresent()) {
        count++;
      }
    }
    return count < quantity;
  };
}
origin: org.opensingular/singular-form-core

public <V> Optional<V> findNearestValue(SType<?> targetType, Class<V> valueClass) {
  return findNearest(targetType).map(it -> valueClass.cast(it.getValueWithDefault(valueClass)));
}
origin: org.opensingular/exemplos-form

  @Override
  List<Integer> getIds(SInstance root) {
    final SIList<SIComposite> formulas = root.findNearest(formulasHomeopaticas).orElse(null);
    final List<Integer>       ids      = new ArrayList<>();
    if (formulas != null) {
      ids.addAll(formulas.stream()
          .flatMap(f -> f.getChildren().stream())
          .map(i -> i.findNearest(idDescricaoDinamizada))
          .filter(Optional::isPresent)
          .map(Optional::get)
          .map(SIInteger::getValue)
          .collect(Collectors.toList()));
    }
    return ids;
  }
}).converter((ValueToSICompositeConverter<FormaFarmaceuticaBasica>) (ins, desc) -> {
origin: org.opensingular/singular-form-core

/**
 * Returns the nearest instance for the given type or throws an Exception if it is not found.
 * This method works exactly as the {@link this#findNearest(SType)}
 *
 * @param targetType
 * @param <A>
 * @return
 */
@Nonnull
public <A extends SInstance> A findNearestOrException(@Nonnull SType<A> targetType) {
  return findNearest(targetType).orElseThrow(() -> new SingularFormException(String.format("O tipo %s não foi encontrado", targetType.getName())));
}
origin: org.opensingular/singular-form-wicket

private <ST extends SType<?>> SInstance resolveTypeFinderInstance(IFunction<T, ST> typeFinder) {
  SInstance instance = getRootSInstanceForGivenSTypeClass();
  ST        subtype  = typeFinder.apply((T) instance.getType());
  return instance.findNearest((SType<SInstance>) subtype).orElse(null);
}
origin: org.opensingular/form-wicket

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);
        }));
  }
}
origin: org.opensingular/exemplos-form

.dependsOn(descricaoDinamizada)
.visible(i -> {
  final SIList<SIComposite> list = i.findNearest(formulasHomeopaticas).orElse(null);
  final boolean hasIdDescricaoDinamizadaPresent = list.stream()
      .map(SIComposite::getChildren)
      .flatMap(Collection::stream)
      .map(ins -> ins.findNearest(descricaoDinamizada))
      .filter(ins -> ins.isPresent() && Value.notNull(ins.get(), idDescricaoDinamizada))
      .findFirst().isPresent();
origin: org.opensingular/exemplos-form

.dependsOn(acao)
.visible(itensInstance -> {
  SIString acaoInstance = itensInstance.findNearest(acao).get();
  return acaoInstance.getValue() != null;
});
origin: org.opensingular/singular-form-samples

.dependsOn(acao)
.visible(itensInstance -> {
  SIString acaoInstance = itensInstance.findNearest(acao).get();
  return acaoInstance.getValue() != null;
});
org.opensingular.formSInstancefindNearest

Javadoc

Returns the nearest SInstance for the given type in the form SInstance tree. The search is performed like described in SInstances#findNearest(SInstance,SType)

Popular methods of SInstance

  • getDocument
    Retorna o documento ao qual pertence a instância atual.
  • getType
  • toStringDisplay
  • getId
    Retorna um ID único dentre as instâncias do mesmo documento. Um ID nunca é reutilizado, mesmo se a i
  • getAttributeValue
  • setId
    Apenas para uso nas soluções de persistencia. Não deve ser usado fora dessa situação.
  • clearInstance
    Apaga os valores associados a instância. Se for uma lista ou composto, apaga os valores em profundid
  • getName
  • getParent
  • getValue
  • isEmptyOfData
    Retorna true se a instancia não conter nenhuma informação diferente de null. A pesquisa é feita em
  • asAtr
  • isEmptyOfData,
  • asAtr,
  • asAtrAnnotation,
  • asAtrProvider,
  • attachEventCollector,
  • detachEventCollector,
  • getDictionary,
  • getField,
  • getPathFromRoot

Popular in Java

  • Creating JSON documents from java classes using gson
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • setContentView (Activity)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • JLabel (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now