organize packages

This commit is contained in:
Albert Shift 2015-03-15 23:43:32 -07:00
parent 8a0e7babd3
commit ac7b2d9b40
26 changed files with 127 additions and 75 deletions

View file

@ -1,18 +1,22 @@
package casser;
import com.datastax.driver.core.Cluster;
import casser.core.Casser;
import casser.core.Filter;
import casser.core.Prepared;
import casser.core.Session;
import casser.operation.SelectOperation;
import casser.tuple.Tuple1;
import casser.tuple.Tuple2;
import casser.core.CasserSession;
import casser.core.operation.SelectOperation;
import casser.core.tuple.Tuple1;
import casser.core.tuple.Tuple2;
public class Example {
static final User _user = Casser.dsl(User.class);
Session session = Casser.connect("localhost").update(_user).get();
Cluster cluster = new Cluster.Builder().addContactPoint("localhost").build();
CasserSession session = Casser.connect(cluster).use("test").update(_user).get();
public static User mapUser(Tuple2<String, Integer> t) {
User user = Casser.pojo(User.class);

View file

@ -1,4 +1,4 @@
package casser.core;
package casser.config;
import java.util.function.Function;

View file

@ -1,7 +1,10 @@
package casser.core;
package casser.config;
import java.util.function.Function;
import casser.converter.CamelCaseToUnderscoreConverter;
import casser.converter.MethodNameToPropertyConverter;
public class DefaultCasserSettings implements CasserSettings {
@Override

View file

@ -1,4 +1,4 @@
package casser.core;
package casser.converter;
import java.util.function.Function;

View file

@ -1,4 +1,4 @@
package casser.core;
package casser.converter;
import java.util.function.Function;

View file

@ -3,6 +3,14 @@ package casser.core;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import casser.config.CasserSettings;
import casser.config.DefaultCasserSettings;
import casser.core.reflect.DslInvocationHandler;
import casser.core.reflect.PojoInvocationHandler;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
public final class Casser {
@ -21,9 +29,15 @@ public final class Casser {
casserSettings = overrideSettings;
return old;
}
public static SessionInitializer connect(String host) {
return null;
public static SessionInitializer connect(Cluster cluster) {
Session session = cluster.connect();
return new SessionInitializer(session);
}
public static SessionInitializer connect(Cluster cluster, String keyspace) {
Session session = cluster.connect(keyspace);
return new SessionInitializer(session);
}
public static <E> E dsl(Class<E> iface) {

View file

@ -0,0 +1,61 @@
package casser.core;
import java.io.Closeable;
import casser.core.dsl.Getter;
import casser.core.dsl.Setter;
import casser.core.operation.DeleteOperation;
import casser.core.operation.SelectOperation;
import casser.core.operation.UpdateOperation;
import casser.core.operation.UpsertOperation;
import casser.core.tuple.Tuple1;
import casser.core.tuple.Tuple2;
import casser.core.tuple.Tuple3;
import com.datastax.driver.core.CloseFuture;
import com.datastax.driver.core.Session;
public class CasserSession implements Closeable {
private Session session;
protected CasserSession(Session session) {
this.session = session;
}
public <V1> SelectOperation<Tuple1<V1>> select(Getter<V1> getter1) {
return null;
}
public <V1, V2> SelectOperation<Tuple2<V1, V2>> select(Getter<V1> getter1, Getter<V2> getter2) {
return null;
}
public <V1, V2, V3> SelectOperation<Tuple3<V1, V2, V3>> select(Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3) {
return null;
}
public <V1> UpdateOperation update(Setter<V1> setter1, V1 v1) {
return null;
}
public UpsertOperation upsert(Object pojo) {
return null;
}
public DeleteOperation delete() {
return null;
}
public Session getSession() {
return session;
}
public void close() {
session.close();
}
public CloseFuture closeAsync() {
return session.closeAsync();
}
}

View file

@ -1,6 +1,6 @@
package casser.core;
import casser.dsl.Getter;
import casser.core.dsl.Getter;
public final class Filter {

View file

@ -1,42 +0,0 @@
package casser.core;
import casser.dsl.Getter;
import casser.dsl.Setter;
import casser.operation.DeleteOperation;
import casser.operation.SelectOperation;
import casser.operation.UpdateOperation;
import casser.operation.UpsertOperation;
import casser.tuple.Tuple1;
import casser.tuple.Tuple2;
import casser.tuple.Tuple3;
public class Session {
public <V1> SelectOperation<Tuple1<V1>> select(Getter<V1> getter1) {
return null;
}
public <V1, V2> SelectOperation<Tuple2<V1, V2>> select(Getter<V1> getter1, Getter<V2> getter2) {
return null;
}
public <V1, V2, V3> SelectOperation<Tuple3<V1, V2, V3>> select(Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3) {
return null;
}
public <V1> UpdateOperation update(Setter<V1> setter1, V1 v1) {
return null;
}
public UpsertOperation upsert(Object pojo) {
return null;
}
public DeleteOperation delete() {
return null;
}
public void close() {
}
}

View file

@ -1,8 +1,16 @@
package casser.core;
import com.datastax.driver.core.Session;
public class SessionInitializer {
private final Session session;
public SessionInitializer(Session session) {
this.session = session;
}
public SessionInitializer validate(Object... dsls) {
return this;
}
@ -20,11 +28,12 @@ public class SessionInitializer {
}
public SessionInitializer use(String keyspace) {
session.execute("USE " + keyspace);
return this;
}
public Session get() {
return null;
public CasserSession get() {
return new CasserSession(session);
}

View file

@ -1,4 +1,4 @@
package casser.dsl;
package casser.core.dsl;
public interface Getter<V> {

View file

@ -1,4 +1,4 @@
package casser.dsl;
package casser.core.dsl;
public interface Setter<V> {

View file

@ -1,7 +1,7 @@
package casser.operation;
package casser.core.operation;
import casser.core.Filter;
import casser.dsl.Getter;
import casser.core.dsl.Getter;
public abstract class AbstractFilterOperation<E, O extends AbstractFilterOperation<E, O>> extends AbstractOperation<E, O> {

View file

@ -1,7 +1,7 @@
package casser.operation;
package casser.core.operation;
import casser.core.Filter;
import casser.dsl.Getter;
import casser.core.dsl.Getter;
public abstract class AbstractFilterStreamOperation<E, O extends AbstractFilterStreamOperation<E, O>> extends AbstractStreamOperation<E, O> {

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
import java.util.concurrent.Future;

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
import java.util.concurrent.Future;
import java.util.stream.Stream;

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
public class CountOperation extends AbstractOperation<Long, CountOperation> {

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
public class DeleteOperation extends AbstractFilterOperation<Object, DeleteOperation> {

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
import java.util.function.Function;

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
public class UpdateOperation extends AbstractFilterOperation<Object, UpdateOperation> {

View file

@ -1,4 +1,4 @@
package casser.operation;
package casser.core.operation;
public class UpsertOperation extends AbstractOperation<Object, UpsertOperation> {

View file

@ -1,8 +1,11 @@
package casser.core;
package casser.core.reflect;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import casser.config.CasserSettings;
import casser.core.Casser;
import casser.core.ColumnInformation;
import casser.support.DslColumnException;
public class DslInvocationHandler<E> implements InvocationHandler {

View file

@ -1,4 +1,4 @@
package casser.core;
package casser.core.reflect;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

View file

@ -1,4 +1,4 @@
package casser.tuple;
package casser.core.tuple;
public final class Tuple1<V1> {

View file

@ -1,4 +1,4 @@
package casser.tuple;
package casser.core.tuple;
public final class Tuple2<V1, V2> {

View file

@ -1,4 +1,4 @@
package casser.tuple;
package casser.core.tuple;
public final class Tuple3<V1, V2, V3> {