Remove trailing whitespace
[unical.git] / gson / com / google / gson / annotations / Until.java
1 /*
2 * Copyright (C) 2008 Google 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
17 package com.google.gson.annotations;
18
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23
24 /**
25 * An annotation that indicates the version number until a member or a type should be present.
26 * Basically, if Gson is created with a version number that exceeds the value stored in the
27 * {@code Until} annotation then the field will be ignored from the JSON output. This annotation
28 * is useful to manage versioning of your JSON classes for a web-service.
29 *
30 * <p>
31 * This annotation has no effect unless you build {@link com.google.gson.Gson} with a
32 * {@link com.google.gson.GsonBuilder} and invoke
33 * {@link com.google.gson.GsonBuilder#setVersion(double)} method.
34 *
35 * <p>Here is an example of how this annotation is meant to be used:</p>
36 * <pre>
37 * public class User {
38 * private String firstName;
39 * private String lastName;
40 * &#64Until(1.1) private String emailAddress;
41 * &#64Until(1.1) private String password;
42 * }
43 * </pre>
44 *
45 * <p>If you created Gson with {@code new Gson()}, the {@code toJson()} and {@code fromJson()}
46 * methods will use all the fields for serialization and deserialization. However, if you created
47 * Gson with {@code Gson gson = new GsonBuilder().setVersion(1.2).create()} then the
48 * {@code toJson()} and {@code fromJson()} methods of Gson will exclude the {@code emailAddress}
49 * and {@code password} fields from the example above, because the version number passed to the
50 * GsonBuilder, {@code 1.2}, exceeds the version number set on the {@code Until} annotation,
51 * {@code 1.1}, for those fields.
52 *
53 * @author Inderjeet Singh
54 * @author Joel Leitch
55 * @since 1.3
56 */
57 @Retention(RetentionPolicy.RUNTIME)
58 @Target({ElementType.FIELD, ElementType.TYPE})
59 public @interface Until {
60
61 /**
62 * the value indicating a version number until this member
63 * or type should be ignored.
64 */
65 double value();
66 }
This page took 0.021366 seconds and 4 git commands to generate.