javax.annotation.OverridingMethodsMustInvokeSuper#com.helger.commons.collection.CollectionHelper源码实例Demo

下面列出了javax.annotation.OverridingMethodsMustInvokeSuper#com.helger.commons.collection.CollectionHelper 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ph-commons   文件: EqualsHelperTest.java
@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")));
}
 
源代码2 项目: ph-commons   文件: IAggregatorTest.java
@Test
public void testUseFirst ()
{
  final IAggregator <String, String> a1 = CollectionHelper::getFirstElement;
  assertEquals (a1, a1);
  assertNotEquals (a1, null);
  assertNotEquals (a1, "any other");
  assertEquals (a1.hashCode (), a1.hashCode ());
  assertNotEquals (a1.hashCode (), 0);
  assertNotEquals (a1.hashCode (), "any other".hashCode ());
  assertNotNull (a1.toString ());
  final ICommonsList <String> l = new CommonsArrayList <> ("a", null, "b", "", "c");
  assertEquals ("a", a1.apply (l));
  assertNull (a1.apply (new CommonsArrayList <String> ()));
  assertNull (a1.apply ((Collection <String>) null));
}
 
源代码3 项目: ph-commons   文件: IComparatorTest.java
/**
 * Test for constructors using a locale
 */
@Test
public void testLocaleGerman ()
{
  final String S1 = "bbc";
  final String S2 = "abc";
  final String S3 = "äbc";
  final String [] x = new String [] { S1, S2, S3 };

  // default: sort ascending
  ICommonsList <String> l = CollectionHelper.getSorted (x, IComparator.getComparatorCollating (Locale.GERMAN));
  assertArrayEquals (new String [] { S2, S3, S1 }, l.toArray ());

  // sort ascending manually
  l = CollectionHelper.getSorted (x, IComparator.getComparatorCollating (Locale.GERMAN));
  assertArrayEquals (new String [] { S2, S3, S1 }, l.toArray ());

  // sort descending manually
  l = CollectionHelper.getSorted (x, IComparator.getComparatorCollating (Locale.GERMAN).reversed ());
  assertArrayEquals (new String [] { S1, S3, S2 }, l.toArray ());

  // null locale allowed
  IComparator.getComparatorCollating ((Locale) null);
  assertArrayEquals (new String [] { S1, S3, S2 }, l.toArray ());
}
 
源代码4 项目: ph-commons   文件: EqualsHelperTest.java
@Test
public void testMap ()
{
  final StringMap aMap = new StringMap ("a", "b").add ("c", "d");
  assertTrue (EqualsHelper.equalsCollection (aMap, aMap));
  assertTrue (EqualsHelper.equalsCollection (aMap, CollectionHelper.makeUnmodifiable (aMap)));
  assertTrue (EqualsHelper.equalsCollection (aMap, Collections.synchronizedMap (aMap)));
  assertTrue (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "d")));
  assertTrue (EqualsHelper.equalsCollection (new CommonsHashMap <Integer, Integer> (), new CommonsHashMap <Double, Float> ()));

  assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashMap <Integer, Integer> ()));
  assertFalse (EqualsHelper.equalsCollection (new CommonsHashMap <Integer, Integer> (), aMap));
  assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("A", "b").add ("c", "d")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "B").add ("c", "d")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("C", "d")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "D")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "d").add ("e", "f")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsArrayList <> ("a", "b", "c")));
  assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashSet <> ("a", "b", "c")));
  assertFalse (EqualsHelper.equalsCollection (aMap, ArrayHelper.newArray ("a", "b", "c")));
}
 
源代码5 项目: ph-commons   文件: IAggregatorTest.java
@Test
public void testUseLast ()
{
  final IAggregator <String, String> a1 = CollectionHelper::getLastElement;
  assertEquals (a1, a1);
  assertNotEquals (a1, null);
  assertNotEquals (a1, "any other");
  assertEquals (a1.hashCode (), a1.hashCode ());
  assertNotEquals (a1.hashCode (), 0);
  assertNotEquals (a1.hashCode (), "any other".hashCode ());
  assertNotNull (a1.toString ());
  final ICommonsList <String> l = new CommonsArrayList <> ("a", null, "b", "", "c");
  assertEquals ("c", a1.apply (l));
  assertNull (a1.apply (new CommonsArrayList <String> ()));
  assertNull (a1.apply ((Collection <String>) null));
}
 
