All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.imap.protocol.command.atoms.BaseImapAtom Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
package com.hubspot.imap.protocol.command.atoms;

import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import java.util.List;

public abstract class BaseImapAtom implements ImapAtom {

  protected static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls();

  protected final List args;

  public BaseImapAtom(String... args) {
    this.args = Lists.newArrayList(args);
  }

  public String imapString() {
    if (hasArgs()) {
      return String.format("%s %s", getPrefix(), SPACE_JOINER.join(getArgs())).trim();
    } else {
      return getPrefix();
    }
  }

  public abstract String getPrefix();

  public List getArgs() {
    return args;
  }

  public boolean hasArgs() {
    return args.size() > 0;
  }

  public String toString() {
    return imapString();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy