]>
iEval git - unical.git/blob - gson/com/google/gson/annotations/Until.java
2 * Copyright (C) 2008 Google Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com
.google
.gson
.annotations
;
19 import java
.lang
.annotation
.ElementType
;
20 import java
.lang
.annotation
.Retention
;
21 import java
.lang
.annotation
.RetentionPolicy
;
22 import java
.lang
.annotation
.Target
;
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.
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.
35 * <p>Here is an example of how this annotation is meant to be used:</p>
38 * private String firstName;
39 * private String lastName;
40 * @Until(1.1) private String emailAddress;
41 * @Until(1.1) private String password;
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.
53 * @author Inderjeet Singh
57 @Retention(RetentionPolicy
.RUNTIME
)
58 @Target({ElementType
.FIELD
, ElementType
.TYPE
})
59 public @interface Until
{
62 * the value indicating a version number until this member
63 * or type should be ignored.
This page took 0.048235 seconds and 4 git commands to generate.