// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java
// public final class SmtpResponses {
//   private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls();
// 
//   private SmtpResponses() {
//     throw new AssertionError("Cannot create static utility class");
//   }
// 
//   public static String toString(SmtpResponse response) {
//     if (response.details().size() == 0) {
//       return Integer.toString(response.code());
//     } else {
//       return response.code() + " " + SPACE_JOINER.join(response.details());
//     }
//   }
// 
//   public static List<String> getLines(SmtpResponse response) {
//     if (response.details().size() == 0) {
//       return ImmutableList.of(Integer.toString(response.code()));
//     }
// 
//     String[] lines = new String[response.details().size()];
// 
//     for (int i = 0; i < response.details().size(); i++) {
//       StringBuilder responseBuilder = new StringBuilder();
// 
//       responseBuilder.append(response.code());
// 
//       if (i == response.details().size() - 1) {
//         responseBuilder.append(" ");
//       } else {
//         responseBuilder.append("-");
//       }
// 
//       responseBuilder.append(response.details().get(i));
// 
//       lines[i] = responseBuilder.toString();
//     }
// 
//     return ImmutableList.copyOf(lines);
//   }
// 
//   public static boolean isTransientError(SmtpResponse response) {
//     return response.code() >= 400 && response.code() < 500;
//   }
// 
//   public static boolean isPermanentError(SmtpResponse response) {
//     return response.code() >= 500;
//   }
// 
//   public static boolean isError(SmtpResponse response) {
//     return isTransientError(response) || isPermanentError(response);
//   }
// }


import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import com.hubspot.smtp.utils.SmtpResponses;
import io.netty.handler.codec.smtp.SmtpResponse;
package com.hubspot.smtp.client;




/**
 * Wraps the session and the responses to one or more SMTP commands.
 *
 * <p>This class is thread-safe.
 */
public class SmtpClientResponse  {
  private final SmtpSession session;
  private final List<SmtpResponse> responses;

  public SmtpClientResponse(SmtpSession session, SmtpResponse response) {
    this.responses = ImmutableList.of(response);
    this.session = session;
  }

  public SmtpClientResponse(SmtpSession session, Iterable<SmtpResponse> responses) {
    this.responses = ImmutableList.copyOf(responses);
    this.session = session;
  }

  public SmtpClientResponse(SmtpSession session, List<SmtpResponse> responses) {
    this.responses = ImmutableList.copyOf(responses);
    this.session = session;
  }

  /**
   * Gets the {@link SmtpSession} that received these responses.
   */
  public SmtpSession getSession() {
    return session;
  }

  /**
   * Gets whether any of the contained {@link SmtpResponse}s have a {@code code >= 400}.
   */
  public boolean containsError() {
    return responses.stream().anyMatch(SmtpResponses::isError);
  }

  /**
   * Gets the {@link SmtpResponse}s.
   */
  public List<SmtpResponse> getResponses() {
    return responses;
  }

  @Override
  public String toString() {
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java
// public final class SmtpResponses {
//   private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls();
// 
//   private SmtpResponses() {
//     throw new AssertionError("Cannot create static utility class");
//   }
// 
//   public static String toString(SmtpResponse response) {
//     if (response.details().size() == 0) {
//       return Integer.toString(response.code());
//     } else {
//       return response.code() + " " + SPACE_JOINER.join(response.details());
//     }
//   }
// 
//   public static List<String> getLines(SmtpResponse response) {
//     if (response.details().size() == 0) {
//       return ImmutableList.of(Integer.toString(response.code()));
//     }
// 
//     String[] lines = new String[response.details().size()];
// 
//     for (int i = 0; i < response.details().size(); i++) {
//       StringBuilder responseBuilder = new StringBuilder();
// 
//       responseBuilder.append(response.code());
// 
//       if (i == response.details().size() - 1) {
//         responseBuilder.append(" ");
//       } else {
//         responseBuilder.append("-");
//       }
// 
//       responseBuilder.append(response.details().get(i));
// 
//       lines[i] = responseBuilder.toString();
//     }
// 
//     return ImmutableList.copyOf(lines);
//   }
// 
//   public static boolean isTransientError(SmtpResponse response) {
//     return response.code() >= 400 && response.code() < 500;
//   }
// 
//   public static boolean isPermanentError(SmtpResponse response) {
//     return response.code() >= 500;
//   }
// 
//   public static boolean isError(SmtpResponse response) {
//     return isTransientError(response) || isPermanentError(response);
//   }
// }


// Path: src/main/java/com/hubspot/smtp/client/SmtpClientResponse.java
import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import com.hubspot.smtp.utils.SmtpResponses;
import io.netty.handler.codec.smtp.SmtpResponse;

package com.hubspot.smtp.client;




/**
 * Wraps the session and the responses to one or more SMTP commands.
 *
 * <p>This class is thread-safe.
 */
public class SmtpClientResponse  {
  private final SmtpSession session;
  private final List<SmtpResponse> responses;

  public SmtpClientResponse(SmtpSession session, SmtpResponse response) {
    this.responses = ImmutableList.of(response);
    this.session = session;
  }

  public SmtpClientResponse(SmtpSession session, Iterable<SmtpResponse> responses) {
    this.responses = ImmutableList.copyOf(responses);
    this.session = session;
  }

  public SmtpClientResponse(SmtpSession session, List<SmtpResponse> responses) {
    this.responses = ImmutableList.copyOf(responses);
    this.session = session;
  }

  /**
   * Gets the {@link SmtpSession} that received these responses.
   */
  public SmtpSession getSession() {
    return session;
  }

  /**
   * Gets whether any of the contained {@link SmtpResponse}s have a {@code code >= 400}.
   */
  public boolean containsError() {
    return responses.stream().anyMatch(SmtpResponses::isError);
  }

  /**
   * Gets the {@link SmtpResponse}s.
   */
  public List<SmtpResponse> getResponses() {
    return responses;
  }

  @Override
  public String toString() {
    return responses.stream().map(SmtpResponses::toString).collect(Collectors.joining("; "));