@Test
public void testChildProvder ()
{
  final DefaultTreeWithGlobalUniqueID <String, String> aTestTree2 = new DefaultTreeWithGlobalUniqueID <> ();

  assertEquals (0, aTestTree2.getChildCount (null));
  assertFalse (aTestTree2.hasChildren (null));
  assertTrue (CollectionHelper.isEmpty (aTestTree2.getAllChildren (null)));

  final DefaultTreeItemWithID <String, String> x12 = aTestTree2.getRootItem ().createChildItem ("x1", "1");
  x12.createChildItem ("x2", "a");
  x12.createChildItem ("x3", "b");
  x12.createChildItem ("x4", "c");

  assertEquals (1, aTestTree2.getChildCount (null));
  assertTrue (aTestTree2.hasChildren (null));
  assertEquals (1, aTestTree2.getAllChildren (null).size ());

  assertEquals (3, aTestTree2.getChildCount (x12));
  assertTrue (aTestTree2.hasChildren (x12));
  assertEquals (3, aTestTree2.getAllChildren (x12).size ());
}
 
源代码7 项目: ph-commons   文件: KeyStoreHelperTest.java
@Test
public void testLoadPeppolTrustStorePilot () throws Exception
{
  // Load trust store
  final KeyStore aTrustStore = KeyStoreHelper.loadKeyStoreDirect (EKeyStoreType.JKS,
                                                                  "keystores/truststore-peppol-pilot.jks",
                                                                  "peppol");
  assertNotNull (aTrustStore);

  // Additionally the STS certificate is contained
  assertEquals (4, CollectionHelper.getSize (aTrustStore.aliases ()));

  // Ensure all name entries are contained
  assertNotNull (aTrustStore.getCertificate (TRUSTSTORE_PILOT_ALIAS_ROOT));
  assertNotNull (aTrustStore.getCertificate (TRUSTSTORE_PILOT_ALIAS_AP));
  assertNotNull (aTrustStore.getCertificate (TRUSTSTORE_PILOT_ALIAS_SMP));

  final X509Certificate aCertAPOld = (X509Certificate) aTrustStore.getCertificate (TRUSTSTORE_PILOT_ALIAS_AP);
  final String sIssuerName = aCertAPOld.getIssuerX500Principal ().getName ();
  assertEquals ("CN=PEPPOL Root TEST CA,OU=FOR TEST PURPOSES ONLY,O=NATIONAL IT AND TELECOM AGENCY,C=DK",
                sIssuerName);
  final String sSubjectName = aCertAPOld.getSubjectX500Principal ().getName ();
  assertEquals ("CN=PEPPOL ACCESS POINT TEST CA,OU=FOR TEST PURPOSES ONLY,O=NATIONAL IT AND TELECOM AGENCY,C=DK",
                sSubjectName);
}
 
源代码8 项目: ph-commons   文件: FilterIteratorTest.java
@Test
public void testIteration5 ()
{
  // filtered elements at the beginning
  final List <String> aList = CollectionHelper.newList (null, null, "s1", "s2", "s3");
  final FilterIterator <String> it = new FilterIterator <> (aList, Objects::nonNull);
  assertNotNull (it);

  assertEquals ("s1", it.next ());
  assertEquals ("s2", it.next ());
  assertEquals ("s3", it.next ());

  CommonsTestHelper.testToStringImplementation (it);

  try
  {
    // can't call next if hasNext failed
    it.next ();
    fail ();
  }
  catch (final NoSuchElementException ex)
  {}
}
 
源代码9 项目: ph-commons   文件: IComparatorTest.java
@Test
public void testCollatingOrder ()
{
  final String S1 = "abc";
  final String S2 = "ABC";
  final String S3 = "ab";
  final String [] x = new String [] { S1, S2, S3 };

  // Explicitly sort ascending
  List <String> l = CollectionHelper.getSorted (x, IComparator.getComparatorCollating (Locale.US));
  assertArrayEquals (new String [] { S3, S1, S2 }, l.toArray ());

  // Explicitly sort descending
  l = CollectionHelper.getSorted (x, IComparator.getComparatorCollating (Locale.US).reversed ());
  assertArrayEquals (new String [] { S2, S1, S3 }, l.toArray ());
}
 
源代码10 项目: ph-ubl   文件: MockUBLTRTestDocuments.java
@Nonnull
@ReturnsMutableCopy
public static List <String> getUBLTRTestDocuments (@Nonnull final EUBLTRDocumentType eType)
{
  List <String> aFiles = null;
  switch (eType)
  {
    case CANCEL_USER_ACCOUNT:
      aFiles = CollectionHelper.makeUnmodifiable (PREFIX +
                                                  "tr_useraccount/5_KULLANICI_SILME.xml",
                                                  PREFIX + "tr_useraccount/9_FATURA_SAKLAMA_KULLANICI_SILME.xml");
      break;
    case PROCESS_USER_ACCOUNT:
      aFiles = CollectionHelper.makeUnmodifiable (PREFIX +
                                                  "tr_useraccount/4_KULLANICI_ACMA.xml",
                                                  PREFIX + "tr_useraccount/8_FATURA_SAKLAMA_KULLANICI_ACMA.xml");
      break;
    default:
      throw new IllegalArgumentException ("No test files available for type " + eType);
  }

  return CollectionHelper.newList (aFiles);
}
 
源代码11 项目: ph-commons   文件: EqualsHelperTest.java
@Test
public void testSet ()
{
  final ICommonsSet <String> aCont = new CommonsHashSet <> ("a", "b", "c");
  assertTrue (EqualsHelper.equalsCollection (aCont, aCont));
  assertTrue (EqualsHelper.equalsCollection (aCont, CollectionHelper.makeUnmodifiable (aCont)));
  assertTrue (EqualsHelper.equalsCollection (aCont, Collections.synchronizedSet (aCont)));
  assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> (aCont)));
  assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsLinkedHashSet <> (aCont)));
  assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsTreeSet <> (aCont)));
  assertTrue (EqualsHelper.equalsCollection (new CommonsHashSet <String> (), new CommonsLinkedHashSet <String> ()));
  assertTrue (EqualsHelper.equalsCollection (new CommonsTreeSet <String> (), new CommonsHashSet <String> ()));

  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <String> ()));
  assertFalse (EqualsHelper.equalsCollection (new CommonsHashSet <String> (), aCont));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsTreeSet <String> ()));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b")));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("A", "b", "c")));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "B", "c")));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b", "C")));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b", "c", "d")));
  assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("a", "b", "c")));
  assertFalse (EqualsHelper.equalsCollection (aCont, ArrayHelper.newArray ("a", "b", "c")));
}
 
源代码12 项目: ph-commons   文件: EqualsHelperTest.java
@Test
public void testEqualsTypeSpecific ()
{
  final StringBuffer aSB1 = new StringBuffer ("Hi");
  CommonsAssert.assertEquals (aSB1, new StringBuffer ("Hi"));
  CommonsAssert.assertNotEquals (aSB1, new StringBuffer ("Hallo"));

  CommonsAssert.assertEquals (aSB1, new StringBuffer ("Hi"));
  CommonsAssert.assertNotEquals (aSB1, new StringBuffer ("Hallo"));
  CommonsAssert.assertNotEquals (aSB1, null);

  CommonsAssert.assertEquals (new CommonsArrayList <> ("a", "b", "c"), new CommonsArrayList <> ("a", "b", "c"));
  CommonsAssert.assertEquals (StackHelper.newStack ("a", "b", "c"), StackHelper.newStack ("a", "b", "c"));
  CommonsAssert.assertEquals (new CommonsArrayList <> ("a", "b", "c").iterator (), new CommonsArrayList <> ("a", "b", "c").iterator ());
  CommonsAssert.assertEquals (IteratorHelper.getEnumeration ("a", "b", "c"), IteratorHelper.getEnumeration ("a", "b", "c"));
  CommonsAssert.assertNotEquals (CollectionHelper.makeUnmodifiable (new CommonsArrayList <> ("a", "b", "c")),
                                 new CommonsArrayList <> ("a", "b", "c"));
}
 
