com.helger.commons.collection.NonBlockingStack Java Examples
The following examples show how to use
com.helger.commons.collection.NonBlockingStack.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testList () { final ICommonsList <String> aCont = new CommonsArrayList <> ("a", "b", "c"); assertTrue (EqualsHelper.equalsCollection (aCont, aCont)); assertTrue (EqualsHelper.equalsCollection (aCont, CollectionHelper.makeUnmodifiable (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, Collections.synchronizedList (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsLinkedList <> (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsVector <> (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new NonBlockingStack <> (aCont))); assertTrue (EqualsHelper.equalsCollection (new CommonsArrayList <String> (), new CommonsLinkedList <String> ())); assertTrue (EqualsHelper.equalsCollection (new NonBlockingStack <String> (), new CommonsVector <String> ())); assertTrue (EqualsHelper.equalsCollection (new NonBlockingStack <String> (), new Stack <String> ())); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsLinkedList <String> ())); assertFalse (EqualsHelper.equalsCollection (new CommonsLinkedList <String> (), aCont)); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <String> ())); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("a", "b"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("A", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("a", "B", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("a", "b", "C"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("a", "b", "c", "d"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont, ArrayHelper.newArray ("a", "b", "c"))); }
Example #2
Source File: TreeXMLConverter.java From ph-commons with Apache License 2.0 | 5 votes |
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> void fillXMLAsTreeWithID (@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; } }); }
Example #3
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testIterator () { final ICommonsList <String> aCont = new CommonsArrayList <> ("a", "b", "c"); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), aCont.iterator ())); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), CollectionHelper.makeUnmodifiable (aCont).iterator ())); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), Collections.synchronizedList (aCont).iterator ())); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <> (aCont).iterator ())); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsLinkedList <> (aCont).iterator ())); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsVector <> (aCont).iterator ())); assertTrue (EqualsHelper.equalsCollection (aCont.iterator (), new NonBlockingStack <> (aCont).iterator ())); assertTrue (EqualsHelper.equalsCollection (new CommonsArrayList <String> ().iterator (), new CommonsLinkedList <String> ().iterator ())); assertTrue (EqualsHelper.equalsCollection (new NonBlockingStack <String> ().iterator (), new CommonsVector <String> ().iterator ())); assertTrue (EqualsHelper.equalsCollection (new NonBlockingStack <String> ().iterator (), new Stack <String> ().iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsLinkedList <String> ().iterator ())); assertFalse (EqualsHelper.equalsCollection (new CommonsLinkedList <String> ().iterator (), aCont.iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <String> ().iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <> ("a", "b").iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <> ("A", "b", "c").iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <> ("a", "B", "c").iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <> ("a", "b", "C").iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsArrayList <> ("a", "b", "c", "d").iterator ())); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), new CommonsHashSet <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont.iterator (), ArrayHelper.newArray ("a", "b", "c"))); }
Example #4
Source File: MainFindOccurrances.java From ph-ubl with Apache License 2.0 | 5 votes |
private static void _findAllRecursive (@Nonnull final Class <?> aStartClass, @Nonnull final Class <?> aFindClass, @Nonnull @Nonempty final String sXMLName, @Nonnull final NonBlockingStack <StackElement> aStack, @Nonnull final Set <Class <?>> aUniqueClasses) { // Avoid endless loop, if the same type is already part of the stack if (aUniqueClasses.add (aStartClass)) { aStack.push (new StackElement (aStartClass, sXMLName)); // Find per-class data PerClassData aPerClassData = s_aClassCache.get (aStartClass); if (aPerClassData == null) { aPerClassData = _createPerClassData (aStartClass, aFindClass); s_aClassCache.put (aStartClass, aPerClassData); } // Recursive always, even if data is from cache for (final PerClassData.MemberData aMemberData : aPerClassData.m_aMembers) _findAllRecursive (aMemberData.m_aClass, aFindClass, aMemberData.m_sXMLName, aStack, aUniqueClasses); if (aPerClassData.m_aMatches.isNotEmpty ()) { // Found matching members final String sPrefix = StringHelper.getImplodedMapped (aStack, x -> x.m_sXMLName); if (false) for (final Field aField : aPerClassData.m_aMatches) System.out.println (++i + sPrefix + _getXMLName (aField)); } aStack.pop (); aUniqueClasses.remove (aStartClass); } }
Example #5
Source File: MainFindOccurrances.java From ph-ubl with Apache License 2.0 | 5 votes |
public static void findAll (final Class <?> aStartClass, final Class <?> aFindClass) { final NonBlockingStack <StackElement> aStack = new NonBlockingStack<> (); _findAllRecursive (aStartClass, aFindClass, StringHelper.trimEnd (aStartClass.getSimpleName (), "Type"), aStack, new CommonsHashSet<> ()); }
Example #6
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testEnumeration () { final ICommonsList <String> aCont = new CommonsArrayList <> ("a", "b", "c"); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (aCont))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (CollectionHelper.makeUnmodifiable (aCont)))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (Collections.synchronizedList (aCont)))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <> (aCont)))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsLinkedList <> (aCont)))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsVector <> (aCont)))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new NonBlockingStack <> (aCont)))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (new CommonsArrayList <String> ()), IteratorHelper.getEnumeration (new CommonsLinkedList <String> ()))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (new NonBlockingStack <String> ()), IteratorHelper.getEnumeration (new CommonsVector <String> ()))); assertTrue (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (new NonBlockingStack <String> ()), IteratorHelper.getEnumeration (new Stack <String> ()))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsLinkedList <String> ()))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (new CommonsLinkedList <String> ()), IteratorHelper.getEnumeration (aCont))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <String> ()))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <> ("a", "b")))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <> ("A", "b", "c")))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <> ("a", "B", "c")))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <> ("a", "b", "C")))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new CommonsArrayList <> ("a", "b", "c", "d")))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), IteratorHelper.getEnumeration (new StringMap ("a", "b").add ("c", "d")))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), new CommonsHashSet <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (IteratorHelper.getEnumeration (aCont), ArrayHelper.newArray ("a", "b", "c"))); }