當前位置: 首頁>>代碼示例>>Java>>正文


Java EHierarchyVisitorReturn類代碼示例

本文整理匯總了Java中com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn的典型用法代碼示例。如果您正苦於以下問題:Java EHierarchyVisitorReturn類的具體用法?Java EHierarchyVisitorReturn怎麽用?Java EHierarchyVisitorReturn使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EHierarchyVisitorReturn類屬於com.helger.commons.hierarchy.visit包,在下文中一共展示了EHierarchyVisitorReturn類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _sort

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
private static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> void _sort (@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree,
                                                                                                               @Nonnull final Comparator <? super ITEMTYPE> aComparator)
{
  ValueEnforcer.notNull (aTree, "Tree");
  ValueEnforcer.notNull (aComparator, "Comparator");

  // sort root manually
  aTree.getRootItem ().reorderChildrenByItems (aComparator);

  // and now start iterating
  TreeVisitor.visitTree (aTree, new DefaultHierarchyVisitorCallback <ITEMTYPE> ()
  {
    @Override
    public EHierarchyVisitorReturn onItemBeforeChildren (@Nullable final ITEMTYPE aTreeItem)
    {
      if (aTreeItem != null)
        aTreeItem.reorderChildrenByItems (aComparator);
      return EHierarchyVisitorReturn.CONTINUE;
    }
  });
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:22,代碼來源:TreeWithIDSorter.java

示例2: _sort

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
private static <DATATYPE, ITEMTYPE extends ITreeItem <DATATYPE, ITEMTYPE>> void _sort (@Nonnull final IBasicTree <? extends DATATYPE, ITEMTYPE> aTree,
                                                                                       @Nonnull final Comparator <? super ITEMTYPE> aComparator)
{
  ValueEnforcer.notNull (aTree, "Tree");
  ValueEnforcer.notNull (aComparator, "Comparator");

  // and now start iterating (including the root item)
  ChildrenProviderHierarchyVisitor.visitFrom (aTree.getRootItem (), new DefaultHierarchyVisitorCallback <ITEMTYPE> ()
  {
    @Override
    @Nonnull
    public EHierarchyVisitorReturn onItemBeforeChildren (@Nullable final ITEMTYPE aTreeItem)
    {
      if (aTreeItem != null)
        aTreeItem.reorderChildItems (aComparator);
      return EHierarchyVisitorReturn.CONTINUE;
    }
  }, true);
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:20,代碼來源:TreeSorter.java

示例3: findAllItemsWithIDRecursive

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
/**
 * Fill all items with the same ID by linearly scanning the tree.
 *
 * @param <KEYTYPE>
 *        tree ID type
 * @param <DATATYPE>
 *        tree data type
 * @param <ITEMTYPE>
 *        tree item type
 * @param aTreeItem
 *        The tree item to search. May not be <code>null</code>.
 * @param aSearchID
 *        The ID to search. May not be <code>null</code>.
 * @return A non-<code>null</code> list with all matching items.
 */
@Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> ICommonsList <ITEMTYPE> findAllItemsWithIDRecursive (@Nonnull final ITEMTYPE aTreeItem,
                                                                                                                                                       @Nullable final KEYTYPE aSearchID)
{
  final ICommonsList <ITEMTYPE> aRetList = new CommonsArrayList <> ();
  TreeVisitor.visitTreeItem (aTreeItem, new DefaultHierarchyVisitorCallback <ITEMTYPE> ()
  {
    @Override
    @Nonnull
    public EHierarchyVisitorReturn onItemBeforeChildren (@Nullable final ITEMTYPE aItem)
    {
      if (aItem != null && aItem.getID ().equals (aSearchID))
        aRetList.add (aItem);
      return EHierarchyVisitorReturn.CONTINUE;
    }
  });
  return aRetList;
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:35,代碼來源:TreeWithIDSearcher.java

示例4: _getXMLAsTreeWithID

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
private static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> void _getXMLAsTreeWithID (@Nonnull final IMicroElement aElement,
                                                                                                                             @Nonnull final Function <? super String, ? extends KEYTYPE> aIDConverter,
                                                                                                                             @Nonnull final IConverterMicroNodeToTreeItem <? extends DATATYPE> aDataConverter,
                                                                                                                             @Nonnull final BasicTreeWithID <KEYTYPE, DATATYPE, ITEMTYPE> aTree)
{
  final String sNamespaceURI = aDataConverter.getNamespaceURI ();
  final NonBlockingStack <ITEMTYPE> aParents = new NonBlockingStack <> ();
  aParents.push (aTree.getRootItem ());
  MicroVisitor.visit (aElement,
                      new ChildrenProviderElementWithName (sNamespaceURI, ELEMENT_ITEM),
                      new DefaultHierarchyVisitorCallback <IMicroElement> ()
                      {
                        @Override
                        @Nonnull
                        public EHierarchyVisitorReturn onItemBeforeChildren (@Nullable final IMicroElement eItem)
                        {
                          if (eItem != null)
                          {
                            final KEYTYPE aTreeItemID = aIDConverter.apply (eItem.getAttributeValue (ATTR_ID));

                            final IMicroElement eData = eItem.getFirstChildElement (sNamespaceURI, ELEMENT_DATA);
                            final DATATYPE aTreeItemValue = aDataConverter.getAsDataValue (eData);

                            final ITEMTYPE aTreeItem = aParents.peek ().createChildItem (aTreeItemID, aTreeItemValue);
                            aParents.push (aTreeItem);
                          }
                          return EHierarchyVisitorReturn.CONTINUE;
                        }

                        @Override
                        @Nonnull
                        public EHierarchyVisitorReturn onItemAfterChildren (@Nullable final IMicroElement aItem)
                        {
                          if (aItem != null)
                            aParents.pop ();
                          return EHierarchyVisitorReturn.CONTINUE;
                        }
                      });
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:40,代碼來源:TreeXMLConverter.java

示例5: onItemBeforeChildren

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
@Override
@Nonnull
public EHierarchyVisitorReturn onItemBeforeChildren (@Nonnull final ITEMTYPE aItem)
{
  final DATATYPE aConvertedValue = m_aConverter.apply (aItem);
  return m_aDataCallback.onItemBeforeChildren (aConvertedValue);
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:8,代碼來源:TreeVisitor.java

示例6: onItemAfterChildren

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
@Override
@Nonnull
public EHierarchyVisitorReturn onItemAfterChildren (@Nonnull final ITEMTYPE aItem)
{
  final DATATYPE aConvertedValue = m_aConverter.apply (aItem);
  return m_aDataCallback.onItemAfterChildren (aConvertedValue);
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:8,代碼來源:TreeVisitor.java

示例7: onItemBeforeChildren

import com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn; //導入依賴的package包/類
@Override
public EHierarchyVisitorReturn onItemBeforeChildren (final DefaultTreeItemWithID <String, Object> aItem)
{
  if (getLevel () < 0)
    throw new IllegalStateException ();
  m_aMI.inc ();
  return EHierarchyVisitorReturn.CONTINUE;
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:9,代碼來源:MockTreeVisitorCallback.java


注:本文中的com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。