Java源码示例:com.helger.commons.collection.impl.CommonsLinkedHashSet

示例1
@Nullable
@ReturnsMutableCopy
public static ICommonsOrderedSet <Character> getAllInvalidXMLTextChars (@Nonnull final EXMLSerializeVersion eXMLVersion,
                                                                        @Nullable final char [] aChars,
                                                                        @Nonnegative final int nOfs,
                                                                        @Nonnegative final int nLen)
{
  if (aChars == null || nLen <= 0)
    return null;

  final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> ();
  for (int i = 0; i < nLen; ++i)
  {
    final char c = aChars[nOfs + i];
    if (isInvalidXMLTextChar (eXMLVersion, c))
      aRes.add (Character.valueOf (c));
  }
  return aRes;
}
 
示例2
@Nullable
@ReturnsMutableCopy
public static ICommonsOrderedSet <Character> getAllInvalidXMLCDATAChars (@Nonnull final EXMLSerializeVersion eXMLVersion,
                                                                         @Nullable final char [] aChars,
                                                                         @Nonnegative final int nOfs,
                                                                         @Nonnegative final int nLen)
{
  if (aChars == null || nLen <= 0)
    return null;

  final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> ();
  for (int i = 0; i < nLen; ++i)
  {
    final char c = aChars[nOfs + i];
    if (isInvalidXMLCDATAChar (eXMLVersion, c))
      aRes.add (Character.valueOf (c));
  }
  return aRes;
}
 
示例3
@Nullable
@ReturnsMutableCopy
public static ICommonsOrderedSet <Character> getAllInvalidXMLAttributeValueChars (@Nonnull final EXMLSerializeVersion eXMLVersion,
                                                                                  @Nullable final char [] aChars,
                                                                                  @Nonnegative final int nOfs,
                                                                                  @Nonnegative final int nLen)
{
  if (aChars == null || nLen <= 0)
    return null;

  final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> ();
  for (int i = 0; i < nLen; ++i)
  {
    final char c = aChars[nOfs + i];
    if (isInvalidXMLAttributeValueChar (eXMLVersion, c))
      aRes.add (Character.valueOf (c));
  }
  return aRes;
}
 
示例4
/**
 * Get a set of all attribute values with the same name.
 *
 * @param aKey
 *        The key to check. May be <code>null</code>.
 * @param aDefault
 *        The default value to be returned, if no such attribute is present.
 * @return <code>aDefault</code> if no such attribute value exists
 */
@Nullable
default ICommonsOrderedSet <String> getAsStringSet (@Nullable final KEYTYPE aKey,
                                                    @Nullable final ICommonsOrderedSet <String> aDefault)
{
  final Object aValue = getValue (aKey);
  if (aValue != null)
  {
    if (aValue instanceof String [])
    {
      // multiple values passed in the request
      return new CommonsLinkedHashSet <> ((String []) aValue);
    }
    if (aValue instanceof String)
    {
      // single value passed in the request
      return new CommonsLinkedHashSet <> ((String) aValue);
    }
  }
  return aDefault;
}
 
示例5
/**
 * Get a set of all attribute values with the same name.
 *
 * @param nIndex
 *        The index to be accessed. Should be &ge; 0.
 * @param aDefault
 *        The default value to be returned, if no such attribute is present.
 * @return <code>aDefault</code> if no such attribute value exists
 */
@Nullable
default ICommonsOrderedSet <String> getAsStringSet (@Nonnegative final int nIndex,
                                                    @Nullable final ICommonsOrderedSet <String> aDefault)
{
  final Object aValue = getValue (nIndex);
  if (aValue != null)
  {
    if (aValue instanceof String [])
    {
      // multiple values passed in the request
      return new CommonsLinkedHashSet <> ((String []) aValue);
    }
    if (aValue instanceof String)
    {
      // single value passed in the request
      return new CommonsLinkedHashSet <> ((String) aValue);
    }
  }
  return aDefault;
}
 
示例6
@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")));
}
 
