org.boon.datarepo.impl.RepoDefault Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boon Show documentation
Show all versions of boon Show documentation
Simple opinionated Java for the novice to expert level Java Programmer.
Low Ceremony. High Productivity. A real boon to Java to developers!
package org.boon.datarepo.impl;
import org.boon.criteria.*;
import org.boon.datarepo.*;
import org.boon.datarepo.spi.RepoComposer;
import org.boon.datarepo.spi.SearchIndex;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Default Repo implementation.
*
* @param primary key or handleUnexpectedException of object.
* @param - item that this repo holds.
*/
public class RepoDefault
implements Repo, RepoComposer {
private ObjectEditor editor;
private SearchableCollection query;
@Override
public void updateByFilter( String property, Object value, Criteria... expressions ) {
List- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilterUsingValue( String property, String value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modifyByValue( item, property, value );
}
}
@Override
public void updateByFilter( String property, int value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( String property, long value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( String property, char value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( String property, short value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( String property, byte value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( String property, float value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( String property, double value, Criteria... expressions ) {
List
- items = query.query( expressions );
for ( ITEM item : items ) {
modify( item, property, value );
}
}
@Override
public void updateByFilter( List
values, Criteria... expressions ) {
List- items = query.query( expressions );
for ( ITEM item : items ) {
for ( Update value : values ) {
query.invalidateIndex( value.getName(), item );
value.doSet( this, item );
query.validateIndex( value.getName(), item );
}
}
}
@Override
public ITEM get( KEY key ) {
return editor.get( key );
}
@Override
public KEY getKey( ITEM item ) {
return editor.getKey( item );
}
@Override
public void invalidateIndex( String property, ITEM item ) {
query.invalidateIndex( property, item );
}
@Override
public void validateIndex( String property, ITEM item ) {
query.validateIndex( property, item );
}
@Override
public void validateIndexes( ITEM item ) {
query.validateIndexes( item );
}
@Override
public Object readObject( KEY key, String property ) {
return editor.readObject( key, property );
}
@Override
public
T readValue( KEY key, String property, Class type ) {
return editor.readValue( key, property, type );
}
@Override
public int readInt( KEY key, String property ) {
return editor.readInt( key, property );
}
@Override
public long readLong( KEY key, String property ) {
return editor.readLong( key, property );
}
@Override
public char readChar( KEY key, String property ) {
return editor.readChar( key, property );
}
@Override
public short readShort( KEY key, String property ) {
return editor.readShort( key, property );
}
@Override
public byte readByte( KEY key, String property ) {
return editor.readByte( key, property );
}
@Override
public float readFloat( KEY key, String property ) {
return editor.readFloat( key, property );
}
@Override
public double readDouble( KEY key, String property ) {
return editor.readDouble( key, property );
}
@Override
public Object getObject( ITEM item, String property ) {
return editor.getObject( item, property );
}
@Override
public T getValue( ITEM item, String property, Class type ) {
return editor.getValue( item, property, type );
}
@Override
public int getInt( ITEM item, String property ) {
return editor.getInt( item, property );
}
@Override
public long getLong( ITEM item, String property ) {
return editor.getLong( item, property );
}
@Override
public char getChar( ITEM item, String property ) {
return editor.getChar( item, property );
}
@Override
public short getShort( ITEM item, String property ) {
return editor.getShort( item, property );
}
@Override
public byte getByte( ITEM item, String property ) {
return editor.getByte( item, property );
}
@Override
public float getFloat( ITEM item, String property ) {
return editor.getFloat( item, property );
}
@Override
public double getDouble( ITEM item, String property ) {
return editor.getDouble( item, property );
}
@Override
public int count( KEY key, String property, int value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, short value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, byte value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, long value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, char value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, float value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, double value ) {
return query.count( key, property, value );
}
@Override
public int count( KEY key, String property, Object value ) {
return query.count( key, property, value );
}
@Override
public T max( KEY key, String property, Class type ) {
return query.max( key, property, type );
}
@Override
public String maxString( KEY key, String property ) {
return query.maxString( key, property );
}
@Override
public Number maxNumber( KEY key, String property ) {
return query.maxNumber( key, property );
}
@Override
public int maxInt( KEY key, String property ) {
return query.maxInt( key, property );
}
@Override
public long maxLong( KEY key, String property ) {
return query.maxLong( key, property );
}
@Override
public double maxDouble( KEY key, String property ) {
return query.maxDouble( key, property );
}
@Override
public T min( KEY key, String property, Class type ) {
return query.min( key, property, type );
}
@Override
public String minString( KEY key, String property ) {
return query.minString( key, property );
}
@Override
public Number minNumber( KEY key, String property ) {
return query.minNumber( key, property );
}
@Override
public int minInt( KEY key, String property ) {
return query.minInt( key, property );
}
@Override
public long minLong( KEY key, String property ) {
return query.minLong( key, property );
}
@Override
public double minDouble( KEY key, String property ) {
return query.minDouble( key, property );
}
@Override
public ResultSet- results( Criteria... expressions ) {
return query.results( expressions );
}
@Override
public List
- query( Criteria... expressions ) {
return query.query( expressions );
}
@Override
public List
- sortedQuery( String sortBy, Criteria... expressions ) {
return query.sortedQuery( sortBy, expressions );
}
@Override
public List
- sortedQuery( Sort sortBy, Criteria... expressions ) {
return query.sortedQuery( sortBy, expressions );
}
@Override
public List