private static boolean isOrphan(SInstance i) { return !(i instanceof SIComposite) && i.getParent() == null; }
private static boolean isOrphan(SInstance i) { return !(i instanceof SIComposite) && i.getParent() == null; }
@Override public Optional<SInstanceConverter> apply(SInstance inst) { return Optional.ofNullable(inst.getParent()).map(SAttributeEnabled::asAtrProvider).map(AtrProvider::getConverter); } }
@Nonnull public static <A extends SType<?>> Optional<SInstance> findAncestor(SInstance node, Class<A> ancestorType) { for (SInstance parent = node.getParent(); parent != null; parent = parent.getParent()) { if (parent.getType().getClass().equals(ancestorType)) { return Optional.of(parent); } } return Optional.empty(); }
@Nonnull public static <A extends SType<?>> Optional<SInstance> findAncestor(SInstance node, Class<A> ancestorType) { for (SInstance parent = node.getParent(); parent != null; parent = parent.getParent()) { if (parent.getType().getClass().equals(ancestorType)) { return Optional.of(parent); } } return Optional.empty(); }
/** * Busca por um ancestral de <code>node</code> do tipo especificado. * * @param node instância inicial da busca * @param ancestorType tipo do ancestral * @return Optional da instância do ancestral do tipo especificado */ @SuppressWarnings("unchecked") public static <A extends SInstance & ICompositeInstance> Optional<A> findAncestor(SInstance node, SType<A> ancestorType) { for (SInstance parent = node.getParent(); parent != null; parent = parent.getParent()) { if (parent.isTypeOf(ancestorType)) { return Optional.of((A) parent); } } return Optional.empty(); }
/** * Busca por um ancestral de <code>node</code> do tipo especificado. * @param node instância inicial da busca * @param ancestorType tipo do ancestral * @return Optional da instância do ancestral do tipo especificado */ @SuppressWarnings("unchecked") public static <A extends SInstance & ICompositeInstance> Optional<A> findAncestor(SInstance node, SType<A> ancestorType) { for (SInstance parent = node.getParent(); parent != null; parent = parent.getParent()) { if (parent.getType().isTypeOf(ancestorType)) { return Optional.of((A) parent); } } return Optional.empty(); }
/** * Criar um XPath para a instância no formato "order[@id=1]/address[@id=4]/street[@id=5]". */ private StringBuilder buildXPath(SInstance instance, StringBuilder path) { if (instance.getParent() != null) { buildXPath(instance.getParent(), path); } if (path.length() != 0) { path.append('/'); } path.append(instance.getName()).append("[@id=").append(instance.getId()).append(']'); return path; }
/** * Criar um XPath para a instância no formato "order[@id=1]/address[@id=4]/street[@id=5]". */ private StringBuilder buildXPath(SInstance instance, StringBuilder path) { if (instance.getParent() != null) { buildXPath(instance.getParent(), path); } if (path.length() != 0) { path.append('/'); } path.append(instance.getName()).append("[@id=").append(instance.getId()).append("]"); return path; }
/** * Lista os ancestrais de <code>node</code>. * @param instance instância inicial da busca * @return Lista das instâncias de ancestrais do tipo especificado */ public static List<SInstance> listAscendants(SInstance instance, SType<?> limitInclusive, boolean selfIncluded) { List<SInstance> list = new ArrayList<>(); if (selfIncluded) { list.add(instance); } SInstance node = instance.getParent(); while (node != null && !node.getType().isTypeOf(limitInclusive)) { list.add(node); node = node.getParent(); } return list; }
@SuppressWarnings("unchecked") public static <A extends SInstance> Optional<A> findNearest(SInstance children, SInstance node, Class<? extends SType<A>> targetTypeClass) { Optional<A> desc = (Optional<A>) SInstances.streamDescendants(node, true) .filter(sInstance -> sInstance != children) .filter(sInstance -> targetTypeClass.isAssignableFrom(sInstance.getType().getClass())) .findFirst(); if (desc.isPresent()) { return desc; } else if (node.getParent() != null) { return findNearest(node, node.getParent(), targetTypeClass); } else { return Optional.empty(); } }
private void assertCorrectParentRelation(SInstance target) { for (SInstance child : target.getChildren()) { if (target != child.getParent()) { throw new AssertionError( "Incossitência Interna: A instância '" + child.getPathFull() + "', filho de '" + target.getPathFull() + "', aponta para um outro pai: '" + child.getParent() + "'"); } assertCorrectParentRelation(child); } }
public SelectSInstanceAwareModel.SelectConverterResolver getCustomSelectConverterResolver(){ return si -> Optional.ofNullable(si.getParent().asAtrProvider().getConverter()); }
protected static Optional<SInstance> findAncestor(SInstance instance, SType<?> type) { for (SInstance current = instance; current != null; current = current.getParent()) { if (current.getType().getSuperType() == type || current.getType() == type) { return Optional.of(current); } } return Optional.empty(); }
@Override protected void buildFields(WicketBuildContext ctx, BSGrid grid) { if ((ctx.getCurrentInstance().getParent() == null && !ctx.isNested()) || (ctx.getParent().getView() instanceof SViewTab && !(ctx.getView() instanceof SViewByBlock))) { grid.setCssClass("singular-container"); } super.buildFields(ctx, grid); } }
@Override protected void buildFields(WicketBuildContext ctx, BSGrid grid) { if (((ctx.getCurrentInstance().getParent() == null) && (!ctx.isNested())) || ((ctx.getParent().getView() instanceof SViewTab) && !(ctx.getView() instanceof SViewByBlock))) { grid.setCssClass("singular-container"); } super.buildFields(ctx, grid); } }