Class MutableDocument

    • Constructor Detail

      • MutableDocument

        public MutableDocument()
        Creates a new Document object with a new random UUID. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
      • MutableDocument

        public MutableDocument​(@Nullable
                               String id)
        Creates a new Document with the given ID. If the id is null, the document will be created with a new random UUID. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
        Parameters:
        id - the document ID or null.
      • MutableDocument

        public MutableDocument​(@NonNull
                               Map<String,​Object> data)
        Creates a new Document with a new random UUID and the map as the content. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. The created document will be saved into a database when you call Database.save(Document) with this document object.
        Parameters:
        data - the Map object
      • MutableDocument

        public MutableDocument​(@Nullable
                               String id,
                               @NonNull
                               Map<String,​Object> data)
        Creates a new Document with a given ID and content from the passed Map. If the id is null, the document will be created with a new random UUID. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. The List and Map must contain only the above types. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
        Parameters:
        id - the document ID.
        data - the Map object
      • MutableDocument

        public MutableDocument​(@Nullable
                               String id,
                               @NonNull
                               String json)
        Creates a new Document with the given ID and content from the passed JSON string. If the id is null, the document will be created with a new random UUID. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
        Parameters:
        id - the document ID or null.
        json - the document content as a JSON string.
    • Method Detail

      • toMutable

        @NonNull
        public MutableDocument toMutable()
        Returns the copy of this MutableDocument object.
        Overrides:
        toMutable in class Document
        Returns:
        The MutableDocument object
      • setData

        @NonNull
        public MutableDocument setData​(@NonNull
                                       Map<String,​Object> data)
        Populate a document with content from a Map. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. Setting the document content will replace the current data including the existing Array and Dictionary objects.
        Specified by:
        setData in interface MutableDictionaryInterface
        Parameters:
        data - the dictionary object.
        Returns:
        this Document instance
      • setJSON

        @NonNull
        public MutableDocument setJSON​(@NonNull
                                       String json)
        Populate a document with content from a JSON string. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. Setting the document content will replace the current data including the existing Array and Dictionary objects.
        Specified by:
        setJSON in interface MutableDictionaryInterface
        Parameters:
        json - the dictionary object.
        Returns:
        this Document instance
      • setValue

        @NonNull
        public MutableDocument setValue​(@NonNull
                                        String key,
                                        @Nullable
                                        Object value)
        Set an object value by key. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. An Date object will be converted to an ISO-8601 format string.
        Specified by:
        setValue in interface MutableDictionaryInterface
        Parameters:
        key - the key.
        value - the Object value.
        Returns:
        this Document instance
      • setInt

        @NonNull
        public MutableDocument setInt​(@NonNull
                                      String key,
                                      int value)
        Set a integer value for the given key
        Specified by:
        setInt in interface MutableDictionaryInterface
        Parameters:
        key - the key.
        value - the integer value.
        Returns:
        this MutableDocument instance
      • setLong

        @NonNull
        public MutableDocument setLong​(@NonNull
                                       String key,
                                       long value)
        Set a long value for the given key
        Specified by:
        setLong in interface MutableDictionaryInterface
        Parameters:
        key - the key.
        value - the long value.
        Returns:
        this MutableDocument instance
      • setFloat

        @NonNull
        public MutableDocument setFloat​(@NonNull
                                        String key,
                                        float value)
        Set a float value for the given key
        Specified by:
        setFloat in interface MutableDictionaryInterface
        Parameters:
        key - the key.
        value - the float value.
        Returns:
        this MutableDocument instance
      • setDouble

        @NonNull
        public MutableDocument setDouble​(@NonNull
                                         String key,
                                         double value)
        Set a double value for the given key
        Specified by:
        setDouble in interface MutableDictionaryInterface
        Parameters:
        key - the key.
        value - the double value.
        Returns:
        this MutableDocument instance
      • setBoolean

        @NonNull
        public MutableDocument setBoolean​(@NonNull
                                          String key,
                                          boolean value)
        Set a boolean value for the given key
        Specified by:
        setBoolean in interface MutableDictionaryInterface
        Parameters:
        key - the key.
        value - the boolean value.
        Returns:
        this MutableDocument instance