/*
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.gcloud.datastore;

import com.google.common.collect.ImmutableMap;

import java.io.Serializable;
import java.util.Map;

/**
 * Specifies options for read operations in Datastore, namely getting/fetching entities and running
 * queries.
 */
public abstract class ReadOption implements Serializable {

  private static final long serialVersionUID = -4406964829189800528L;

  /**
   * Specifies eventual consistency for reads from Datastore.
   */
  public static final class EventualConsistency extends ReadOption {

    private static final long serialVersionUID = -6959530217724666172L;

    private final boolean eventualConsistency;

    private EventualConsistency(boolean eventualConsistency) {
      this.eventualConsistency = eventualConsistency;
    }

    public boolean isEventual() {
      return eventualConsistency;
    }
  }

  private ReadOption() {}

  /**
   * Returns a {@code ReadOption} that specifies eventual consistency.
   */
  public static EventualConsistency eventualConsistency() {
    return new EventualConsistency(true);
  }

  static Map<Class<? extends ReadOption>, ReadOption> asImmutableMap(ReadOption... options) {
    ImmutableMap.Builder<Class<? extends ReadOption>, ReadOption> builder = ImmutableMap.builder();
    for (ReadOption option : options) {
      builder.put(option.getClass(), option);
    }
    return builder.build();
  }
}

@@ -1068,16 +1068,110 @@
 tastore.
+ Lookups and ancestor queries using%0A   * this option permit Datastore to return stale results.
 %0A   */%0A 
@@ -1665,16 +1665,106 @@
 sistency
+, allowing Datastore to return%0A   * stale results from gets, fetches, and ancestor queries
 .%0A   */%0A

Improve eventual consistency javadoc