com.strongloop.android.loopback

## Class ModelPrototype<T extends Model>

- java.lang.Object
- - com.strongloop.android.remoting.Prototype
  - - com.strongloop.android.loopback.ModelPrototype<T>

    public class ModelPrototype<T extends Model>
    extends Prototype

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` `ModelPrototype.FindAllCallback<T extends Model>`
`static interface` `ModelPrototype.FindCallback<T extends Model>`

### Constructor Summary

Constructors
Constructor and Description
`ModelPrototype(java.lang.String className)`
`ModelPrototype(java.lang.String className, java.lang.Class<T> modelClass)` Creates a new Prototype, associating it with the named remote class.
`ModelPrototype(java.lang.String className, java.lang.String nameForRestUrl, java.lang.Class<T> modelClass)` Creates a new Prototype, 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)` Creates a new `Model` of this type with the parameters described.
`void` `findAll(ModelPrototype.FindAllCallback<T> callback)` Finds and downloads all models of this type on and from the server.
`void` `findById(java.lang.Object id, ModelPrototype.FindCallback<T> callback)` Finds and downloads a single instance of this model type on and from the server with the given id.

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

`createObject, getAdapter, getClassName, invokeStaticMethod, setAdapter`

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

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

### Constructor Detail

#### ModelPrototype

    public ModelPrototype(java.lang.String className)

#### ModelPrototype

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

Creates a new Prototype, 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.

#### ModelPrototype

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

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

Parameters:
  `className` - The remote class name.
  `nameForRestUrl` - The pluralized class name to use in REST transport.
  `modelClass` - The Model class. It must have a public no-argument constructor.

### Method Detail

#### createContract

    public RestContract createContract()

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

Returns:
  A `RestContract` for this model type.

#### createModel

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

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

Parameters:
  `parameters` - The parameters.
Returns:
  A new `Model`.

#### findById

    public void findById(java.lang.Object id,
                ModelPrototype.FindCallback<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(ModelPrototype.FindAllCallback<T> callback)

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

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