com.strongloop.android.loopback

## Class ModelRepository<T extends Model>

- java.lang.Object
- - com.strongloop.android.remoting.Repository<T>
  - - com.strongloop.android.loopback.RestRepository<T>
    - - com.strongloop.android.loopback.ModelRepository<T>

Direct Known Subclasses:
  AccessTokenRepository, UserRepository

    public class ModelRepository<T extends Model>
    extends RestRepository<T>

A local representative of a single model type on the server, encapsulating the name of the model type for easy `Model` creation, discovery, and management.

### Nested Class Summary

Nested Classes
`static interface` `ModelRepository.FindAllCallback<T extends Model>` Deprecated. Use {link ListCallback} instead.
`static interface` `ModelRepository.FindCallback<T extends Model>` Deprecated. Use {link ObjectCallback} instead.

### Constructor Summary

Constructors
Constructor and Description
`ModelRepository(java.lang.String className)`
`ModelRepository(java.lang.String className, java.lang.Class<T> modelClass)` Creates a new Repository, associating it with the named remote class.
`ModelRepository(java.lang.String className, java.lang.String nameForRestUrl, java.lang.Class<T> modelClass)` Creates a new Repository, associating it with the named remote class.

### Method Summary

Methods
`RestContract` `createContract()` Creates a `RestContract` representing this model type's custom routes.
`T` `createModel(java.util.Map<java.lang.String,? extends java.lang.Object> parameters)` Deprecated. Use {link ModelRepository#createObject} instead.
`T` `createObject(java.util.Map<java.lang.String,? extends java.lang.Object> parameters)` Creates a new `Model` of this type with the parameters described.
`void` `findAll(ListCallback<T> callback)` Finds and downloads all models of this type on and from the server.
`void` `findById(java.lang.Object id, ObjectCallback<T> callback)` Finds and downloads a single instance of this model type on and from the server with the given id.
`java.lang.String` `getNameForRestUrl()` Returns the name of the REST url

### Methods inherited from class com.strongloop.android.loopback.RestRepository

`getApplicationContext, getRestAdapter`

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

`getAdapter, getClassName, invokeStaticMethod, invokeStaticMethod, setAdapter`

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

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

### Constructor Detail

#### ModelRepository

    public ModelRepository(java.lang.String className)

#### ModelRepository

    public ModelRepository(java.lang.String className,
                   java.lang.Class<T> modelClass)

Creates a new Repository, associating it with the named remote class.

Parameters:
  `className` - The remote class name.
  `modelClass` - The Model class. It must have a public no-argument constructor.

#### ModelRepository

    public ModelRepository(java.lang.String className,
                   java.lang.String nameForRestUrl,
                   java.lang.Class<T> modelClass)

Creates a new Repository, associating it with the named remote class.

Parameters:
  `className` - The remote class name.
  `nameForRestUrl` - The pluralized class name to use in REST transport. Use `null` for the default value, which is the plural form of className.
  `modelClass` - The Model class. It must have a public no-argument constructor.

### Method Detail

#### getNameForRestUrl

    public java.lang.String getNameForRestUrl()

Returns the name of the REST url

Returns:
  nameForRestUrl

#### createContract

    public RestContract createContract()

Creates a `RestContract` representing this model type's custom routes. Used to extend an `Adapter` to support this model type.

Overrides:
  `createContract` in class `RestRepository<T extends Model>`
Returns:
  A `RestContract` for this model type.

#### createModel

    public T createModel(java.util.Map<java.lang.String,? extends java.lang.Object> parameters)

Deprecated. Use {link ModelRepository#createObject} instead.

#### createObject

    public T createObject(java.util.Map<java.lang.String,? extends java.lang.Object> parameters)

Creates a new `Model` of this type with the parameters described.

Overrides:
  `createObject` in class `Repository<T extends Model>`
Parameters:
  `parameters` - The parameters.
Returns:
  A new `Model`.

#### findById

    public void findById(java.lang.Object id,
                ObjectCallback<T> callback)

Finds and downloads a single instance of this model type on and from the server with the given id.

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

#### findAll

    public void findAll(ListCallback<T> callback)

Finds and downloads all models of this type on and from the server.

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