Elffuss BraidHub

kikocis/java-driver public

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