com.strongloop.android.loopback

## Class Model

- java.lang.Object
- - com.strongloop.android.remoting.VirtualObject
  - - com.strongloop.android.loopback.Model

Direct Known Subclasses:
  AccessToken, User

    public class Model
    extends VirtualObject

A local representative of a single model instance on the server. The data is immediately accessible locally, but can be saved, destroyed, etc. from the server easily.

### Nested Class Summary

Nested Classes
`static interface` `Model.Callback` Deprecated. Use {link VoidCallback} instead.

### Constructor Summary

Constructors
Constructor and Description
`Model()`
`Model(Repository repository, java.util.Map<java.lang.String,? extends java.lang.Object> creationParameters)`

### Method Summary

Methods
`void` `destroy(VoidCallback callback)` Destroys the Model from the server.
`java.lang.Object` `get(java.lang.String key)` Gets the value associated with a given key.
`java.lang.Object` `getId()` Gets the model's id field.
`void` `put(java.lang.String key, java.lang.Object value)` Adds a given key-value pair to the dictionary.
`void` `putAll(java.util.Map<java.lang.String,? extends java.lang.Object> params)` Adds all the specified params to the dictionary.
`void` `save(VoidCallback callback)` Saves the Model to the server.
`java.util.Map<java.lang.String,? extends java.lang.Object>` `toMap()` Converts the Model (and all of its Java Bean properties) into a `Map`.

### Methods inherited from class com.strongloop.android.remoting.VirtualObject

`getCreationParameters, getRepository, invokeMethod, invokeMethod, setCreationParameters, setRepository`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Model

    public Model(Repository repository,
         java.util.Map<java.lang.String,? extends java.lang.Object> creationParameters)

#### Model

    public Model()

### Method Detail

#### getId

    public java.lang.Object getId()

Gets the model's id field.

Returns:
  The id.

#### get

    public java.lang.Object get(java.lang.String key)

Gets the value associated with a given key.

Parameters:
  `key` - The key for which to return the corresponding value.
Returns:
  The value associated with the key, or `null` if no value is associated with the key.

#### put

    public void put(java.lang.String key,
           java.lang.Object value)

Adds a given key-value pair to the dictionary.

Parameters:
  `key` - The key for value. If the key already exists in the dictionary, the specified value takes its place.
  `value` - The value for the key. The value may be `null`.

#### putAll

    public void putAll(java.util.Map<java.lang.String,? extends java.lang.Object> params)

Adds all the specified params to the dictionary.

Parameters:
  `params` - The params to add.

#### toMap

    public java.util.Map<java.lang.String,? extends java.lang.Object> toMap()

Converts the Model (and all of its Java Bean properties) into a `Map`.

Overrides:
  `toMap` in class `VirtualObject`

#### save

    public void save(VoidCallback callback)

Saves the Model to the server.

This method calls `toMap()` to determine which fields should be saved.

Parameters:
  `callback` - The callback to be executed when finished.

#### destroy

    public void destroy(VoidCallback callback)

Destroys the Model from the server.

Parameters:
  `callback` - The callback to be executed when finished.