Java Code Examples for com.helger.commons.string.StringHelper#getImplodedMapped()

The following examples show how to use com.helger.commons.string.StringHelper#getImplodedMapped() . 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: JAXBContextCacheKey.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Cache key using package and optional class loader
 *
 * @param aClasses
 *        Classes to be used. May not be <code>null</code>.
 * @param aProperties
 *        JAXB context properties. May be <code>null</code>.
 * @since v9.4.2
 */
public JAXBContextCacheKey (@Nonnull final ICommonsList <Class <?>> aClasses,
                            @Nullable final Map <String, ?> aProperties)
{
  ValueEnforcer.notEmptyNoNullValue (aClasses, "Classes");
  m_aPackage = null;
  m_aClassLoader = null;
  m_aClasses = new CommonsArrayList <> (aClasses, WeakReference::new);
  m_aProperties = new CommonsHashMap <> (aProperties);
  m_sEqualsHashCodeKey = StringHelper.getImplodedMapped (':', aClasses, Class::getName);
}
 
Example 2
Source File: JAXBContextCacheKey.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
private JAXBContext _createFromClassesAndProperties (final boolean bSilentMode)
{
  final ICommonsList <Class <?>> aClasses = _getAllClasses ();

  // E.g. an internal class - try anyway!
  if (!bSilentMode)
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Creating JAXB context for classes " +
                   StringHelper.getImplodedMapped (", ", aClasses, x -> '\'' + x.getName () + '\'') +
                   (m_aProperties.isEmpty () ? "" : " with properties " + m_aProperties.keySet ()));

  try
  {
    // Using the version with a ClassLoader would require an
    // ObjectFactory.class or an jaxb.index file in the same package!
    final Class <?> [] aClassArray = aClasses.toArray (ArrayHelper.EMPTY_CLASS_ARRAY);
    return JAXBContext.newInstance (aClassArray, m_aProperties);
  }
  catch (final JAXBException ex)
  {
    final String sMsg = "Failed to create JAXB context for classes " +
                        StringHelper.getImplodedMapped (", ", aClasses, x -> '\'' + x.getName () + '\'') +
                        (m_aProperties.isEmpty () ? "" : " with properties " + m_aProperties.keySet ());
    LOGGER.error (sMsg + ": " + ex.getMessage ());
    throw new IllegalArgumentException (sMsg, ex);
  }
}
 
Example 3
Source File: CSSMediaList.java    From ph-css with Apache License 2.0 5 votes vote down vote up
@Nonnull
public String getMediaString (@Nonnull final String sSeparator)
{
  ValueEnforcer.notNull (sSeparator, "Separator");

  if (m_aMedia.isEmpty ())
    return "";

  return StringHelper.getImplodedMapped (sSeparator, m_aMedia, ECSSMedium::getName);
}
 
Example 4
Source File: CSSExpressionMemberMathProduct.java    From ph-css with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Nonempty
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
  aSettings.checkVersionRequirements (this);
  return StringHelper.getImplodedMapped (m_aMembers, x -> x.getAsCSSString (aSettings, nIndentLevel));
}
 
Example 5
Source File: MainFindOccurrances.java    From ph-ubl with Apache License 2.0 5 votes vote down vote up
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 6
Source File: CredentialValidationResultList.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nullable
public String getDisplayText (@Nonnull final Locale aDisplayLocale)
{
  return StringHelper.getImplodedMapped ('\n', m_aResults, x -> x.getDisplayText (aDisplayLocale));
}
 
Example 7
Source File: CmdLineParser.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static String _getDisplayName (@Nonnull final OptionGroup aOptionGroup)
{
  return "[" + StringHelper.getImplodedMapped (" | ", aOptionGroup, CmdLineParser::_getDisplayName) + "]";
}
 
Example 8
Source File: CSSValueMultiValue.java    From ph-css with Apache License 2.0 4 votes vote down vote up
@Nonnull
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
  return StringHelper.getImplodedMapped (m_aValues, x -> x.getAsCSSString (aSettings, nIndentLevel));
}
 
Example 9
Source File: CSSValueMultiProperty.java    From ph-css with Apache License 2.0 4 votes vote down vote up
@Nonnull
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
  return StringHelper.getImplodedMapped (m_aValues, x -> x.getAsCSSString (aSettings, nIndentLevel));
}
 
Example 10
Source File: CSSValueList.java    From ph-css with Apache License 2.0 4 votes vote down vote up
@Nonnull
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
  return StringHelper.getImplodedMapped (m_aValues, x -> x.getAsCSSString (aSettings, nIndentLevel));
}
 
Example 11
Source File: CSSSelector.java    From ph-css with Apache License 2.0 4 votes vote down vote up
@Nonnull
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
  return StringHelper.getImplodedMapped (m_aMembers, x -> x.getAsCSSString (aSettings, nIndentLevel));
}