/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package org.spine3.server.stand;

import com.google.common.collect.ImmutableCollection;
import com.google.protobuf.FieldMask;
import org.spine3.annotation.SPI;
import org.spine3.server.entity.EntityRecord;
import org.spine3.server.entity.storage.EntityQuery;
import org.spine3.server.storage.RecordStorage;
import org.spine3.string.StringifierRegistry;
import org.spine3.type.TypeUrl;

import java.util.Map;

/**
 * Serves as a storage for the latest
 * {@link org.spine3.server.aggregate.Aggregate Aggregate} states.
 *
 * <p>Used by an instance of {@link Stand} to optimize
 * the {@code Aggregate} state fetch performance.
 *
 * @author Alex Tymchenko
 * @see com.google.protobuf.Any#getTypeUrl() Any.getTypeUrl()
 * @see Stand
 */
@SPI
public abstract class StandStorage extends RecordStorage<AggregateStateId> {

    static {
        StringifierRegistry.getInstance()
                           .register(new AggregateStateIdStringifier(),
                                     AggregateStateId.class);
    }

    protected StandStorage(boolean multitenant) {
        super(multitenant);
    }

    /**
     * Reads all the state records by the given type.
     *
     * @param type a {@link TypeUrl} instance
     * @return the state records which {@link com.google.protobuf.Any#getTypeUrl() Any.getTypeUrl()}
     * equals the argument value
     */
    public abstract ImmutableCollection<EntityRecord> readAllByType(TypeUrl type);

    /**
     * Reads all the state records by the given type.
     *
     * @param type a {@link TypeUrl} instance
     * @return the state records which {@link com.google.protobuf.Any#getTypeUrl() Any.getTypeUrl()}
     * equals the argument value
     */
    public abstract ImmutableCollection<EntityRecord> readAllByType(TypeUrl type,
                                                                    FieldMask fieldMask);

    /**
     * The {@code StandStorage} is specified not to satisfy the {@link EntityQuery}.
     *
     * <p>Calling this method is equivalent to calling {@code readAll(fieldMask)}.
     *
     * @param query     ignored
     * @param fieldMask the fields to retrieve
     * @return all the records with the {@link FieldMask} applied
     */
    @Override
    public Map<AggregateStateId, EntityRecord> readAll(EntityQuery<AggregateStateId> query,
                                                       FieldMask fieldMask) {
        return readAll(fieldMask);
    }

    @Override
    protected Map<AggregateStateId, EntityRecord> readAllRecords(
            EntityQuery<AggregateStateId> query,
            FieldMask fieldMask) {
        throw new IllegalStateException("Call #readAll(EntityQuery, FieldMask) instead.");
    }
}

@@ -2898,84 +2898,283 @@
   * 
-The %7B@code StandStorage%7D is specified not to satisfy the %7B@link EntityQuery%7D
+Reads all the state records from the storage.%0A     *%0A     * %3Cp%3EThis method overrides the behaviour of the superclass. Since %7B@code StandStorage%7D does not%0A     * support Entity Columns, the passed %7B@link EntityQuery%7D does not affect the resulting%0A     * %7B@code Map%7D in any way
 .%0A  
@@ -3347,16 +3347,16 @@
 etrieve%0A
-
      * @
@@ -3413,16 +3413,48 @@
 applied%0A
+     * @see #readAll(FieldMask)%0A
      */%0A

Fix Javadoc.