package au.com.southsky.jfreesane;

import java.util.List;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

/**
 * Represents a group of options. The SANE backend may group options together. These may be handy
 * if, for example, a JFreeSane user wants to present the options to the user in logical groups.
 *
 * @author James Ring (sjr@jdns.org)
 */
public class OptionGroup {
  private final String title;
  private List<SaneOption> options = Lists.newArrayList();

  public OptionGroup(String title) {
    this.title = title;
  }

  public String getTitle() {
    return title;
  }

  public OptionValueType getValueType() {
    return OptionValueType.GROUP;
  }

  /**
   * Returns an immutable copy of the options in this group.
   */
  public List<SaneOption> getOptions() {
    return ImmutableList.copyOf(options);
  }

  /**
   * Adds an option to the group.
   */
  void addOption(SaneOption option) {
    Preconditions.checkState(option.getGroup() == this);
    options.add(option);
  }

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("title", title).add("options", options).toString();
  }
}

@@ -57,51 +57,8 @@
 t;%0A%0A
-import com.google.common.base.MoreObjects;%0A
 impo
@@ -1089,83 +1089,74 @@
 urn 
-MoreObjects.toStringHelper(this).add(
+%22OptionGroup%7B%22 + 
 %22title
-%22,
+='%22 +
  title
-).add(%22
+ + '%5C'' + %22, 
 options
-%22,
+=%22 +
  options
 ).to
@@ -1155,20 +1155,14 @@
 ions
-).toString()
+ + '%7D'
 ;%0A  

remove dependence on guava from OptionGroup.toString