/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * 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.badlogic.gdx.utils.reflect;

import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import com.badlogic.gwtref.client.ReflectionCache;

/** Provides information about, and access to, a single field of a class or interface.
 * @author nexsoftware */
public final class Field {

	private final com.badlogic.gwtref.client.Field field;

	Field (com.badlogic.gwtref.client.Field field) {
		this.field = field;
	}

	/** Returns the name of the field. */
	public String getName () {
		return field.getName();
	}

	/** Returns a Class object that identifies the declared type for the field. */
	public Class getType () {
		return field.getType().getClassOfType();
	}

	/** Returns the Class object representing the class or interface that declares the field. */
	public Class getDeclaringClass () {
		return field.getEnclosingType().getClassOfType();
	}

	public boolean isAccessible () {
		return field.isAccessible();
	}

	public void setAccessible (boolean accessible) {
		field.setAccessible(accessible);
	}

	/** Return true if the field does not include any of the {@code private}, {@code protected}, or {@code public} modifiers. */
	public boolean isDefaultAccess () {
		return !isPrivate() && !isProtected() && !isPublic();
	}

	/** Return true if the field includes the {@code final} modifier. */
	public boolean isFinal () {
		return field.isFinal();
	}

	/** Return true if the field includes the {@code private} modifier. */
	public boolean isPrivate () {
		return field.isPrivate();
	}

	/** Return true if the field includes the {@code protected} modifier. */
	public boolean isProtected () {
		return field.isProtected();
	}

	/** Return true if the field includes the {@code public} modifier. */
	public boolean isPublic () {
		return field.isPublic();
	}

	/** Return true if the field includes the {@code static} modifier. */
	public boolean isStatic () {
		return field.isStatic();
	}

	/** Return true if the field includes the {@code transient} modifier. */
	public boolean isTransient () {
		return field.isTransient();
	}

	/** Return true if the field includes the {@code volatile} modifier. */
	public boolean isVolatile () {
		return field.isVolatile();
	}

	/** Return true if the field is a synthetic field. */
	public boolean isSynthetic () {
		return field.isSynthetic();
	}

	/** If the type of the field is parameterized, returns the Class object representing the parameter type at the specified index,
	 * null otherwise. */
	public Class getElementType (int index) {
		return field.getElementType(index).getClassOfType();
	}

	/** Returns the value of the field on the supplied object. */
	public Object get (Object obj) throws ReflectionException {
		try {
			return field.get(obj);
		} catch (IllegalArgumentException e) {
			throw new ReflectionException("Could not get " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e);
		} catch (IllegalAccessException e) {
			throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e);
		}
	}

	/** Sets the value of the field on the supplied object. */
	public void set (Object obj, Object value) throws ReflectionException {
		try {
			field.set(obj, value);
		} catch (IllegalArgumentException e) {
			throw new ReflectionException("Could not set " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e);
		} catch (IllegalAccessException e) {
			throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e);
		}
	}
}

@@ -3415,30 +3415,42 @@
 index) %7B%0D%0A%09%09
-return
+Type elementType =
  field.getEl
@@ -3465,16 +3465,61 @@
 e(index)
+;%0D%0A%09%09return elementType != null ? elementType
 .getClas
@@ -3519,32 +3519,39 @@
 getClassOfType()
+ : null
 ;%0D%0A%09%7D%0D%0A%0D%0A%09/** Re

Add null check