removed the constructor in FieldAttributes that was only used in tests.

This commit is contained in:
Inderjeet Singh 2011-04-06 00:51:01 +00:00
parent ddb0c8c825
commit 05ae10a144
10 changed files with 15 additions and 24 deletions

View File

@ -55,16 +55,6 @@ public final class FieldAttributes {
private Type genericType;
private Collection<Annotation> annotations;
FieldAttributes(Class<?> declaringClazz, Field f) {
this.declaringClazz = $Gson$Preconditions.checkNotNull(declaringClazz);
this.name = f.getName();
this.declaredType = f.getType();
this.isSynthetic = f.isSynthetic();
this.modifiers = f.getModifiers();
this.field = f;
this.resolvedType = getTypeInfoForField(f, declaringClazz);
}
/**
* Constructs a Field Attributes object from the {@code f}.
*

View File

@ -34,7 +34,8 @@ public class DisjunctionExclusionStrategyTest extends TestCase {
new MockExclusionStrategy(true, true);
private static final Class<?> CLAZZ = String.class;
private static final FieldAttributes FIELD = new FieldAttributes(CLAZZ, CLAZZ.getFields()[0]);
private static final FieldAttributes FIELD =
new FieldAttributes(CLAZZ, CLAZZ.getFields()[0], CLAZZ);
public void testBadInstantiation() throws Exception {
try {

View File

@ -75,7 +75,7 @@ public class ExposeAnnotationExclusionStrategyTest extends TestCase {
private static FieldAttributes createFieldAttributes(String fieldName) throws Exception {
Field f = MockObject.class.getField(fieldName);
return new FieldAttributes(MockObject.class, f);
return new FieldAttributes(MockObject.class, f, MockObject.class);
}
@SuppressWarnings("unused")

View File

@ -36,12 +36,12 @@ public class FieldAttributesTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
fieldAttributes = new FieldAttributes(Foo.class, Foo.class.getField("bar"));
fieldAttributes = new FieldAttributes(Foo.class, Foo.class.getField("bar"), Foo.class);
}
public void testNullField() throws Exception {
try {
new FieldAttributes(Foo.class, null);
new FieldAttributes(Foo.class, null, Foo.class);
fail("Field parameter can not be null");
} catch (NullPointerException expected) { }
}

View File

@ -34,7 +34,7 @@ public class FieldNamingStrategy2AdapterTest extends TestCase {
FieldNamingStrategy2 adapter =
new FieldNamingStrategy2Adapter(new UpperCaseNamingStrategy());
assertEquals(expectedFieldName, adapter.translateName(
new FieldAttributes(String.class, field)));
new FieldAttributes(String.class, field, String.class)));
}
@SuppressWarnings("deprecation")

View File

@ -46,7 +46,7 @@ public class InnerClassExclusionStrategyTest extends TestCase {
public void testExcludeInnerClassField() throws Exception {
Field f = getClass().getField("innerClass");
assertTrue(strategy.shouldSkipField(new FieldAttributes(getClass(), f)));
assertTrue(strategy.shouldSkipField(new FieldAttributes(getClass(), f, getClass())));
}
public void testIncludeStaticNestedClassObject() throws Exception {
@ -56,7 +56,7 @@ public class InnerClassExclusionStrategyTest extends TestCase {
public void testIncludeStaticNestedClassField() throws Exception {
Field f = getClass().getField("staticNestedClass");
assertFalse(strategy.shouldSkipField(new FieldAttributes(getClass(), f)));
assertFalse(strategy.shouldSkipField(new FieldAttributes(getClass(), f, getClass())));
}
class InnerClass {

View File

@ -34,7 +34,7 @@ public class JavaFieldNamingPolicyTest extends TestCase {
}
public void testFieldNamingPolicy() throws Exception {
FieldAttributes f = new FieldAttributes(String.class, String.class.getFields()[0]);
FieldAttributes f = new FieldAttributes(String.class, String.class.getFields()[0], String.class);
assertEquals(f.getName(), namingPolicy.translateName(f));
}

View File

@ -38,6 +38,6 @@ public class NullExclusionStrategyTest extends TestCase {
public void testNeverSkipsField() throws Exception {
assertFalse(strategy.shouldSkipField(
new FieldAttributes(String.class, String.class.getFields()[0])));
new FieldAttributes(String.class, String.class.getFields()[0], String.class)));
}
}

View File

@ -39,7 +39,7 @@ public class SerializedNameAnnotationInterceptingNamingPolicyTest extends TestCa
public void testFieldWithAnnotation() throws Exception {
String fieldName = "fieldWithAnnotation";
FieldAttributes f = new FieldAttributes(
SomeObject.class, SomeObject.class.getField(fieldName));
SomeObject.class, SomeObject.class.getField(fieldName), SomeObject.class);
assertFalse(ANNOTATED_FIELD_NAME.equals(fieldName));
assertEquals(ANNOTATED_FIELD_NAME, policy.translateName(f));
@ -48,7 +48,7 @@ public class SerializedNameAnnotationInterceptingNamingPolicyTest extends TestCa
public void testFieldWithoutAnnotation() throws Exception {
String fieldName = "fieldWithoutAnnotation";
FieldAttributes f = new FieldAttributes(
SomeObject.class, SomeObject.class.getField(fieldName));
SomeObject.class, SomeObject.class.getField(fieldName), SomeObject.class);
assertEquals(fieldName, policy.translateName(f));
}

View File

@ -43,7 +43,7 @@ public class VersionExclusionStrategyTest extends TestCase {
VersionExclusionStrategy strategy = new VersionExclusionStrategy(VERSION);
assertFalse(strategy.shouldSkipClass(clazz));
FieldAttributes fieldAttributes = new FieldAttributes(clazz, f);
FieldAttributes fieldAttributes = new FieldAttributes(clazz, f, clazz);
assertFalse(strategy.shouldSkipField(fieldAttributes));
}
@ -53,7 +53,7 @@ public class VersionExclusionStrategyTest extends TestCase {
VersionExclusionStrategy strategy = new VersionExclusionStrategy(VERSION + 1);
assertFalse(strategy.shouldSkipClass(clazz));
FieldAttributes fieldAttributes = new FieldAttributes(clazz, f);
FieldAttributes fieldAttributes = new FieldAttributes(clazz, f, clazz);
assertFalse(strategy.shouldSkipField(fieldAttributes));
}
@ -63,7 +63,7 @@ public class VersionExclusionStrategyTest extends TestCase {
VersionExclusionStrategy strategy = new VersionExclusionStrategy(VERSION - 1);
assertTrue(strategy.shouldSkipClass(clazz));
FieldAttributes fieldAttributes = new FieldAttributes(clazz, f);
FieldAttributes fieldAttributes = new FieldAttributes(clazz, f, clazz);
assertTrue(strategy.shouldSkipField(fieldAttributes));
}