All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.protostuff.generator.html.json.message.MessageFieldModifier Maven / Gradle / Ivy

There is a newer version: 3.1.40
Show newest version
package io.protostuff.generator.html.json.message;

import static com.google.common.base.Preconditions.checkNotNull;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;

/**
 * JSON field's modifier.
 *
 * @author Kostiantyn Shchepanovskyi
 */
public enum MessageFieldModifier {

    @JsonProperty("optional")
    OPTIONAL,

    @JsonProperty("required")
    REQUIRED,

    @JsonProperty("repeated")
    REPEATED;

    private static final ImmutableMap MODIFIER_BY_PROTO_NAME =
            ImmutableMap.builder()
                    .put("optional", OPTIONAL)
                    .put("required", REQUIRED)
                    .put("repeated", REPEATED)
                    .build();

    /**
     * Get field modifier by it's name.
     */
    @Nonnull
    public static MessageFieldModifier fromString(String s) {
        checkNotNull(s);
        MessageFieldModifier modifier = MODIFIER_BY_PROTO_NAME.get(s);
        checkNotNull(modifier, "Could not find modifier for '%s'", s);
        return modifier;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy