| 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 | */ |
| 16 | package com.datastax.driver.mapping.annotations; |
| 17 | |
| 18 | import com.datastax.driver.core.Configuration; |
| 19 | import com.datastax.driver.core.QueryOptions; |
| 20 | |
| 21 | import java.lang.annotation.ElementType; |
| 22 | import java.lang.annotation.Retention; |
| 23 | import java.lang.annotation.RetentionPolicy; |
| 24 | import java.lang.annotation.Target; |
| 25 | |
| 26 | /** |
| 27 | * Query parameters to use in the (generated) implementation of a method of an {@link Accessor} |
| 28 | * interface. |
| 29 | * <p/> |
| 30 | * All the parameters of this annotation are optional, and when not provided default to whatever |
| 31 | * default the {@code Cluster} instance used underneath are (those set in |
| 32 | * {@link Configuration#getQueryOptions}). |
| 33 | */ |
| 34 | @Target(ElementType.METHOD) |
| 35 | @Retention(RetentionPolicy.RUNTIME) |
| 36 | public @interface QueryParameters { |
| 37 | /** |
| 38 | * The consistency level to use for the operation. |
| 39 | * |
| 40 | * @return the consistency level to use for the operation. |
| 41 | */ |
| 42 | String consistency() default ""; |
| 43 | |
| 44 | /** |
| 45 | * The fetch size to use for paging the result of this operation. |
| 46 | * |
| 47 | * @return the fetch size to use for the operation. |
| 48 | */ |
| 49 | int fetchSize() default -1; |
| 50 | |
| 51 | /** |
| 52 | * Whether tracing should be enabled for this operation. |
| 53 | * |
| 54 | * @return whether tracing should be enabled for this operation. |
| 55 | */ |
| 56 | boolean tracing() default false; |
| 57 | |
| 58 | /** |
| 59 | * Whether the operation is idempotent or not. |
| 60 | * <p/> |
| 61 | * When this attribute is set to {@code true} the operation is assumed idempotent; |
| 62 | * when set to {@code false}, it is assumed that it is not. |
| 63 | * <p/> |
| 64 | * If a value of {@code true} or {@code false} is provided, |
| 65 | * the underlying {@link com.datastax.driver.core.Statement} |
| 66 | * will have its {@link com.datastax.driver.core.Statement#setIdempotent(boolean) idempotent flag} |
| 67 | * set accordingly. |
| 68 | * <p/> |
| 69 | * When this attribute is set to its default |
| 70 | * (an empty array), it means that the statement's idempotent flag |
| 71 | * will not be set, and its idempotence will be inferred |
| 72 | * from {@link QueryOptions#getDefaultIdempotence()}. |
| 73 | * <p/> |
| 74 | * This attribute is declared as a boolean array to allow |
| 75 | * for "unset" values, but it can only contain at most |
| 76 | * one element. |
| 77 | * |
| 78 | * @return {@code true} if the operation is idempotent, {@code false} otherwise. |
| 79 | */ |
| 80 | boolean[] idempotent() default {}; |
| 81 | } |