refactor tuples and mappers

This commit is contained in:
Albert Shift 2015-04-16 17:18:20 -07:00
parent 862804a225
commit 28b2186854
12 changed files with 469 additions and 588 deletions

View file

@ -22,8 +22,8 @@ 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.core.tuple.Tuple1;
import com.noorq.casser.core.tuple.Tuple2;
import com.noorq.casser.core.tuple.Fun;
import com.noorq.casser.core.tuple.Fun.Tuple1;
public class Example {
@ -33,7 +33,7 @@ public class Example {
CasserSession session = Casser.connect(cluster).use("test").add(user).autoUpdate().get();
public static User mapUser(final Tuple2<String, Integer> t) {
public static User mapUser(final Fun.Tuple2<String, Integer> t) {
return new User() {

View file

@ -30,13 +30,11 @@ import com.noorq.casser.core.operation.InsertOperation;
import com.noorq.casser.core.operation.SelectOperation;
import com.noorq.casser.core.operation.UpdateOperation;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.core.tuple.Tuple1;
import com.noorq.casser.core.tuple.Tuple2;
import com.noorq.casser.core.tuple.Tuple3;
import com.noorq.casser.core.tuple.Tuple4;
import com.noorq.casser.core.tuple.Tuple5;
import com.noorq.casser.core.tuple.Tuple6;
import com.noorq.casser.core.tuple.Tuple7;
import com.noorq.casser.core.tuple.Fun;
import com.noorq.casser.core.tuple.Fun.Tuple1;
import com.noorq.casser.core.tuple.Fun.Tuple2;
import com.noorq.casser.core.tuple.Fun.Tuple6;
import com.noorq.casser.core.tuple.Mappers;
import com.noorq.casser.mapping.CasserEntity;
import com.noorq.casser.mapping.MappingUtil;
import com.noorq.casser.mapping.value.ColumnValuePreparer;
@ -130,11 +128,11 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
return new SelectOperation<E>(this, Casser.entity(entityClass), rowMapper);
}
public <V1> SelectOperation<Tuple1<V1>> select(Getter<V1> getter1) {
public <V1> SelectOperation<Fun.Tuple1<V1>> select(Getter<V1> getter1) {
Objects.requireNonNull(getter1, "field 1 is empty");
CasserPropertyNode p1 = MappingUtil.resolveMappingProperty(getter1);
return new SelectOperation<Tuple1<V1>>(this, new Tuple1.Mapper<V1>(getValueProvider(), p1), p1);
return new SelectOperation<Tuple1<V1>>(this, new Mappers.Mapper1<V1>(getValueProvider(), p1), p1);
}
public <V1, V2> SelectOperation<Tuple2<V1, V2>> select(Getter<V1> getter1, Getter<V2> getter2) {
@ -143,10 +141,10 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
CasserPropertyNode p1 = MappingUtil.resolveMappingProperty(getter1);
CasserPropertyNode p2 = MappingUtil.resolveMappingProperty(getter2);
return new SelectOperation<Tuple2<V1, V2>>(this, new Tuple2.Mapper<V1, V2>(getValueProvider(), p1, p2), p1, p2);
return new SelectOperation<Fun.Tuple2<V1, V2>>(this, new Mappers.Mapper2<V1, V2>(getValueProvider(), p1, p2), p1, p2);
}
public <V1, V2, V3> SelectOperation<Tuple3<V1, V2, V3>> select(Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3) {
public <V1, V2, V3> SelectOperation<Fun.Tuple3<V1, V2, V3>> select(Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3) {
Objects.requireNonNull(getter1, "field 1 is empty");
Objects.requireNonNull(getter2, "field 2 is empty");
Objects.requireNonNull(getter3, "field 3 is empty");
@ -154,10 +152,10 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
CasserPropertyNode p1 = MappingUtil.resolveMappingProperty(getter1);
CasserPropertyNode p2 = MappingUtil.resolveMappingProperty(getter2);
CasserPropertyNode p3 = MappingUtil.resolveMappingProperty(getter3);
return new SelectOperation<Tuple3<V1, V2, V3>>(this, new Tuple3.Mapper<V1, V2, V3>(getValueProvider(), p1, p2, p3), p1, p2, p3);
return new SelectOperation<Fun.Tuple3<V1, V2, V3>>(this, new Mappers.Mapper3<V1, V2, V3>(getValueProvider(), p1, p2, p3), p1, p2, p3);
}
public <V1, V2, V3, V4> SelectOperation<Tuple4<V1, V2, V3, V4>> select(
public <V1, V2, V3, V4> SelectOperation<Fun.Tuple4<V1, V2, V3, V4>> select(
Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3, Getter<V4> getter4) {
Objects.requireNonNull(getter1, "field 1 is empty");
Objects.requireNonNull(getter2, "field 2 is empty");
@ -168,10 +166,10 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
CasserPropertyNode p2 = MappingUtil.resolveMappingProperty(getter2);
CasserPropertyNode p3 = MappingUtil.resolveMappingProperty(getter3);
CasserPropertyNode p4 = MappingUtil.resolveMappingProperty(getter4);
return new SelectOperation<Tuple4<V1, V2, V3, V4>>(this, new Tuple4.Mapper<V1, V2, V3, V4>(getValueProvider(), p1, p2, p3, p4), p1, p2, p3, p4);
return new SelectOperation<Fun.Tuple4<V1, V2, V3, V4>>(this, new Mappers.Mapper4<V1, V2, V3, V4>(getValueProvider(), p1, p2, p3, p4), p1, p2, p3, p4);
}
public <V1, V2, V3, V4, V5> SelectOperation<Tuple5<V1, V2, V3, V4, V5>> select(
public <V1, V2, V3, V4, V5> SelectOperation<Fun.Tuple5<V1, V2, V3, V4, V5>> select(
Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3, Getter<V4> getter4, Getter<V5> getter5) {
Objects.requireNonNull(getter1, "field 1 is empty");
Objects.requireNonNull(getter2, "field 2 is empty");
@ -184,12 +182,12 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
CasserPropertyNode p3 = MappingUtil.resolveMappingProperty(getter3);
CasserPropertyNode p4 = MappingUtil.resolveMappingProperty(getter4);
CasserPropertyNode p5 = MappingUtil.resolveMappingProperty(getter5);
return new SelectOperation<Tuple5<V1, V2, V3, V4, V5>>(this,
new Tuple5.Mapper<V1, V2, V3, V4, V5>(getValueProvider(), p1, p2, p3, p4, p5),
return new SelectOperation<Fun.Tuple5<V1, V2, V3, V4, V5>>(this,
new Mappers.Mapper5<V1, V2, V3, V4, V5>(getValueProvider(), p1, p2, p3, p4, p5),
p1, p2, p3, p4, p5);
}
public <V1, V2, V3, V4, V5, V6> SelectOperation<Tuple6<V1, V2, V3, V4, V5, V6>> select(
public <V1, V2, V3, V4, V5, V6> SelectOperation<Fun.Tuple6<V1, V2, V3, V4, V5, V6>> select(
Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3,
Getter<V4> getter4, Getter<V5> getter5, Getter<V6> getter6) {
Objects.requireNonNull(getter1, "field 1 is empty");
@ -206,11 +204,11 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
CasserPropertyNode p5 = MappingUtil.resolveMappingProperty(getter5);
CasserPropertyNode p6 = MappingUtil.resolveMappingProperty(getter6);
return new SelectOperation<Tuple6<V1, V2, V3, V4, V5, V6>>(this,
new Tuple6.Mapper<V1, V2, V3, V4, V5, V6>(getValueProvider(), p1, p2, p3, p4, p5, p6),
new Mappers.Mapper6<V1, V2, V3, V4, V5, V6>(getValueProvider(), p1, p2, p3, p4, p5, p6),
p1, p2, p3, p4, p5, p6);
}
public <V1, V2, V3, V4, V5, V6, V7> SelectOperation<Tuple7<V1, V2, V3, V4, V5, V6, V7>> select(
public <V1, V2, V3, V4, V5, V6, V7> SelectOperation<Fun.Tuple7<V1, V2, V3, V4, V5, V6, V7>> select(
Getter<V1> getter1, Getter<V2> getter2, Getter<V3> getter3,
Getter<V4> getter4, Getter<V5> getter5, Getter<V6> getter6,
Getter<V7> getter7) {
@ -229,8 +227,8 @@ public class CasserSession extends AbstractSessionOperations implements Closeabl
CasserPropertyNode p5 = MappingUtil.resolveMappingProperty(getter5);
CasserPropertyNode p6 = MappingUtil.resolveMappingProperty(getter6);
CasserPropertyNode p7 = MappingUtil.resolveMappingProperty(getter7);
return new SelectOperation<Tuple7<V1, V2, V3, V4, V5, V6, V7>>(this,
new Tuple7.Mapper<V1, V2, V3, V4, V5, V6, V7>(
return new SelectOperation<Fun.Tuple7<V1, V2, V3, V4, V5, V6, V7>>(this,
new Mappers.Mapper7<V1, V2, V3, V4, V5, V6, V7>(
getValueProvider(),
p1, p2, p3, p4, p5, p6, p7),
p1, p2, p3, p4, p5, p6, p7);

View file

@ -27,7 +27,8 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.noorq.casser.core.AbstractSessionOperations;
import com.noorq.casser.core.Getter;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.core.tuple.Tuple2;
import com.noorq.casser.core.tuple.Fun;
import com.noorq.casser.core.tuple.Fun.Tuple2;
import com.noorq.casser.mapping.CasserEntity;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.MappingUtil;
@ -38,7 +39,7 @@ public final class InsertOperation extends AbstractOperation<ResultSet, InsertOp
private CasserEntity entity;
private final List<Tuple2<CasserPropertyNode, Object>> values = new ArrayList<Tuple2<CasserPropertyNode, Object>>();
private final List<Fun.Tuple2<CasserPropertyNode, Object>> values = new ArrayList<Fun.Tuple2<CasserPropertyNode, Object>>();
private boolean ifNotExists;
private int[] ttl;

View file

@ -0,0 +1,206 @@
/*
* 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.core.tuple;
public final class Fun {
private Fun() {
}
public final static class Tuple1<A> {
public final A _1;
public Tuple1(A v1) {
this._1 = v1;
}
public static <A> Tuple1<A> of(A _1) {
return new Tuple1<A>(_1);
}
@Override
public String toString() {
return "Tuple1 [_1=" + _1 + "]";
}
}
public final static class Tuple2<A, B> {
public final A _1;
public final B _2;
public Tuple2(A v1, B v2) {
this._1 = v1;
this._2 = v2;
}
public static <A, B> Tuple2<A, B> of(A _1, B _2) {
return new Tuple2<A, B>(_1, _2);
}
@Override
public String toString() {
return "Tuple2 [_1=" + _1 + ", _2=" + _2 + "]";
}
}
public final static class Tuple3<A, B, C> {
public final A _1;
public final B _2;
public final C _3;
public Tuple3(A v1, B v2, C v3) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
}
public static <A, B, C> Tuple3<A, B, C> of(A _1, B _2, C _3) {
return new Tuple3<A, B, C>(_1, _2, _3);
}
@Override
public String toString() {
return "Tuple3 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + "]";
}
}
public final static class Tuple4<A, B, C, D> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public Tuple4(A v1, B v2, C v3, D v4) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
}
public static <A, B, C, D> Tuple4<A, B, C, D> of(A _1, B _2, C _3, D _4) {
return new Tuple4<A, B, C, D>(_1, _2, _3, _4);
}
@Override
public String toString() {
return "Tuple4 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ "]";
}
}
public final static class Tuple5<A, B, C, D, E> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public final E _5;
public Tuple5(A v1, B v2, C v3, D v4, E v5) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
this._5 = v5;
}
public static <A, B, C, D, E> Tuple5<A, B, C, D, E> of(A _1, B _2, C _3, D _4, E _5) {
return new Tuple5<A, B, C, D, E>(_1, _2, _3, _4, _5);
}
@Override
public String toString() {
return "Tuple5 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ ", _5=" + _5 + "]";
}
}
public final static class Tuple6<A, B, C, D, E, F> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public final E _5;
public final F _6;
public Tuple6(A v1, B v2, C v3, D v4, E v5, F v6) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
this._5 = v5;
this._6 = v6;
}
public static <A, B, C, D, E, F> Tuple6<A, B, C, D, E, F> of(A _1, B _2, C _3, D _4, E _5, F _6) {
return new Tuple6<A, B, C, D, E, F>(_1, _2, _3, _4, _5, _6);
}
@Override
public String toString() {
return "Tuple6 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ ", _5=" + _5 + ", _6=" + _6 + "]";
}
}
public final static class Tuple7<A, B, C, D, E, F, G> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public final E _5;
public final F _6;
public final G _7;
public Tuple7(A v1, B v2, C v3, D v4, E v5, F v6, G v7) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
this._5 = v5;
this._6 = v6;
this._7 = v7;
}
public static <A, B, C, D, E, F, G> Tuple7<A, B, C, D, E, F, G> of(A _1, B _2, C _3, D _4, E _5, F _6, G _7) {
return new Tuple7<A, B, C, D, E, F, G>(_1, _2, _3, _4, _5, _6, _7);
}
@Override
public String toString() {
return "Tuple7 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ ", _5=" + _5 + ", _6=" + _6 + ", _7=" + _7 + "]";
}
}
}

View file

@ -0,0 +1,237 @@
/*
* 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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Mappers {
private Mappers() {
}
public final static class Mapper1<A> implements Function<Row, Fun.Tuple1<A>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
public Mapper1(ColumnValueProvider provider, CasserPropertyNode p1) {
this.provider = provider;
this.p1 = p1.getProperty();
}
@Override
public Fun.Tuple1<A> apply(Row row) {
return new Fun.Tuple1<A>(provider.getColumnValue(row, 0, p1));
}
}
public final static class Mapper2<A, B> implements Function<Row, Fun.Tuple2<A, B>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
private final CasserProperty p2;
public Mapper2(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
}
@Override
public Fun.Tuple2<A, B> apply(Row row) {
return new Fun.Tuple2<A, B>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2));
}
}
public final static class Mapper3<A, B, C> implements Function<Row, Fun.Tuple3<A, B, C>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
private final CasserProperty p2;
private final CasserProperty p3;
public Mapper3(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
}
@Override
public Fun.Tuple3<A, B, C> apply(Row row) {
return new Fun.Tuple3<A, B, C>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3)
);
}
}
public final static class Mapper4<A, B, C, D> implements Function<Row, Fun.Tuple4<A, B, C, D>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
private final CasserProperty p2;
private final CasserProperty p3;
private final CasserProperty p4;
public Mapper4(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
}
@Override
public Fun.Tuple4<A, B, C, D> apply(Row row) {
return new Fun.Tuple4<A, B, C, D>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4)
);
}
}
public final static class Mapper5<A, B, C, D, E> implements Function<Row, Fun.Tuple5<A, B, C, D, E>> {
private final ColumnValueProvider provider;
private final CasserProperty p1, p2, p3, p4, p5;
public Mapper5(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4,
CasserPropertyNode p5
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
this.p5 = p5.getProperty();
}
@Override
public Fun.Tuple5<A, B, C, D, E> apply(Row row) {
return new Fun.Tuple5<A, B, C, D, E>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4),
provider.getColumnValue(row, 4, p5)
);
}
}
public final static class Mapper6<A, B, C, D, E, F> implements
Function<Row,
Fun.Tuple6<A, B, C, D, E, F>> {
private final ColumnValueProvider provider;
private final CasserProperty p1, p2, p3, p4, p5, p6;
public Mapper6(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4,
CasserPropertyNode p5,
CasserPropertyNode p6
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
this.p5 = p5.getProperty();
this.p6 = p6.getProperty();
}
@Override
public Fun.Tuple6<A, B, C, D, E, F> apply(Row row) {
return new Fun.Tuple6<A, B, C, D, E, F>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4),
provider.getColumnValue(row, 4, p5),
provider.getColumnValue(row, 5, p6)
);
}
}
public final static class Mapper7<A, B, C, D, E, F, G> implements
Function<Row,
Fun.Tuple7<A, B, C, D, E, F, G>> {
private final ColumnValueProvider provider;
private final CasserProperty p1, p2, p3, p4, p5, p6, p7;
public Mapper7(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4,
CasserPropertyNode p5,
CasserPropertyNode p6,
CasserPropertyNode p7
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
this.p5 = p5.getProperty();
this.p6 = p6.getProperty();
this.p7 = p7.getProperty();
}
@Override
public Fun.Tuple7<A, B, C, D, E, F, G> apply(Row row) {
return new Fun.Tuple7<A, B, C, D, E, F, G>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4),
provider.getColumnValue(row, 4, p5),
provider.getColumnValue(row, 5, p6),
provider.getColumnValue(row, 6, p7)
);
}
}
}

View file

@ -1,60 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple1<A> {
public final A _1;
public Tuple1(A v1) {
this._1 = v1;
}
public static <A> Tuple1<A> of(A _1) {
return new Tuple1<A>(_1);
}
public final static class Mapper<A> implements Function<Row, Tuple1<A>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
public Mapper(ColumnValueProvider provider, CasserPropertyNode p1) {
this.provider = provider;
this.p1 = p1.getProperty();
}
@Override
public Tuple1<A> apply(Row row) {
return new Tuple1<A>(provider.getColumnValue(row, 0, p1));
}
}
@Override
public String toString() {
return "Tuple1 [_1=" + _1 + "]";
}
}

View file

@ -1,68 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple2<A, B> {
public final A _1;
public final B _2;
public Tuple2(A v1, B v2) {
this._1 = v1;
this._2 = v2;
}
public static <A, B> Tuple2<A, B> of(A _1, B _2) {
return new Tuple2<A, B>(_1, _2);
}
public final static class Mapper<A, B> implements Function<Row, Tuple2<A, B>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
private final CasserProperty p2;
public Mapper(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
}
@Override
public Tuple2<A, B> apply(Row row) {
return new Tuple2<A, B>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2));
}
}
@Override
public String toString() {
return "Tuple2 [_1=" + _1 + ", _2=" + _2 + "]";
}
}

View file

@ -1,75 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple3<A, B, C> {
public final A _1;
public final B _2;
public final C _3;
public Tuple3(A v1, B v2, C v3) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
}
public static <A, B, C> Tuple3<A, B, C> of(A _1, B _2, C _3) {
return new Tuple3<A, B, C>(_1, _2, _3);
}
public final static class Mapper<A, B, C> implements Function<Row, Tuple3<A, B, C>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
private final CasserProperty p2;
private final CasserProperty p3;
public Mapper(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
}
@Override
public Tuple3<A, B, C> apply(Row row) {
return new Tuple3<A, B, C>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3)
);
}
}
@Override
public String toString() {
return "Tuple3 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + "]";
}
}

View file

@ -1,83 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple4<A, B, C, D> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public Tuple4(A v1, B v2, C v3, D v4) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
}
public static <A, B, C, D> Tuple4<A, B, C, D> of(A _1, B _2, C _3, D _4) {
return new Tuple4<A, B, C, D>(_1, _2, _3, _4);
}
public final static class Mapper<A, B, C, D> implements Function<Row, Tuple4<A, B, C, D>> {
private final ColumnValueProvider provider;
private final CasserProperty p1;
private final CasserProperty p2;
private final CasserProperty p3;
private final CasserProperty p4;
public Mapper(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
}
@Override
public Tuple4<A, B, C, D> apply(Row row) {
return new Tuple4<A, B, C, D>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4)
);
}
}
@Override
public String toString() {
return "Tuple4 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ "]";
}
}

View file

@ -1,85 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple5<A, B, C, D, E> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public final E _5;
public Tuple5(A v1, B v2, C v3, D v4, E v5) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
this._5 = v5;
}
public static <A, B, C, D, E> Tuple5<A, B, C, D, E> of(A _1, B _2, C _3, D _4, E _5) {
return new Tuple5<A, B, C, D, E>(_1, _2, _3, _4, _5);
}
public final static class Mapper<A, B, C, D, E> implements Function<Row, Tuple5<A, B, C, D, E>> {
private final ColumnValueProvider provider;
private final CasserProperty p1, p2, p3, p4, p5;
public Mapper(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4,
CasserPropertyNode p5
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
this.p5 = p5.getProperty();
}
@Override
public Tuple5<A, B, C, D, E> apply(Row row) {
return new Tuple5<A, B, C, D, E>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4),
provider.getColumnValue(row, 4, p5)
);
}
}
@Override
public String toString() {
return "Tuple5 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ ", _5=" + _5 + "]";
}
}

View file

@ -1,93 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple6<A, B, C, D, E, F> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public final E _5;
public final F _6;
public Tuple6(A v1, B v2, C v3, D v4, E v5, F v6) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
this._5 = v5;
this._6 = v6;
}
public static <A, B, C, D, E, F> Tuple6<A, B, C, D, E, F> of(A _1, B _2, C _3, D _4, E _5, F _6) {
return new Tuple6<A, B, C, D, E, F>(_1, _2, _3, _4, _5, _6);
}
public final static class Mapper<A, B, C, D, E, F> implements
Function<Row,
Tuple6<A, B, C, D, E, F>> {
private final ColumnValueProvider provider;
private final CasserProperty p1, p2, p3, p4, p5, p6;
public Mapper(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4,
CasserPropertyNode p5,
CasserPropertyNode p6
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
this.p5 = p5.getProperty();
this.p6 = p6.getProperty();
}
@Override
public Tuple6<A, B, C, D, E, F> apply(Row row) {
return new Tuple6<A, B, C, D, E, F>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4),
provider.getColumnValue(row, 4, p5),
provider.getColumnValue(row, 5, p6)
);
}
}
@Override
public String toString() {
return "Tuple6 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ ", _5=" + _5 + ", _6=" + _6 + "]";
}
}

View file

@ -1,97 +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.core.tuple;
import java.util.function.Function;
import com.datastax.driver.core.Row;
import com.noorq.casser.core.reflect.CasserPropertyNode;
import com.noorq.casser.mapping.CasserProperty;
import com.noorq.casser.mapping.value.ColumnValueProvider;
public final class Tuple7<A, B, C, D, E, F, G> {
public final A _1;
public final B _2;
public final C _3;
public final D _4;
public final E _5;
public final F _6;
public final G _7;
public Tuple7(A v1, B v2, C v3, D v4, E v5, F v6, G v7) {
this._1 = v1;
this._2 = v2;
this._3 = v3;
this._4 = v4;
this._5 = v5;
this._6 = v6;
this._7 = v7;
}
public static <A, B, C, D, E, F, G> Tuple7<A, B, C, D, E, F, G> of(A _1, B _2, C _3, D _4, E _5, F _6, G _7) {
return new Tuple7<A, B, C, D, E, F, G>(_1, _2, _3, _4, _5, _6, _7);
}
public final static class Mapper<A, B, C, D, E, F, G> implements
Function<Row,
Tuple7<A, B, C, D, E, F, G>> {
private final ColumnValueProvider provider;
private final CasserProperty p1, p2, p3, p4, p5, p6, p7;
public Mapper(ColumnValueProvider provider,
CasserPropertyNode p1,
CasserPropertyNode p2,
CasserPropertyNode p3,
CasserPropertyNode p4,
CasserPropertyNode p5,
CasserPropertyNode p6,
CasserPropertyNode p7
) {
this.provider = provider;
this.p1 = p1.getProperty();
this.p2 = p2.getProperty();
this.p3 = p3.getProperty();
this.p4 = p4.getProperty();
this.p5 = p5.getProperty();
this.p6 = p6.getProperty();
this.p7 = p7.getProperty();
}
@Override
public Tuple7<A, B, C, D, E, F, G> apply(Row row) {
return new Tuple7<A, B, C, D, E, F, G>(
provider.getColumnValue(row, 0, p1),
provider.getColumnValue(row, 1, p2),
provider.getColumnValue(row, 2, p3),
provider.getColumnValue(row, 3, p4),
provider.getColumnValue(row, 4, p5),
provider.getColumnValue(row, 5, p6),
provider.getColumnValue(row, 6, p7)
);
}
}
@Override
public String toString() {
return "Tuple7 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4
+ ", _5=" + _5 + ", _6=" + _6 + ", _7=" + _7 + "]";
}
}