Elffuss BraidHub

kikocis/java-driver public

3cd7eb6efc56 · 2.3 KiBRawPermalink
1/*
2 * Copyright (C) 2012-2015 DataStax Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.datastax.driver.mapping.annotations;
17
18import com.datastax.driver.core.TypeCodec;
19
20import java.lang.annotation.ElementType;
21import java.lang.annotation.Retention;
22import java.lang.annotation.RetentionPolicy;
23import java.lang.annotation.Target;
24
25/**
26 * Annotation that allows to specify the name of the CQL column to which the
27 * field should be mapped.
28 * <p/>
29 * Note that this annotation is generally optional in the sense that any field
30 * of a class annotated by {@link Table} will be mapped by default to a column
31 * having the same name than this field unless that field has the
32 * {@link Transient} annotation. As such, this annotation is mainly useful when
33 * the name to map the field to is not the same one that the field itself (but
34 * can be added without it's name parameter for documentation sake).
35 */
36@Target(ElementType.FIELD)
37@Retention(RetentionPolicy.RUNTIME)
38public @interface Column {
39 /**
40 * Name of the column being mapped in Cassandra. By default, the name of the
41 * field will be used.
42 *
43 * @return the name of the mapped column in Cassandra, or {@code ""} to use
44 * the field name.
45 */
46 String name() default "";
47
48 /**
49 * Whether the column name is a case sensitive one.
50 *
51 * @return whether the column name is a case sensitive one.
52 */
53 boolean caseSensitive() default false;
54
55 /**
56 * A custom codec that will be used to serialize and deserialize the column.
57 *
58 * @return the codec's class. It must have a no-argument constructor (the mapper
59 * will create an instance and cache it).
60 */
61 Class<? extends TypeCodec<?>> codec() default Defaults.NoCodec.class;
62}