X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fcom%2Fgoogle%2Fgson%2FFieldAttributes.java;fp=src%2Fcom%2Fgoogle%2Fgson%2FFieldAttributes.java;h=0000000000000000000000000000000000000000;hb=5c86ae2f45d293408d98a291e826948052d207bc;hp=cb89ff110306bfe6b6e1f12a2884cc2f38656ab1;hpb=5cf4714f0675349ed599707e024cf0e70fe114b2;p=unical.git diff --git a/src/com/google/gson/FieldAttributes.java b/src/com/google/gson/FieldAttributes.java deleted file mode 100644 index cb89ff1..0000000 --- a/src/com/google/gson/FieldAttributes.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.gson; - -import com.google.gson.internal.$Gson$Preconditions; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.Collection; - -/** - * A data object that stores attributes of a field. - * - *
This class is immutable; therefore, it can be safely shared across threads. - * - * @author Inderjeet Singh - * @author Joel Leitch - * - * @since 1.4 - */ -public final class FieldAttributes { - private final Field field; - - /** - * Constructs a Field Attributes object from the {@code f}. - * - * @param f the field to pull attributes from - */ - public FieldAttributes(Field f) { - $Gson$Preconditions.checkNotNull(f); - this.field = f; - } - - /** - * @return the declaring class that contains this field - */ - public Class> getDeclaringClass() { - return field.getDeclaringClass(); - } - - /** - * @return the name of the field - */ - public String getName() { - return field.getName(); - } - - /** - *
For example, assume the following class definition: - *
- * public class Foo { - * private String bar; - * private List<String> red; - * } - * - * Type listParmeterizedType = new TypeToken<List<String>>() {}.getType(); - *- * - *
This method would return {@code String.class} for the {@code bar} field and - * {@code listParameterizedType} for the {@code red} field. - * - * @return the specific type declared for this field - */ - public Type getDeclaredType() { - return field.getGenericType(); - } - - /** - * Returns the {@code Class} object that was declared for this field. - * - *
For example, assume the following class definition: - *
- * public class Foo { - * private String bar; - * private List<String> red; - * } - *- * - *
This method would return {@code String.class} for the {@code bar} field and
- * {@code List.class} for the {@code red} field.
- *
- * @return the specific class object that was declared for the field
- */
- public Class> getDeclaredClass() {
- return field.getType();
- }
-
- /**
- * Return the {@code T} annotation object from this field if it exist; otherwise returns
- * {@code null}.
- *
- * @param annotation the class of the annotation that will be retrieved
- * @return the annotation instance if it is bound to the field; otherwise {@code null}
- */
- public This method is meant to be called as:
- *
- * boolean hasPublicModifier = fieldAttribute.hasModifier(java.lang.reflect.Modifier.PUBLIC);
- *
- *
- * @see java.lang.reflect.Modifier
- */
- public boolean hasModifier(int modifier) {
- return (field.getModifiers() & modifier) != 0;
- }
-
- /**
- * This is exposed internally only for the removing synthetic fields from the JSON output.
- *
- * @return true if the field is synthetic; otherwise false
- * @throws IllegalAccessException
- * @throws IllegalArgumentException
- */
- Object get(Object instance) throws IllegalAccessException {
- return field.get(instance);
- }
-
- /**
- * This is exposed internally only for the removing synthetic fields from the JSON output.
- *
- * @return true if the field is synthetic; otherwise false
- */
- boolean isSynthetic() {
- return field.isSynthetic();
- }
-}