| 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.DataType; |
| 19 | |
| 20 | import java.lang.annotation.ElementType; |
| 21 | import java.lang.annotation.Retention; |
| 22 | import java.lang.annotation.RetentionPolicy; |
| 23 | import java.lang.annotation.Target; |
| 24 | |
| 25 | /** |
| 26 | * Specifies that the field decorated with this annotation maps to a CQL type that is {@link DataType#isFrozen() frozen}, |
| 27 | * or contains frozen subtypes. |
| 28 | * <p/> |
| 29 | * This annotation is purely informational at this stage, the validity of the declaration is not checked. |
| 30 | * But will become useful when a schema generation feature is added to the mapper. Therefore it is a good idea to keep |
| 31 | * frozen declarations up-to-date. |
| 32 | * |
| 33 | * @see FrozenKey |
| 34 | * @see FrozenValue |
| 35 | */ |
| 36 | @Target(ElementType.FIELD) |
| 37 | @Retention(RetentionPolicy.RUNTIME) |
| 38 | public @interface Frozen { |
| 39 | |
| 40 | // Implementation note: frozen annotations were previously checked at runtime, this code can be found in version 2.1.7 |
| 41 | |
| 42 | /** |
| 43 | * Contains the full CQL type of the target column. As a convenience, this can be left out when only the top-level |
| 44 | * type is frozen. |
| 45 | * <p/> |
| 46 | * Examples: |
| 47 | * <pre> |
| 48 | * // Will map to frozen<user> |
| 49 | * @Frozen |
| 50 | * private User user; |
| 51 | * |
| 52 | * @Frozen("map<text, map<text, frozen<user>>>") |
| 53 | * private Map<String, Map<String, User>> m; |
| 54 | * </pre> |
| 55 | * <p/> |
| 56 | * Also consider the {@link FrozenKey @FrozenKey} and {@link FrozenValue @FrozenValue} shortcuts for simple collections. |
| 57 | * |
| 58 | * @return the full CQL type of the target column. |
| 59 | */ |
| 60 | String value() default ""; |
| 61 | } |