示例7
@Test
public void testWithStringArray ()
{
  final AttributeContainerAny <String> aCont = new AttributeContainerAny <> ();
  aCont.putIn ("a", new String [] { "1", "20" });
  // Expected to use the first
  assertEquals ("1", aCont.getAsString ("a"));
  assertEquals (1, aCont.getAsInt ("a"));
  assertEquals (1, aCont.getAsLong ("a"));
  assertEquals (1, aCont.getAsShort ("a"));
  assertEquals (1, aCont.getAsByte ("a"));
  CommonsAssert.assertEquals (1, aCont.getAsDouble ("a"));
  CommonsAssert.assertEquals (1, aCont.getAsFloat ("a"));
  assertEquals (BigDecimal.ONE, aCont.getAsBigDecimal ("a"));
  assertEquals (BigInteger.ONE, aCont.getAsBigInteger ("a"));
  assertEquals (new CommonsArrayList <> ("1", "20"), aCont.getAsStringList ("a"));
  assertEquals (new CommonsLinkedHashSet <> ("1", "20"), aCont.getAsStringSet ("a"));
}
 
示例8
@Override
@Nonnull
@ReturnsMutableCopy
protected final CommonsLinkedHashSet <VALUETYPE> createNewCollection ()
{
  return new CommonsLinkedHashSet <> ();
}
 
示例9
@Override
@Nonnull
@ReturnsMutableCopy
protected final CommonsLinkedHashSet <VALUETYPE> createNewCollection ()
{
  return new CommonsLinkedHashSet <> ();
}
 
示例10
@Override
@Nonnull
@ReturnsMutableCopy
protected final CommonsLinkedHashSet <VALUETYPE> createNewCollection ()
{
  return new CommonsLinkedHashSet <> ();
}
 
示例11
@Override
@Nonnull
@ReturnsMutableCopy
protected final CommonsLinkedHashSet <VALUETYPE> createNewCollection ()
{
  return new CommonsLinkedHashSet <> ();
}
 
示例12
@Override
@Nonnull
@ReturnsMutableCopy
protected final CommonsLinkedHashSet <VALUETYPE> createNewCollection ()
{
  return new CommonsLinkedHashSet <> ();
}
 
示例13
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllRelationIDs ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  for (final IMutableGraphNode aNode : m_aNodes.values ())
    ret.addAll (aNode.getAllRelationIDs ());
  return ret;
}
 
示例14
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <IMutableDirectedGraphRelation> getAllRelations ()
{
  final ICommonsOrderedSet <IMutableDirectedGraphRelation> ret = new CommonsLinkedHashSet <> ();
  if (m_aIncoming != null)
    ret.addAll (m_aIncoming.values ());
  if (m_aOutgoing != null)
    ret.addAll (m_aOutgoing.values ());
  return ret;
}
 
示例15
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllRelationIDs ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  if (m_aIncoming != null)
    ret.addAll (m_aIncoming.keySet ());
  if (m_aOutgoing != null)
    ret.addAll (m_aOutgoing.keySet ());
  return ret;
}
 
示例16
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <IMutableGraphRelation> getAllRelations ()
{
  final ICommonsOrderedSet <IMutableGraphRelation> ret = new CommonsLinkedHashSet <> ();
  if (m_aRelations != null)
    ret.addAll (m_aRelations.values ());
  return ret;
}
 
示例17
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllRelationIDs ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  if (m_aRelations != null)
    ret.addAll (m_aRelations.keySet ());
  return ret;
}
 
示例18
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <IMutableGraphNode> getAllRelatedNodes ()
{
  final ICommonsOrderedSet <IMutableGraphNode> ret = new CommonsLinkedHashSet <> ();
  if (m_aRelations != null)
    for (final IMutableGraphRelation aRelation : m_aRelations.values ())
    {
      ret.add (aRelation.getNode1 ());
      ret.add (aRelation.getNode2 ());
    }
  return ret;
}
 
示例19
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllRelatedNodeIDs ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  if (m_aRelations != null)
    for (final IMutableGraphRelation aRelation : m_aRelations.values ())
    {
      ret.add (aRelation.getNode1ID ());
      ret.add (aRelation.getNode2ID ());
    }
  return ret;
}
 
示例20
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllRelationIDs ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  for (final IMutableDirectedGraphNode aNode : m_aNodes.values ())
    ret.addAll (aNode.getAllRelationIDs ());
  return ret;
}
 
示例21
@Nullable
@ReturnsMutableCopy
public static ICommonsOrderedSet <Character> getAllInvalidXMLNameChars (@Nonnull final EXMLSerializeVersion eXMLVersion,
                                                                        @Nullable final char [] aChars,
                                                                        @Nonnegative final int nOfs,
                                                                        @Nonnegative final int nLen)
{
  if (aChars == null || nLen <= 0)
    return null;

  final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> ();
  int nIndex = 0;
  for (int i = 0; i < nLen; ++i)
  {
    final char c = aChars[nOfs + i];
    if (nIndex == 0)
    {
      if (isInvalidXMLNameStartChar (eXMLVersion, c))
        aRes.add (Character.valueOf (c));
    }
    else
    {
      if (isInvalidXMLNameChar (eXMLVersion, c))
        aRes.add (Character.valueOf (c));
    }
    ++nIndex;
  }
  return aRes;
}
 
