package com.google.copybara;

import com.google.common.collect.ImmutableMap;

import java.util.Arrays;

/**
 * A class that groups all the options used in the program
 */
public class Options {

  private final ImmutableMap<Class<?>, Object> config;

  public Options(Iterable<Option> options) {
    ImmutableMap.Builder<Class<?>, Object> builder = ImmutableMap.builder();
    for (Object option : options) {
      builder.put(option.getClass(), option);
    }
    config = builder.build();
  }

  /**
   * Get an option for a given class.
   *
   * @throws IllegalStateException if the configuration cannot be found
   */
  @SuppressWarnings("unchecked")
  public <T> T getOption(Class<? extends T> optionClass) {
    Object config = this.config.get(optionClass);
    if (config == null) {
      throw new IllegalStateException("No option type found for " + optionClass);
    }
    return (T) config;
  }
}

@@ -75,34 +75,8 @@
 p;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -198,25 +198,40 @@
 %3CClass%3C?
-%3E, Object
+ extends Option%3E, Option
 %3E config
@@ -259,16 +259,26 @@
 terable%3C
+? extends 
 Option%3E 
@@ -324,17 +324,32 @@
 ss%3C?
-%3E, Object
+ extends Option%3E, Option
 %3E bu
@@ -390,21 +390,21 @@
   for (O
-bject
+ption
  option 
@@ -674,16 +674,31 @@
 ublic %3CT
+ extends Option
 %3E T getO
@@ -746,13 +746,13 @@
    O
-bject
+ption
  con

Fix ReplaceRegexTest