organize packages
This commit is contained in:
parent
8a0e7babd3
commit
ac7b2d9b40
26 changed files with 127 additions and 75 deletions
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package casser.core;
|
||||
package casser.config;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
package casser.core;
|
||||
package casser.converter;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.core;
|
||||
package casser.converter;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -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) {
|
||||
|
|
61
src/main/java/casser/core/CasserSession.java
Normal file
61
src/main/java/casser/core/CasserSession.java
Normal 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();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package casser.core;
|
||||
|
||||
import casser.dsl.Getter;
|
||||
import casser.core.dsl.Getter;
|
||||
|
||||
public final class Filter {
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package casser.dsl;
|
||||
package casser.core.dsl;
|
||||
|
||||
public interface Getter<V> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.dsl;
|
||||
package casser.core.dsl;
|
||||
|
||||
public interface Setter<V> {
|
||||
|
|
@ -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> {
|
||||
|
|
@ -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> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Stream;
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
public class CountOperation extends AbstractOperation<Long, CountOperation> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
|
||||
public class DeleteOperation extends AbstractFilterOperation<Object, DeleteOperation> {
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
|
||||
public class UpdateOperation extends AbstractFilterOperation<Object, UpdateOperation> {
|
|
@ -1,4 +1,4 @@
|
|||
package casser.operation;
|
||||
package casser.core.operation;
|
||||
|
||||
public class UpsertOperation extends AbstractOperation<Object, UpsertOperation> {
|
||||
|
|
@ -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 {
|
|
@ -1,4 +1,4 @@
|
|||
package casser.core;
|
||||
package casser.core.reflect;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
|
@ -1,4 +1,4 @@
|
|||
package casser.tuple;
|
||||
package casser.core.tuple;
|
||||
|
||||
public final class Tuple1<V1> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.tuple;
|
||||
package casser.core.tuple;
|
||||
|
||||
public final class Tuple2<V1, V2> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package casser.tuple;
|
||||
package casser.core.tuple;
|
||||
|
||||
public final class Tuple3<V1, V2, V3> {
|
||||
|
Loading…
Reference in a new issue