源代码13 项目: ph-schematron   文件: PSSchema.java
@Override
public String toString ()
{
  return new ToStringGenerator (this).appendIfNotNull ("resource", m_aResource)
                                     .appendIfNotNull ("id", m_sID)
                                     .appendIfNotNull ("rich", m_aRich)
                                     .appendIfNotNull ("schemaVersion", m_sSchemaVersion)
                                     .appendIfNotNull ("defaultPhase", m_sDefaultPhase)
                                     .appendIfNotNull ("queryBinding", m_sQueryBinding)
                                     .appendIfNotNull ("title", m_aTitle)
                                     .appendIf ("includes", m_aIncludes, CollectionHelper::isNotEmpty)
                                     .appendIf ("nss", m_aNSs, CollectionHelper::isNotEmpty)
                                     .appendIf ("startps", m_aStartPs, CollectionHelper::isNotEmpty)
                                     .appendIf ("lets", m_aLets, CollectionHelper::isNotEmpty)
                                     .appendIf ("phases", m_aPhases, CollectionHelper::isNotEmpty)
                                     .appendIf ("patterns", m_aPatterns, CollectionHelper::isNotEmpty)
                                     .appendIf ("endps", m_aEndPs, CollectionHelper::isNotEmpty)
                                     .appendIfNotNull ("diagnostics", m_aDiagnostics)
                                     .appendIf ("foreignAttrs", m_aForeignAttrs, CollectionHelper::isNotEmpty)
                                     .appendIf ("foreignElements", m_aForeignElements, CollectionHelper::isNotEmpty)
                                     .getToString ();
}
 
源代码14 项目: ph-commons   文件: QueueHelper.java
@Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> PriorityQueue <ELEMENTTYPE> newQueue (@Nullable final Collection <? extends ELEMENTTYPE> aCont)
{
  if (CollectionHelper.isEmpty (aCont))
    return newQueue (0);
  return new PriorityQueue <> (aCont);
}
 
源代码15 项目: ph-commons   文件: VectorHelper.java
@Nonnull
@ReturnsMutableCopy
public static <SRCTYPE, DSTTYPE> CommonsVector <DSTTYPE> newVectorMapped (@Nullable final Collection <? extends SRCTYPE> aCollection,
                                                                          @Nonnull final Function <? super SRCTYPE, DSTTYPE> aMapper)
{
  if (CollectionHelper.isEmpty (aCollection))
    return newVector (0);
  final CommonsVector <DSTTYPE> ret = newVector (aCollection.size ());
  ret.addAllMapped (aCollection, aMapper);
  return ret;
}
 
源代码16 项目: ph-commons   文件: VectorHelper.java
@Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> CommonsVector <ELEMENTTYPE> newVector (@Nullable final Collection <? extends ELEMENTTYPE> aCont)
{
  if (CollectionHelper.isEmpty (aCont))
    return newVector (0);

  return new CommonsVector <> (aCont);
}
 
源代码17 项目: ph-schematron   文件: PSRule.java
@Override
public String toString ()
{
  return new ToStringGenerator (this).appendIfNotNull ("flag", m_sFlag)
                                     .appendIfNotNull ("rich", m_aRich)
                                     .appendIfNotNull ("linkable", m_aLinkable)
                                     .append ("abstract", m_bAbstract)
                                     .appendIfNotNull ("context", m_sContext)
                                     .appendIfNotNull ("id", m_sID)
                                     .appendIf ("content", m_aContent, CollectionHelper::isNotEmpty)
                                     .appendIf ("foreignAttrs", m_aForeignAttrs, CollectionHelper::isNotEmpty)
                                     .getToString ();
}
 
源代码18 项目: ph-schematron   文件: PSDir.java
@Override
public String toString ()
{
  return new ToStringGenerator (this).appendIfNotNull ("value", m_eValue)
                                     .appendIf ("content", m_aContent, CollectionHelper::isNotEmpty)
                                     .appendIf ("foreignAttrs", m_aForeignAttrs, CollectionHelper::isNotEmpty)
                                     .getToString ();
}
 
