removed Example.java, the file from what the project was started ;)

This commit is contained in:
Albert Shift 2015-04-27 20:50:16 -07:00
parent 0f33939184
commit 323ce05162
3 changed files with 1 additions and 140 deletions

View file

@ -25,7 +25,7 @@ Active development dependency:
<dependency> <dependency>
<groupId>com.noorq.casser</groupId> <groupId>com.noorq.casser</groupId>
<artifactId>casser-core</artifactId> <artifactId>casser-core</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -1,110 +0,0 @@
/*
* Copyright (C) 2015 Noorq, Inc.
*
* 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 com.noorq.casser;
import static com.noorq.casser.core.Query.eq;
import com.datastax.driver.core.Cluster;
import com.noorq.casser.core.Casser;
import com.noorq.casser.core.CasserSession;
import com.noorq.casser.core.Operator;
import com.noorq.casser.core.operation.PreparedStreamOperation;
import com.noorq.casser.support.Fun;
import com.noorq.casser.support.Fun.Tuple1;
public class Example {
static final User user = Casser.dsl(User.class);
Cluster cluster = new Cluster.Builder().addContactPoint("localhost").build();
CasserSession session = Casser.connect(cluster).use("test").add(user).autoUpdate().get();
public static User mapUser(final Fun.Tuple2<String, Integer> t) {
return new User() {
@Override
public Long id() {
return null;
}
@Override
public String name() {
return t._1;
}
@Override
public Integer age() {
return t._2;
}
};
}
public static class UserImpl implements User {
Long id;
String name;
Integer age;
@Override
public Long id() {
return id;
}
@Override
public String name() {
return name;
}
@Override
public Integer age() {
return age;
}
}
public void test() {
UserImpl newUser = new UserImpl();
newUser.id = 100L;
newUser.name = "alex";
newUser.age = 34;
session.upsert(newUser);
String nameAndAge = session.select(user::name, user::age).where(user::id, eq(100L)).sync().findFirst().map(t -> {
return t._1 + ":" + t._2;
}).get();
User userTmp = session.select(user::name, user::age).where(user::id, eq(100L)).map(Example::mapUser).sync().findFirst().get();
session.update(user::age, 10).where(user::id, eq(100L)).async();
session.delete(User.class).where(user::id, eq(100L)).async();
PreparedStreamOperation<Tuple1<String>> ps = session.select(user::name).where(user::id, Operator.EQ, null).prepare();
long cnt = ps.bind(100L).sync().count();
cnt = session.select(user::name).where(user::id, eq(100L)).count().sync();
cnt = session.select(user::name).where(user::id, eq(100L)).count().sync();
}
}

View file

@ -1,29 +0,0 @@
/*
* Copyright (C) 2015 Noorq, Inc.
*
* 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 com.noorq.casser;
import com.noorq.casser.mapping.annotation.Table;
@Table("user")
public interface User {
Long id();
String name();
Integer age();
}