Elffuss BraidHub

kikocis/java-driver public

56ea1f21527e · 1.7 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
18
19import java.lang.annotation.ElementType;
20import com.datastax.driver.mapping.Mapper;
21import java.lang.annotation.Retention;
22import java.lang.annotation.RetentionPolicy;
23import java.lang.annotation.Target;
24
25/**
26 * Annotates a "computed" field, which gets filled from a CQL expression in the SELECT query
27 * used to retrieve an entity.
28 * <p>
29 * Note that such fields are only filled by default mapper operations ({@link Mapper#get(Object...)}),
30 * they will be ignored in accessor queries and save operations.
31 * <p>
32 * As opposed to other mapper annotation, this one doesn't handle case sensitivity. If your expression
33 * contains case-sensitive names, you'll need to quote them explicitly:
34 * <pre>
35 * {@code @Computed("\"caseSensitiveFunction\"(v)")}
36 * </pre>
37 */
38@Target(ElementType.FIELD)
39@Retention(RetentionPolicy.RUNTIME)
40public @interface Computed {
41 /**
42 * The formula used to compute the field.
43 * <p>
44 * This is a CQL expression like you would use directly in a query, for instance
45 * "writetime(v)".
46 *
47 * @return the formula.
48 */
49 String value();
50}