com.google.gwt.inject.rebind.reflect
Class FieldLiteral<T>

java.lang.Object
  extended by com.google.gwt.inject.rebind.reflect.MemberLiteral<T,java.lang.reflect.Field>
      extended by com.google.gwt.inject.rebind.reflect.FieldLiteral<T>

public class FieldLiteral<T>
extends MemberLiteral<T,java.lang.reflect.Field>

Generic field representation preserving the fields type parametrization.

See Also:
TypeLiteral

Method Summary
static
<T> FieldLiteral<T>
get(java.lang.reflect.Field field, TypeLiteral<T> declaringType)
          Returns a new field literal based on the passed field and its declaring type.
 TypeLiteral<?> getFieldType()
          Returns the field's type, if appropriate parametrized with the declaring class's type parameters.
 boolean isLegacyFinalField()
          Returns true if this is a final field that past versions of Gin allowed to be set by member injection.
 java.lang.String toString()
          Returns the field's declaring type and name in the format used in javadoc, e.g.
 
Methods inherited from class com.google.gwt.inject.rebind.reflect.MemberLiteral
getAnnotation, getAnnotations, getBindingAnnotation, getBindingAnnotation, getDeclaringType, getMember, getModifiers, getName, getRawDeclaringType, isAnnotationPresent, isDefaultAccess, isPrivate, isPublic, isStatic
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public static <T> FieldLiteral<T> get(java.lang.reflect.Field field,
                                      TypeLiteral<T> declaringType)
Returns a new field literal based on the passed field and its declaring type.

Parameters:
field - field for which the literal is created
declaringType - the field's declaring type
Returns:
new field literal

getFieldType

public TypeLiteral<?> getFieldType()
Returns the field's type, if appropriate parametrized with the declaring class's type parameters.

Returns:
field type

isLegacyFinalField

public boolean isLegacyFinalField()
Returns true if this is a final field that past versions of Gin allowed to be set by member injection.

Past versions of Gin used native Javascript to set the values of inaccessible fields. If those fields also happened to be final, the native code would ignore the final modifier and assign the field anyway.

As I (dburrows) don't feel that this is something to encourage, I'm narrowly allowing this usage only in cases where to do otherwise would break previously compiling code. It might be prudent to remove this exclusion in the future, but not as part of my current work.


toString

public java.lang.String toString()
Returns the field's declaring type and name in the format used in javadoc, e.g. com.bar.Foo#baz, with resolved type parameters.

Overrides:
toString in class java.lang.Object
Returns:
string representation for this method including the declaring type