Class JsonMapBuilder


  • public final class JsonMapBuilder
    extends java.lang.Object
    Helper class for Jsonifiable classes to generate JSON maps for RPC responses.

    The returned map is mutable. Map entries can be null but list entries can not. If a list is passed as null, it'll be substituted with empty list. Lists are not mutable.

    • Constructor Detail

      • JsonMapBuilder

        public JsonMapBuilder()
    • Method Detail

      • put

        public JsonMapBuilder put​(java.lang.String name,
                                  @Nullable
                                  java.lang.Boolean value)
      • put

        public JsonMapBuilder put​(java.lang.String name,
                                  @Nullable
                                  java.lang.Number value)
      • put

        public JsonMapBuilder put​(java.lang.String name,
                                  @Nullable
                                  java.lang.String value)
      • put

        public JsonMapBuilder put​(java.lang.String name,
                                  @Nullable
                                  java.lang.Enum<?> value)
      • putString

        public <T> JsonMapBuilder putString​(java.lang.String name,
                                            @Nullable
                                            T value)
      • putListOfStrings

        public <T> JsonMapBuilder putListOfStrings​(java.lang.String name,
                                                   @Nullable
                                                   java.lang.Iterable<T> value)
      • putListOfJsonObjects

        public JsonMapBuilder putListOfJsonObjects​(java.lang.String name,
                                                   @Nullable
                                                   java.lang.Iterable<? extends Jsonifiable> value)
      • build

        public java.util.Map<java.lang.String,​java.lang.Object> build()
        Returns mutable JSON object. Please dispose of the builder object after calling me.