Skip to content

Commit 65dd9db

Browse files
committed
Fix imports and trailing spaces.
1 parent eed7f7b commit 65dd9db

10 files changed

Lines changed: 99 additions & 125 deletions

File tree

driver-core/src/main/java/com/datastax/driver/core/DataType.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.google.common.base.Objects;
2828
import com.google.common.collect.ImmutableList;
2929
import com.google.common.collect.ImmutableSet;
30-
3130
import org.jboss.netty.buffer.ChannelBuffer;
3231

3332
import com.datastax.driver.core.exceptions.DriverInternalError;
@@ -391,7 +390,7 @@ public static DataType custom(String typeClassName) {
391390

392391
/**
393392
* Returns a User Defined Type (UDT).
394-
*
393+
*
395394
* @param definition the description of the type's keyspace, name and fields.
396395
* @return the UDT defined by {@code definition}.
397396
*/
@@ -401,19 +400,19 @@ public static DataType userType(UDTDefinition definition) {
401400

402401
/**
403402
* Returns the appropriate data type to map a Java field.
404-
*
403+
*
405404
* @param f the field to map.
406405
* @return the corresponding data type.
407406
*/
408407
public static DataType of(Field f) {
409408
Type type = f.getGenericType();
410-
409+
411410
if (type instanceof ParameterizedType) {
412411
ParameterizedType pt = (ParameterizedType)type;
413412
Type raw = pt.getRawType();
414413
if (!(raw instanceof Class))
415414
throw new IllegalArgumentException(String.format("Cannot map class %s for field %s", type, f.getName()));
416-
415+
417416
Class<?> klass = (Class<?>)raw;
418417
if (List.class.isAssignableFrom(klass)) {
419418
return list(DataType.of(Reflection.getParam(pt, 0, f.getName()), f));
@@ -426,10 +425,10 @@ public static DataType of(Field f) {
426425
}
427426
throw new IllegalArgumentException(String.format("Cannot map class %s for field %s", type, f.getName()));
428427
}
429-
428+
430429
if (!(type instanceof Class))
431430
throw new IllegalArgumentException(String.format("Cannot map class %s for field %s", type, f.getName()));
432-
431+
433432
return DataType.of((Class<?>)type, f);
434433
}
435434

@@ -441,15 +440,15 @@ public static DataType of(Field f) {
441440
* (for example {@code String} in {@code List<String>}), otherwise use
442441
* {@link #of(Field)}.
443442
* </p>
444-
*
443+
*
445444
* @param klass the Java type to map.
446445
* @param f the Java field in which the type is used.
447446
* @return the corresponding data type.
448447
*/
449448
public static DataType of(Class<?> klass, Field f) {
450449
if (ByteBuffer.class.isAssignableFrom(klass))
451450
return blob();
452-
451+
453452
if (klass == int.class || Integer.class.isAssignableFrom(klass))
454453
return cint();
455454
if (klass == long.class || Long.class.isAssignableFrom(klass))
@@ -460,12 +459,12 @@ public static DataType of(Class<?> klass, Field f) {
460459
return cdouble();
461460
if (klass == boolean.class || Boolean.class.isAssignableFrom(klass))
462461
return cboolean();
463-
462+
464463
if (BigDecimal.class.isAssignableFrom(klass))
465464
return decimal();
466465
if (BigInteger.class.isAssignableFrom(klass))
467466
return decimal();
468-
467+
469468
if (String.class.isAssignableFrom(klass))
470469
return text();
471470
if (InetAddress.class.isAssignableFrom(klass))
@@ -474,10 +473,10 @@ public static DataType of(Class<?> klass, Field f) {
474473
return timestamp();
475474
if (UUID.class.isAssignableFrom(klass))
476475
return uuid();
477-
476+
478477
if (Collection.class.isAssignableFrom(klass))
479478
throw new IllegalArgumentException(String.format("Cannot map non-parametrized collection type %s for field %s; Please use a concrete type parameter", klass.getName(), f.getName()));
480-
479+
481480
throw new IllegalArgumentException(String.format("Cannot map unknow class %s for field %s", klass.getName(), f));
482481
}
483482

@@ -598,7 +597,7 @@ public ByteBuffer serialize(Object value) {
598597

599598
/**
600599
* Serialize a value of this type to bytes, with the given protocol version.
601-
*
600+
*
602601
* @param value the value to serialize.
603602
* @param protocolVersion the protocol version.
604603
* @return the value serialized, or {@code null} if {@code value} is null.
@@ -611,14 +610,14 @@ public ByteBuffer serialize(Object value, int protocolVersion) {
611610
Class<?> expectedClass = asJavaClass();
612611
if (!expectedClass.isAssignableFrom(providedClass))
613612
throw new InvalidTypeException(String.format("Invalid value for CQL type %s, expecting %s but %s provided", toString(), expectedClass, providedClass));
614-
613+
615614
try {
616615
return codec(protocolVersion).serialize(value);
617616
} catch (ClassCastException e) {
618617
// With collections, the element type has not been checked, so it can throw
619618
throw new InvalidTypeException("Invalid type for collection element: " + e.getMessage());
620619
}
621-
}
620+
}
622621

623622
/**
624623
* Deserialize a value of this type from the provided bytes.
@@ -646,17 +645,17 @@ public Object deserialize(ByteBuffer bytes) {
646645

647646
/**
648647
* Deserialize a value of this type from the provided bytes, with the given protocol version.
649-
*
648+
*
650649
* @param bytes bytes holding the value to deserialize.
651650
* @param protocolVersion the protocol version.
652651
* @return the deserialized value (of class {@code this.asJavaClass()}).
653-
*
652+
*
654653
* @see #deserialize(ByteBuffer)
655654
*/
656655
public Object deserialize(ByteBuffer bytes, int protocolVersion) {
657656
return codec(protocolVersion).deserialize(bytes);
658657
}
659-
658+
660659
/**
661660
* Serialize an object based on its java class.
662661
* <p>

driver-core/src/main/java/com/datastax/driver/core/TypeCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static DataType getDataTypeFor(Object value) {
200200
? null
201201
: DataType.map(keyType, valueType);
202202
}
203-
203+
204204
if (value instanceof UDTValue) {
205205
return DataType.userType(((UDTValue) value).getDefinition());
206206
}

driver-core/src/main/java/com/datastax/driver/core/utils/Reflection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
public class Reflection {
1111

1212
/**
13-
* Gets a type argument from a parameterized type.
14-
*
13+
* Gets a type argument from a parameterized type.
14+
*
1515
* @param pt the parameterized type.
1616
* @param arg the index of the argument to retrieve.
1717
* @param name the name of the element (field or method argument).

driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ public static <T> EntityMapper<T> parseEntity(Class<T> entityClass, EntityMapper
7474
convert(rgs, factory, mapper.entityClass, mappingManager));
7575
return mapper;
7676
}
77-
77+
7878
public static <T> EntityMapper<T> parseNested(Class<T> nestedClass, EntityMapper.Factory factory, MappingManager mappingManager) {
7979
UserDefinedType udt = nestedClass.getAnnotation(UserDefinedType.class);
8080
if (udt == null)
81-
throw new IllegalArgumentException(String.format("@%s annotation was not found on class %s", UserDefinedType.class.getSimpleName(), nestedClass.getName()));
81+
throw new IllegalArgumentException(String.format("@%s annotation was not found on class %s", UserDefinedType.class.getSimpleName(), nestedClass.getName()));
8282

8383
String ksName = udt.caseSensitiveKeyspace() ? udt.keyspace() : udt.keyspace().toLowerCase();
8484
String udtName = udt.caseSensitiveType() ? udt.name() : udt.name().toLowerCase();
85-
85+
8686
EntityMapper<T> mapper = factory.create(nestedClass, ksName, udtName, null, null);
87-
87+
8888
List<Field> columns = new ArrayList<Field>();
89-
89+
9090
for (Field field : nestedClass.getDeclaredFields()) {
9191
if (field.getAnnotation(Transient.class) != null)
9292
continue;
@@ -214,7 +214,7 @@ public static <T> AccessorMapper<T> parseAccessor(Class<T> accClass, AccessorMap
214214

215215
return factory.create(accClass, methods);
216216
}
217-
217+
218218
@SuppressWarnings({ "unchecked", "rawtypes" })
219219
private static ParamMapper newParamMapper(String className, String methodName, String paramName, Type paramType, Annotation[] paramAnnotations, MappingManager mappingManager) {
220220
// TODO support enums
@@ -225,7 +225,7 @@ private static ParamMapper newParamMapper(String className, String methodName, S
225225
NestedMapper<?> nestedMapper = mappingManager.getNestedMapper(paramClass);
226226
return new UDTParamMapper(paramName, nestedMapper);
227227
}
228-
return new ParamMapper(paramName);
228+
return new ParamMapper(paramName);
229229
} if (paramType instanceof ParameterizedType) {
230230
ParameterizedType pt = (ParameterizedType) paramType;
231231
Type raw = pt.getRawType();
@@ -239,7 +239,7 @@ private static ParamMapper newParamMapper(String className, String methodName, S
239239
}
240240
if (Set.class.isAssignableFrom(klass) && firstTypeParam.isAnnotationPresent(UserDefinedType.class)) {
241241
NestedMapper<?> valueMapper = mappingManager.getNestedMapper(firstTypeParam);
242-
return new UDTSetParamMapper(paramName, valueMapper);
242+
return new UDTSetParamMapper(paramName, valueMapper);
243243
}
244244
if (Map.class.isAssignableFrom(klass)) {
245245
Class<?> secondTypeParam = Reflection.getParam(pt, 1, paramName);
@@ -249,7 +249,7 @@ private static ParamMapper newParamMapper(String className, String methodName, S
249249
return new UDTMapParamMapper(paramName, keyMapper, valueMapper);
250250
}
251251
}
252-
return new ParamMapper(paramName);
252+
return new ParamMapper(paramName);
253253
} else {
254254
throw new IllegalArgumentException(String.format("Cannot map class %s for parameter %s of %s.%s", paramType, paramName, className, methodName));
255255
}

driver-mapping/src/main/java/com/datastax/driver/mapping/EntityMapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.*;
55

66
import com.datastax.driver.core.ConsistencyLevel;
7-
87
import static com.datastax.driver.core.querybuilder.QueryBuilder.quote;
98

109
abstract class EntityMapper<T> {
@@ -55,10 +54,10 @@ public void addColumns(List<ColumnMapper<T>> pks, List<ColumnMapper<T>> ccs, Lis
5554

5655
addColumns(rgs);
5756
}
58-
57+
5958
public void addColumns(List<ColumnMapper<T>> rgs) {
6059
regularColumns.addAll(rgs);
61-
allColumns.addAll(rgs);
60+
allColumns.addAll(rgs);
6261
}
6362

6463
public abstract T newEntity();
@@ -69,6 +68,6 @@ public List<ColumnMapper<T>> allColumns() {
6968

7069
interface Factory {
7170
public <T> EntityMapper<T> create(Class<T> entityClass, String keyspace, String table, ConsistencyLevel writeConsistency, ConsistencyLevel readConsistency);
72-
public <T> ColumnMapper<T> createColumnMapper(Class<T> componentClass, Field field, int position, MappingManager mappingManager);
71+
public <T> ColumnMapper<T> createColumnMapper(Class<T> componentClass, Field field, int position, MappingManager mappingManager);
7372
}
7473
}

driver-mapping/src/main/java/com/datastax/driver/mapping/MappingManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private <T> Mapper<T> getMapper(Class<T> klass) {
9191
}
9292
return mapper;
9393
}
94-
94+
9595
@SuppressWarnings("unchecked")
9696
<T> NestedMapper<T> getNestedMapper(Class<T> klass) {
9797
NestedMapper<T> mapper = (NestedMapper<T>)nestedMappers.get(klass);
@@ -107,7 +107,7 @@ <T> NestedMapper<T> getNestedMapper(Class<T> klass) {
107107
}
108108
}
109109
}
110-
return mapper;
110+
return mapper;
111111
}
112112

113113
@SuppressWarnings("unchecked")

driver-mapping/src/main/java/com/datastax/driver/mapping/MethodMapper.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,11 @@
77
import java.util.Map;
88
import java.util.Set;
99

10-
import com.datastax.driver.core.BoundStatement;
11-
import com.datastax.driver.core.ConsistencyLevel;
12-
import com.datastax.driver.core.DataType;
13-
import com.datastax.driver.core.PreparedStatement;
14-
import com.datastax.driver.core.ResultSet;
15-
import com.datastax.driver.core.ResultSetFuture;
16-
import com.datastax.driver.core.Session;
17-
import com.datastax.driver.core.Statement;
1810
import com.google.common.util.concurrent.Futures;
1911
import com.google.common.util.concurrent.ListenableFuture;
2012

13+
import com.datastax.driver.core.*;
14+
2115
// TODO: we probably should make that an abstract class and move some bit in a "ReflexionMethodMapper"
2216
// subclass for consistency with the rest, but we can see to that later
2317
class MethodMapper {
@@ -146,7 +140,7 @@ public Object invoke(Object[] args) {
146140
return mapOne ? result.one() : result;
147141
}
148142
}
149-
143+
150144
static class ParamMapper {
151145
private final String paramName;
152146

@@ -160,65 +154,65 @@ void setValue(BoundStatement boundStatement, Object arg) {
160154
}
161155
}
162156
}
163-
157+
164158
static class UDTParamMapper<V> extends ParamMapper {
165159
private final NestedMapper<V> nestedMapper;
166160

167161
UDTParamMapper(String paramName, NestedMapper<V> nestedMapper) {
168162
super(paramName);
169163
this.nestedMapper = nestedMapper;
170164
}
171-
165+
172166
@Override
173167
void setValue(BoundStatement boundStatement, Object arg) {
174168
@SuppressWarnings("unchecked")
175169
V entity = (V) arg;
176170
super.setValue(boundStatement, nestedMapper.toUDTValue(entity));
177171
}
178172
}
179-
173+
180174
static class UDTListParamMapper<V> extends ParamMapper {
181175
private final NestedMapper<V> valueMapper;
182176

183177
UDTListParamMapper(String paramName, NestedMapper<V> valueMapper) {
184178
super(paramName);
185179
this.valueMapper = valueMapper;
186180
}
187-
181+
188182
@Override
189183
void setValue(BoundStatement boundStatement, Object arg) {
190184
@SuppressWarnings("unchecked")
191185
List<V> nestedEntities = (List<V>) arg;
192186
super.setValue(boundStatement, valueMapper.toUDTValues(nestedEntities));
193187
}
194188
}
195-
189+
196190
static class UDTSetParamMapper<V> extends ParamMapper {
197191
private final NestedMapper<V> valueMapper;
198-
192+
199193
UDTSetParamMapper(String paramName, NestedMapper<V> valueMapper) {
200194
super(paramName);
201195
this.valueMapper = valueMapper;
202196
}
203-
197+
204198
@Override
205199
void setValue(BoundStatement boundStatement, Object arg) {
206200
@SuppressWarnings("unchecked")
207201
Set<V> nestedEntities = (Set<V>) arg;
208202
super.setValue(boundStatement, valueMapper.toUDTValues(nestedEntities));
209203
}
210204
}
211-
205+
212206
static class UDTMapParamMapper<K, V> extends ParamMapper {
213207
private final NestedMapper<K> keyMapper;
214208
private final NestedMapper<V> valueMapper;
215-
209+
216210
UDTMapParamMapper(String paramName, NestedMapper<K> keyMapper, NestedMapper<V> valueMapper) {
217211
super(paramName);
218212
this.keyMapper = keyMapper;
219213
this.valueMapper = valueMapper;
220214
}
221-
215+
222216
@Override
223217
void setValue(BoundStatement boundStatement, Object arg) {
224218
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)