class ShouldOnlyHaveElementsOfTypes extends BasicErrorMessageFactory {

  /**
   * Creates a new <code>{@link ShouldOnlyHaveElementsOfTypes}</code>.
   * 
   * @param actual the object value in the failed assertion.
   * @param types the expected classes and interfaces.
   * @param mismatches elements that are not an instance of one of the given types.
   * @return the created {@code ErrorMessageFactory}.
   */
  public static ShouldOnlyHaveElementsOfTypes shouldOnlyHaveElementsOfTypes(Object actual, Class<?>[] types,
                                                                            Iterable<?> mismatches) {
    return new ShouldOnlyHaveElementsOfTypes(actual, types, mismatches);
  }

  private ShouldOnlyHaveElementsOfTypes(Object actual, Class<?>[] types, Iterable<?> nonMatchingElements) {
    super("%n" +
          "Expecting actual:%n" +
          "  %s%n" +
          "to only have instances of:%n" +
          "  %s%n" +
          "but these elements are not:%n" +
          "  [" + resolveClassNames(nonMatchingElements) + "]",
          actual, types);
  }

  private static String resolveClassNames(Iterable<?> elements) {<FILL_FUNCTION_BODY>}

}

    StringBuilder builder = new StringBuilder();

    for (Object element : elements) {
      if (builder.length() > 0) {
        builder.append(", ");
      }

      String formatted = CONFIGURATION_PROVIDER.representation().toStringOf(element);
      builder.append(formatted);

      if (element != null && !formatted.contains(element.getClass().getName())) {
        builder.append(" (").append(element.getClass().getName()).append(")");
      }
    }

    return builder.toString();
  
<methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables>protected final non-sealed java.lang.Object[] arguments,protected final non-sealed java.lang.String format,org.assertj.core.error.MessageFormatter formatter