源代码19 项目: ph-commons   文件: Utf8ResourceBundleTest.java
@Test
public void testAll ()
{
  assertNotNull (Utf8ResourceBundle.getBundle ("properties/test-utf8"));
  assertNotNull (Utf8ResourceBundle.getBundle ("properties/test-utf8", L_DE));
  final ResourceBundle rb = Utf8ResourceBundle.getBundle ("properties/test-utf8",
                                                          L_DE,
                                                          ClassLoaderHelper.getDefaultClassLoader ());
  assertNotNull (rb);
  assertTrue (rb instanceof Utf8PropertyResourceBundle);
  assertEquals (2, CollectionHelper.newList (rb.getKeys ()).size ());
}
 
源代码20 项目: ph-schematron   文件: PSName.java
@Override
public String toString ()
{
  return new ToStringGenerator (this).appendIfNotNull ("path", m_sPath)
                                     .appendIf ("foreignAttrs", m_aForeignAttrs, CollectionHelper::isNotEmpty)
                                     .getToString ();
}
 
源代码21 项目: ph-commons   文件: XMLHelper.java
@Nonnegative
public static int getDirectChildElementCountNS (@Nullable final Element aParent,
                                                @Nullable final String sNamespaceURI,
                                                @Nonnull @Nonempty final String sLocalName)
{
  return aParent == null ? 0
                         : CollectionHelper.getSize (getChildElementIteratorNS (aParent, sNamespaceURI, sLocalName));
}
 
源代码22 项目: ph-commons   文件: MimeTypeInfo.java
@Override
public String toString ()
{
  return new ToStringGenerator (this).append ("mimeTypes", m_aMimeTypes)
                                     .appendIfNotNull ("comment", m_sComment)
                                     .appendIf ("parentTypes", m_aParentTypes, CollectionHelper::isNotEmpty)
                                     .appendIf ("globs", m_aGlobs, CollectionHelper::isNotEmpty)
                                     .appendIf ("extensions", m_aExtensions, CollectionHelper::isNotEmpty)
                                     .appendIfNotNull ("source", m_sSource)
                                     .getToString ();
}
 
源代码23 项目: ph-commons   文件: MapBasedNamespaceContext.java
@Override
@Nullable
public String getCustomPrefix (@Nonnull final String sNamespaceURI)
{
  final ICommonsSet <String> aAllPrefixes = m_aNS2Prefix.get (sNamespaceURI);
  return CollectionHelper.getFirstElement (aAllPrefixes);
}
 
源代码24 项目: ph-commons   文件: ChildElementIteratorTest.java
@Test
public void testGetRecursiveChildIter ()
{
  final Document doc = XMLFactory.newDocument ();

  // No children present
  assertFalse (new ChildElementIterator (doc).hasNext ());

  // 1 child
  final Element eRoot = (Element) doc.appendChild (doc.createElement ("root"));
  assertEquals (1, CollectionHelper.newList (new ChildElementIterator (doc)).size ());

  // 2 children
  eRoot.appendChild (doc.createElement ("Hallo"));
  eRoot.appendChild (doc.createTextNode (" - "));
  eRoot.appendChild (doc.createElement ("Welt"));
  assertEquals (2, CollectionHelper.newList (new ChildElementIterator (eRoot)).size ());
  assertEquals (1,
                CollectionHelper.newList (new ChildElementIterator (eRoot).withFilter (XMLHelper.filterElementWithTagName ("Hallo")))
                                .size ());

  try
  {
    new ChildElementIterator (doc).remove ();
    fail ();
  }
  catch (final UnsupportedOperationException ex)
  {}
  assertEquals (0, CollectionHelper.getSize (new ChildElementIterator (null)));
}
 
