com.backendless.DataStoreFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android Show documentation
Show all versions of android Show documentation
Android SDK used by developers to provide Backendless API in apps.
/*
* ********************************************************************************************************************
*
* BACKENDLESS.COM CONFIDENTIAL
*
* ********************************************************************************************************************
*
* Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers,
* if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
* suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
* or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
* unless prior written permission is obtained from Backendless.com.
*
* ********************************************************************************************************************
*/
package com.backendless;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.exceptions.BackendlessException;
import com.backendless.persistence.BackendlessDataQuery;
import java.util.ArrayList;
import java.util.List;
class DataStoreFactory
{
private static final List emptyRelations = new ArrayList();
protected static IDataStore createDataStore( final Class entityClass )
{
return new IDataStore()
{
@Override
public E save( final E entity ) throws BackendlessException
{
return Backendless.Persistence.save( entity );
}
@Override
public void save( final E entity, final AsyncCallback responder )
{
Backendless.Persistence.save( entity, responder );
}
@Override
public Long remove( final E entity ) throws BackendlessException
{
return Backendless.Persistence.remove( entity );
}
@Override
public void remove( final E entity, final AsyncCallback responder )
{
Backendless.Persistence.remove( entity, responder );
}
@Override
public E findFirst() throws BackendlessException
{
return Backendless.Persistence.first( entityClass );
}
@Override
public E findFirst( int relationsDepth ) throws BackendlessException
{
return findFirst( emptyRelations, relationsDepth );
}
@Override
public E findFirst( List relations ) throws BackendlessException
{
return findFirst( relations, 0 );
}
private E findFirst( List relations, int relationsDepth ) throws BackendlessException
{
return Backendless.Persistence.first( entityClass, relations, relationsDepth );
}
@Override
public void findFirst( final AsyncCallback responder )
{
Backendless.Persistence.first( entityClass, responder );
}
@Override
public void findFirst( int relationsDepth, final AsyncCallback responder )
{
findFirst( emptyRelations, relationsDepth, responder );
}
@Override
public void findFirst( List relations, AsyncCallback responder )
{
findFirst( relations, 0, responder );
}
private void findFirst( List relations, int relationsDepth, final AsyncCallback responder )
{
Backendless.Persistence.first( entityClass, relations, relationsDepth, responder );
}
@Override
public E findLast() throws BackendlessException
{
return Backendless.Persistence.last( entityClass );
}
@Override
public E findLast( int relationsDepth ) throws BackendlessException
{
return findLast( emptyRelations, relationsDepth );
}
@Override
public E findLast( List relations ) throws BackendlessException
{
return findLast( relations, 0 );
}
private E findLast( List relations, int relationsDepth ) throws BackendlessException
{
return Backendless.Persistence.last( entityClass, relations, relationsDepth );
}
@Override
public void findLast( final AsyncCallback responder )
{
Backendless.Persistence.last( entityClass, responder );
}
@Override
public void findLast( int relationsDepth, final AsyncCallback responder )
{
findLast( emptyRelations, relationsDepth, responder );
}
@Override
public void findLast( List relations, AsyncCallback responder )
{
findLast( relations, 0, responder );
}
private void findLast( List relations, int relationsDepth, final AsyncCallback responder )
{
Backendless.Persistence.last( entityClass, relations, relationsDepth, responder );
}
@Override
public BackendlessCollection find() throws BackendlessException
{
return Backendless.Persistence.find( entityClass, new BackendlessDataQuery() );
}
@Override
public BackendlessCollection find( BackendlessDataQuery dataQueryOptions ) throws BackendlessException
{
return Backendless.Persistence.find( entityClass, dataQueryOptions );
}
@Override
public void find( AsyncCallback> responder )
{
Backendless.Persistence.find( entityClass, new BackendlessDataQuery(), responder );
}
@Override
public void find( BackendlessDataQuery dataQueryOptions, AsyncCallback> responder )
{
Backendless.Persistence.find( entityClass, dataQueryOptions, responder );
}
@Override
public E findById( String objectId ) throws BackendlessException
{
return findById( objectId, emptyRelations );
}
@Override
public E findById( String objectId, List relations ) throws BackendlessException
{
return Backendless.Persistence.findById( entityClass, objectId, relations );
}
@Override
public E findById( String objectId, int relationsDepth ) throws BackendlessException
{
return Backendless.Persistence.findById( entityClass, objectId, emptyRelations, relationsDepth );
}
@Override
public E findById( String objectId, List relations, int relationsDepth ) throws BackendlessException
{
return Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth );
}
@Override
public E findById( E entity )
{
return findById( entity, emptyRelations );
}
@Override
public E findById( E entity, List relations )
{
return findById( entity, relations, 0 );
}
@Override
public E findById( E entity, int relationsDepth )
{
return findById( entity, emptyRelations, relationsDepth );
}
@Override
public E findById( E entity, List relations, int relationsDepth )
{
return Backendless.Data.findById( entity, relations, relationsDepth );
}
@Override
public void findById( String objectId, AsyncCallback responder )
{
findById( objectId, emptyRelations, responder );
}
@Override
public void findById( String objectId, List relations, AsyncCallback responder )
{
Backendless.Persistence.findById( entityClass, objectId, relations, responder );
}
@Override
public void findById( String objectId, int relationsDepth, AsyncCallback responder )
{
findById( objectId, emptyRelations, relationsDepth, responder );
}
@Override
public void findById( String objectId, List relations, int relationsDepth, AsyncCallback responder )
{
Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth, responder );
}
@Override
public void findById( E entity, AsyncCallback responder )
{
findById( entity, emptyRelations, responder );
}
@Override
public void findById( E entity, List relations, AsyncCallback responder )
{
findById( entity, relations, 0, responder );
}
@Override
public void findById( E entity, int relationsDepth, AsyncCallback responder )
{
findById( entity, emptyRelations, relationsDepth, responder );
}
@Override
public void findById( E entity, List relations, int relationsDepth, AsyncCallback responder )
{
Backendless.Data.findById( entity, relations, relationsDepth, responder );
}
@Override
public void loadRelations( E entity, List relations ) throws BackendlessException
{
Backendless.Persistence.loadRelations( entity, relations );
}
@Override
public void loadRelations( E entity, List relations, AsyncCallback responder )
{
Backendless.Persistence.loadRelations( entity, relations, responder );
}
};
}
}