示例22
/**
 * @return A non-<code>null</code> set with all mime types known to this
 *         instance.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <IMimeType> getAllMimeTypes ()
{
  final ICommonsOrderedSet <IMimeType> ret = new CommonsLinkedHashSet <> ();
  m_aRWLock.readLocked ( () -> m_aList.forEach (i -> ret.addAll (i.getAllMimeTypes ())));
  return ret;
}
 
示例23
/**
 * @return A non-<code>null</code> set with all mime types known to this
 *         instance.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllMimeTypeStrings ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  m_aRWLock.readLocked ( () -> m_aList.forEach (i -> ret.addAll (i.getAllMimeTypeStrings ())));
  return ret;
}
 
示例24
/**
 * Get all mime types that are associated to the specified filename extension.
 *
 * @param sExtension
 *        The filename extension to search. May not be <code>null</code>.
 * @return Never <code>null</code> but maybe empty set if no mime type is
 *         associated with the passed extension.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <IMimeType> getAllMimeTypesForExtension (@Nonnull final String sExtension)
{
  ValueEnforcer.notNull (sExtension, "Extension");

  final ICommonsOrderedSet <IMimeType> ret = new CommonsLinkedHashSet <> ();
  final ICommonsList <MimeTypeInfo> aInfos = getAllInfosOfExtension (sExtension);
  if (aInfos != null)
    for (final MimeTypeInfo aInfo : aInfos)
      ret.addAll (aInfo.getAllMimeTypes ());
  return ret;
}
 
示例25
/**
 * Get all mime types that are associated to the specified filename extension.
 *
 * @param sExtension
 *        The filename extension to search. May not be <code>null</code>.
 * @return Never <code>null</code> but maybe empty set if no mime type is
 *         associated with the passed extension.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllMimeTypeStringsForExtension (@Nonnull final String sExtension)
{
  ValueEnforcer.notNull (sExtension, "Extension");

  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  final ICommonsList <MimeTypeInfo> aInfos = getAllInfosOfExtension (sExtension);
  if (aInfos != null)
    for (final MimeTypeInfo aInfo : aInfos)
      ret.addAll (aInfo.getAllMimeTypeStrings ());
  return ret;
}
 
示例26
/**
 * Get all extensions associated to the specified mime type
 *
 * @param aMimeType
 *        The mime type to search. May be <code>null</code>.
 * @return Never <code>null</code> but empty set if no extensions are present.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllExtensionsOfMimeType (@Nullable final IMimeType aMimeType)
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  final ICommonsList <MimeTypeInfo> aInfos = getAllInfosOfMimeType (aMimeType);
  if (aInfos != null)
    for (final MimeTypeInfo aInfo : aInfos)
      ret.addAll (aInfo.getAllExtensions ());
  return ret;
}
 
示例27
/**
 * Get all globs (=filename patterns) associated to the specified mime type
 *
 * @param aMimeType
 *        The mime type to search. May be <code>null</code>.
 * @return Never <code>null</code> but empty set if no globs are present.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllGlobsOfMimeType (@Nullable final IMimeType aMimeType)
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  final ICommonsList <MimeTypeInfo> aInfos = getAllInfosOfMimeType (aMimeType);
  if (aInfos != null)
    for (final MimeTypeInfo aInfo : aInfos)
      ret.addAll (aInfo.getAllGlobs ());
  return ret;
}
 
示例28
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllExtensions ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  ret.addAllMapped (m_aExtensions, ExtensionWithSource::getExtension);
  return ret;
}
 
示例29
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <String> getAllParamNames ()
{
  final ICommonsOrderedSet <String> ret = new CommonsLinkedHashSet <> ();
  forEach (aParam -> ret.add (aParam.getName ()));
  return ret;
}
 
示例30
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet <Class <?>> getAsSet ()
{
  // Use a linked hash set, to maintain the order
  final ICommonsOrderedSet <Class <?>> ret = new CommonsLinkedHashSet <> (m_aList.size ());
  for (final WeakReference <Class <?>> aRef : m_aList)
  {
    final Class <?> aClass = aRef.get ();
    if (aClass != null)
      ret.add (aClass);
  }
  return ret;
}