源代码25 项目: ph-commons   文件: JsonWriterTest.java
@Test
public void testComplex ()
{
  final ICommonsList <JsonObject> aObjs = new CommonsArrayList <> ();
  for (final ICommonsMap <String, String> aRow : new CommonsArrayList <> (CollectionHelper.newMap ("key", "value")))
  {
    final JsonObject aObj = new JsonObject ();
    for (final Map.Entry <String, String> aEntry : aRow.entrySet ())
      aObj.add (aEntry.getKey (), aEntry.getValue ());
    aObjs.add (aObj);
  }
  assertEquals ("{\"aa\":[{\"key\":\"value\"}]}", JsonConverter.convertToJson (new JsonObject ().add ("aa", aObjs)).getAsJsonString ());
}
 
源代码26 项目: ph-schematron   文件: PSValueOf.java
@Override
public String toString ()
{
  return new ToStringGenerator (this).appendIfNotNull ("select", m_sSelect)
                                     .appendIf ("foreignAttrs", m_aForeignAttrs, CollectionHelper::isNotEmpty)
                                     .getToString ();
}
 
源代码27 项目: ph-commons   文件: AbstractMapBasedWALDAO.java
@Nonnull
@ReturnsMutableCopy
@IsLocked (ELockType.READ)
public final ICommonsList <INTERFACETYPE> getAll (@Nullable final Predicate <? super INTERFACETYPE> aFilter)
{
  if (aFilter == null)
    return getAll ();

  // Use new CommonsArrayList to get the return type to NOT use "? extends
  // INTERFACETYPE"
  final ICommonsList <INTERFACETYPE> ret = new CommonsArrayList <> ();
  // (Runnable) cast for Java 9
  m_aRWLock.readLocked ((Runnable) () -> CollectionHelper.findAll (m_aMap.values (), aFilter, ret::add));
  return ret;
}
 
源代码28 项目: ph-commons   文件: AbstractMapBasedWALDAO.java
@IsLocked (ELockType.READ)
public final <RETTYPE> void findAllMapped (@Nullable final Predicate <? super INTERFACETYPE> aFilter,
                                           @Nonnull final Function <? super INTERFACETYPE, ? extends RETTYPE> aMapper,
                                           @Nonnull final Consumer <? super RETTYPE> aConsumer)
{
  // (Runnable) cast for Java 9
  m_aRWLock.readLocked ((Runnable) () -> CollectionHelper.findAllMapped (m_aMap.values (),
                                                                         aFilter,
                                                                         aMapper,
                                                                         aConsumer));
}
 
源代码29 项目: ph-commons   文件: IterableIteratorTest.java
@Test
public void testBasic ()
{
  assertSame (IterableIterator.createEmpty (), IterableIterator.createEmpty ());
  IIterableIterator <String> iit = new IterableIterator <> (ArrayHelper.newArray ("Hallo",
                                                                                  "Welt",
                                                                                  "from",
                                                                                  "Copenhagen"));
  assertNotNull (iit);
  assertNotNull (iit.iterator ());
  assertTrue (iit.hasNext ());
  assertEquals ("Hallo", iit.next ());

  iit = new IterableIterator <> (CollectionHelper.newList ("Hallo", "Welt", "from", "Copenhagen"));
  iit.next ();
  iit.remove ();

  assertEquals (3, CollectionHelper.newList (new IterableIterator <> (new String [] { "a", "b", "c" })).size ());
  assertEquals (3,
                CollectionHelper.newList (new IterableIterator <> (CollectionHelper.newList ("a", "b", "c")))
                                .size ());
  assertEquals (3,
                CollectionHelper.newList (new IterableIterator <> (CollectionHelper.newList ("a", "b", "c")
                                                                                   .iterator ()))
                                .size ());
  CommonsTestHelper.testToStringImplementation (iit);

  try
  {
    new IterableIterator <> ((Iterator <String>) null);
    fail ();
  }
  catch (final NullPointerException ex)
  {}
}
 
源代码30 项目: ph-commons   文件: EqualsHelper.java
private static boolean _areChildrenEqual (@Nullable final Object aObj1, @Nullable final Object aObj2)
{
  if (CollectionHelper.isCollectionObject (aObj1) && CollectionHelper.isCollectionObject (aObj2))
  {
    // It's a nested collection!
    // -> indirect recursive call
    return equalsCollection (aObj1, aObj2);
  }

  // Not collections
  return EqualsImplementationRegistry.areEqual (aObj1, aObj2);
}