Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Opensec UTIL - https://nakamura5akihito.github.io/ Copyright (C) 2015 Akihito Nakamura Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package io.opensec.util.repository;
 
 import java.util.List;



A prescription for the low-level persistent data store.

Author(s):
Akihito Nakamura, AIST
 
 public interface Datastore
 {

    
Loads the object of the specified identifier. If no such object exists in the storage, this method returns null.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
id the identifier of the object.
Returns:
the object if exists, or null otherwise.
Throws:
ObjectNotFoundException if the object not found.
RepositoryException in case of repository errors.
 
     public <T, K extends Serializable>
     T findByIdClass<T> type, K id );



    
Tests if the object of the specified identifier exists.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
id the identifier of the object.
Returns:
true if the object exists, or false otherwise.
Throws:
RepositoryException in case of repository errors.
 
     public <T, K extends Serializable>
     boolean existsClass<T> type, K id );



    
Loads all the objects of the specified type.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
Returns:
all the objects of the specified type.
Throws:
RepositoryException in case of repository errors.
 
     public <T, K extends Serializable>
     List<T> findClass<T> type );
 
 
 
 //    /**
 //     * Loads all the objects of the specified type with the given identifiers.
 //     *
 //     * @param   type
 //     *  the type of the object.
 //     * @return
 //     *  all the objects of the specified type.
 //     */
 //    public <T, K extends Serializable>
 //    List<T> find( Class<T> type, Iterable<K> ids );



    
Searches for the objects that match the specified query parameters.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
params the parameters to select the objects.
Returns:
all the objects of the specified type.
Throws:
QueryException in case of query errors.
RepositoryException in case of repository errors.
    public <T, K extends Serializable>
    List<T> findClass<T> typeQueryParams params );



    
Returns identifiers of all the objects of the specified type.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
Returns:
the identifiers of all the objects.
Throws:
RepositoryException in case of repository errors.
    public <T, K extends Serializable>
    List<K> findIdClass<T> type );



    
Searches for the identifiers of the objects that match the specified query parameters.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
params the parameters to select the objects.
Returns:
the identifiers of all the objects.
    public <T, K extends Serializable>
    List<K> findIdClass<T> typeQueryParams params );



    
Counts the number of all the objects of the specified type.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
Returns:
the number of the objects.
    public <T, K extends Serializable>
    long countClass<T> type );



    
Counts the number of the objects that match the specified query parameters.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
params the parameters to select the objects.
Returns:
the number of the objects.
Throws:
QueryException in case of query errors.
RepositoryException in case of repository errors.
    public <T, K extends Serializable>
    long countClass<T> typeQueryParams params );



    
Saves the object, either inserting or updating the existing one.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
object the object.
Returns:
the identifier of the object.
Throws:
ObjectIntegrityException in case of object integrity errors.
RepositoryException in case of repository errors.
    public <T, K extends Serializable>
    K saveClass<T> type, T object );



    
Removes the object of the specified identifier. If no such object exists, this method returns immediately without any exception.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
id the identifier of the object.
Throws:
ObjectNotFoundException if the object not found.
RepositoryException in case of repository errors.
    public <T, K extends Serializable>
    void deleteByIdClass<T> type, K id );



    
Removes all the object of the specified type.

Parameters:
<T> the type of the object.
<K> the type of the unique key of the object.
type the type of the object.
Throws:
RepositoryException in case of repository errors.
    public <T, K extends Serializable>
    void deleteClass<T> type );
//
New to GrepCode? Check out our FAQ X