Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.robrua.orianna.store;
  
  import java.util.Iterator;
  import java.util.List;
  
Interface for local storage, be it in-memory, on disk, or otherwise

Author(s):
Rob Rua (FatalElement - NA) (robrua@alumni.cmu.edu)
 
 public abstract class DataStore {
    

Parameters:
<T> the type of object to check for
type the type of object to check for
Returns:
whether the data store contains the full set of possible objects of this type
 
     protected abstract <T extends OriannaObject<?>> boolean checkHasAll(Class<T> type);

    

Parameters:
<T> the type of object to delete
type the type of object to delete
keys the keys to delete
 
     public <T extends OriannaObject<?>> void delete(final Class<T> typefinal List<?> keys) {
         if(type == null || keys == null || keys.isEmpty()) {
             return;
         }
 
         doDelete(typekeys);
     }

    

Parameters:
<T> the type of object to delete
type the type of object to delete
key the key to delete
 
     public <T extends OriannaObject<?>> void delete(final Class<T> typefinal Object key) {
         if(type == null || key == null) {
             return;
         }
 
         doDelete(typekey);
     }

    

Parameters:
<T> the type of object to delete
type the type of object to delete
keys the keys to delete
 
     protected abstract <T extends OriannaObject<?>> void doDelete(Class<T> typeList<?> keys);

    

Parameters:
<T> the type of object to delete
type the type of object to delete
key the key to delete
 
     protected abstract <T extends OriannaObject<?>> void doDelete(Class<T> typeObject key);

    

Parameters:
<T> the type of object to get
type the type of object to get
keys the keys to get
Returns:
a list of retrieved objects (same length as keys list, with null entries if not found)
 
     protected abstract <T extends OriannaObject<?>> List<T> doGet(Class<T> typeList<?> keys);

    

Parameters:
<T> the type of object to get
type the type of object to get
key the key to get
Returns:
the retrieved object (null if not found)
 
     protected abstract <T extends OriannaObject<?>> T doGet(Class<T> typeObject key);

    

Parameters:
<T> the type of object to get
type the type of object to get
Returns:
all objects of that type in the data store
    protected abstract <T extends OriannaObject<?>> List<T> doGetAll(Class<T> type);

    

Parameters:
<T> the type of object to get
type the type of object to get
Returns:
an iterator over objects of that type in the data store
    protected abstract <T extends OriannaObject<?>> Iterator<T> doGetIterator(final Class<T> type);

    

Parameters:
<T> the type of object to store
type the type of object to store
objs the objects to store
keys the keys to store them with
isFullSet whether these are all the objects of that type that can exist
    protected abstract <T extends OriannaObject<?>> void doStore(Class<T> typeList<T> objsList<?> keysboolean isFullSet);

    

Parameters:
<T> the type of object to store
obj the object to store
key the key to store it with
    protected abstract <T extends OriannaObject<?>> void doStore(T objObject key);

    

Parameters:
<T> the type of object to get
type the type of object to get
keys the keys to get
Returns:
a list of retrieved objects (same length as keys list, with null entries if not found)
    public <T extends OriannaObject<?>> List<T> get(final Class<T> typefinal List<?> keys) {
        if(type == null || keys == null || keys.isEmpty()) {
            return Collections.emptyList();
        }
        return doGet(typekeys);
    }

    

Parameters:
<T> the type of object to get
type the type of object to get
key the key to get
Returns:
the retrieved object (null if not found)
    public <T extends OriannaObject<?>> T get(final Class<T> typefinal Object key) {
        if(type == null || key == null) {
            return null;
        }
        return doGet(typekey);
    }

    

Parameters:
<T> the type of object to get
type the type of object to get
Returns:
all objects of that type in the data store
    public <T extends OriannaObject<?>> List<T> getAll(final Class<T> type) {
        if(type == null) {
            return Collections.emptyList();
        }
        return doGetAll(type);
    }

    

Parameters:
<T> the type of object to get
type the type of object to get
Returns:
an iterator over objects of that type in the data store
    public <T extends OriannaObject<?>> Iterator<T> getIterator(final Class<T> type) {
        if(type == null) {
            return Collections.emptyIterator();
        }
        return doGetIterator(type);
    }

    

Parameters:
<T> the type of object to check for
type the type of object to check for
Returns:
whether the data store contains the full set of possible objects of this type
    public <T extends OriannaObject<?>> boolean hasAll(final Class<T> type) {
        if(type == null) {
            return false;
        }
        return checkHasAll(type);
    }

    

Parameters:
<T> the type of object to store
type the type of object to store
objs the objects to store
keys the keys to store them with
isFullSet whether these are all the objects of that type that can exist
    public <T extends OriannaObject<?>> void store(final Class<T> typefinal List<T> objsfinal List<?> keysfinal boolean isFullSet) {
        if(type == null || objs == null || keys == null || objs.size() != keys.size() || objs.isEmpty()) {
            return;
        }
        doStore(typeobjskeysisFullSet);
    }

    

Parameters:
<T> the type of object to store
obj the object to store
key the key to store it with
    public <T extends OriannaObject<?>> void store(final T objfinal Object key) {
        if(obj == null || key == null) {
            return;
        }
        doStore(objkey);
    }
New to GrepCode? Check out our FAQ X