/*
 * Copyright 2020, TeamDev. 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 io.spine.code.proto;

import com.google.errorprone.annotations.Immutable;
import com.google.protobuf.Descriptors.Descriptor;
import io.spine.option.EntityOption;
import io.spine.option.OptionsProto;

import java.util.Optional;

/**
 * An option for a message representing a state of the entity which defines its kind and visibility
 * to queries. There are four kids of options, namely, Aggregate, Projection, Process Manager,
 * and Entity).
 */
@Immutable
public final class EntityStateOption extends MessageOption<EntityOption> {

    private EntityStateOption() {
        super(OptionsProto.entity);
    }

    /**
     * Obtains the value of the {@code entity} option from the specified message.
     *
     * @param message
     *         the message to obtain the option value from
     * @return either an {@code Optional} containing the value of the {@code entity} option
     *         or an empty {@code Optional}.
     * @apiNote This method is just a shorthand for
     *      <pre>
     *      {@code
     *      EntityStateOption option = new EntityStateOption();
     *      option.valueFrom(messageDescriptor);
     *      }
     *      </pre>
     * to avoid instantiating an object.
     */
    public static Optional<EntityOption> valueOf(Descriptor message) {
        EntityStateOption option = new EntityStateOption();
        return option.valueFrom(message);
    }

    /**
     * Obtains an entity kind of the message as defined by the {@code (entity)} option.
     *
     * @return an {@code Optional} containing the entity kind if the option is present and an empty
     *         {@code Optional} otherwise
     */
    public static Optional<EntityOption.Kind> entityKindOf(Descriptor message) {
        Optional<EntityOption> option = valueOf(message);
        return option.map(EntityOption::getKind);
    }
}

@@ -1664,38 +1664,40 @@
 e of the %7B@code 
+(
 entity
+)
 %7D option from th
@@ -1882,22 +1882,24 @@
  %7B@code 
+(
 entity
+)
 %7D option
@@ -1942,17 +1942,16 @@
 ptional%7D
-.
 %0A     * 
@@ -2007,16 +2007,18 @@
  *      
+  
 %3Cpre%3E%0A  
@@ -2027,25 +2027,8 @@
  *  
- 
-   %7B@code%0A     *
     
@@ -2093,16 +2093,18 @@
  *      
+  
 option.v
@@ -2144,20 +2144,8 @@
  *  
-    %7D%0A     *
     
@@ -2159,16 +2159,23 @@
 %3E%0A     *
+       
  to avoi

Use proto-like option name in `EntityStateOption` docs