class NumberTypeAdapter extends TypeAdapter<Number> {
  /** Gson default factory using {@link ToNumberPolicy#LAZILY_PARSED_NUMBER}. */
  private static final TypeAdapterFactory LAZILY_PARSED_NUMBER_FACTORY =
      newFactory(ToNumberPolicy.LAZILY_PARSED_NUMBER);

  private final ToNumberStrategy toNumberStrategy;

  private NumberTypeAdapter(ToNumberStrategy toNumberStrategy) {
    this.toNumberStrategy = toNumberStrategy;
  }

  private static TypeAdapterFactory newFactory(ToNumberStrategy toNumberStrategy) {
    final NumberTypeAdapter adapter = new NumberTypeAdapter(toNumberStrategy);
    return new TypeAdapterFactory() {
      @SuppressWarnings("unchecked")
      @Override
      public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        return type.getRawType() == Number.class ? (TypeAdapter<T>) adapter : null;
      }
    };
  }

  public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberStrategy) {<FILL_FUNCTION_BODY>}

  @Override
  public Number read(JsonReader in) throws IOException {
    JsonToken jsonToken = in.peek();
    switch (jsonToken) {
      case NULL:
        in.nextNull();
        return null;
      case NUMBER:
      case STRING:
        return toNumberStrategy.readNumber(in);
      default:
        throw new JsonSyntaxException(
            "Expecting number, got: " + jsonToken + "; at path " + in.getPath());
    }
  }

  @Override
  public void write(JsonWriter out, Number value) throws IOException {
    out.value(value);
  }
}

    if (toNumberStrategy == ToNumberPolicy.LAZILY_PARSED_NUMBER) {
      return LAZILY_PARSED_NUMBER_FACTORY;
    } else {
      return newFactory(toNumberStrategy);
    }
  
<methods>public void <init>() ,public final java.lang.Number fromJson(java.io.Reader) throws java.io.IOException,public final java.lang.Number fromJson(java.lang.String) throws java.io.IOException,public final java.lang.Number fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.lang.Number> nullSafe() ,public abstract java.lang.Number read(com.google.gson.stream.JsonReader) throws java.io.IOException,public final void toJson(java.io.Writer, java.lang.Number) throws java.io.IOException,public final java.lang.String toJson(java.lang.Number) ,public final com.google.gson.JsonElement toJsonTree(java.lang.Number) ,public abstract void write(com.google.gson.stream.JsonWriter, java.lang.Number) throws java.io.IOException<variables>