Minor formatting fixes.

This commit is contained in:
Joel Leitch 2011-04-06 00:43:57 +00:00
parent 7afda06253
commit ddb0c8c825
2 changed files with 14 additions and 14 deletions

View File

@ -101,8 +101,8 @@ final class ModifyFirstLetterNamingPolicy extends RecursiveFieldNamingPolicy {
} }
private String modifyString(char firstCharacter, String srcString, int indexOfSubstring) { private String modifyString(char firstCharacter, String srcString, int indexOfSubstring) {
return indexOfSubstring < srcString.length() ? return (indexOfSubstring < srcString.length())
firstCharacter + srcString.substring(indexOfSubstring) ? firstCharacter + srcString.substring(indexOfSubstring)
: String.valueOf(firstCharacter); : String.valueOf(firstCharacter);
} }
} }

View File

@ -16,10 +16,10 @@
package com.google.gson; package com.google.gson;
import java.lang.reflect.Type;
import junit.framework.TestCase; import junit.framework.TestCase;
import java.lang.reflect.Type;
/** /**
* Unit tests for the {@link MappedObjectConstructor} class. * Unit tests for the {@link MappedObjectConstructor} class.
* *
@ -28,7 +28,7 @@ import junit.framework.TestCase;
public class MappedObjectConstructorTest extends TestCase { public class MappedObjectConstructorTest extends TestCase {
private ParameterizedTypeHandlerMap<InstanceCreator<?>> creatorMap; private ParameterizedTypeHandlerMap<InstanceCreator<?>> creatorMap;
private MappedObjectConstructor constructor; private MappedObjectConstructor constructor;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
@ -38,47 +38,47 @@ public class MappedObjectConstructorTest extends TestCase {
public void testInstanceCreatorTakesTopPrecedence() throws Exception { public void testInstanceCreatorTakesTopPrecedence() throws Exception {
creatorMap.register(ObjectWithDefaultConstructor.class, new MyInstanceCreator()); creatorMap.register(ObjectWithDefaultConstructor.class, new MyInstanceCreator());
ObjectWithDefaultConstructor obj = ObjectWithDefaultConstructor obj =
constructor.construct(ObjectWithDefaultConstructor.class); constructor.construct(ObjectWithDefaultConstructor.class);
assertEquals("instanceCreator", obj.stringValue); assertEquals("instanceCreator", obj.stringValue);
assertEquals(10, obj.intValue); assertEquals(10, obj.intValue);
} }
public void testNoInstanceCreatorInvokesDefaultConstructor() throws Exception { public void testNoInstanceCreatorInvokesDefaultConstructor() throws Exception {
ObjectWithDefaultConstructor expected = new ObjectWithDefaultConstructor(); ObjectWithDefaultConstructor expected = new ObjectWithDefaultConstructor();
ObjectWithDefaultConstructor obj = ObjectWithDefaultConstructor obj =
constructor.construct(ObjectWithDefaultConstructor.class); constructor.construct(ObjectWithDefaultConstructor.class);
assertEquals(expected.stringValue, obj.stringValue); assertEquals(expected.stringValue, obj.stringValue);
assertEquals(expected.intValue, obj.intValue); assertEquals(expected.intValue, obj.intValue);
} }
public void testNoDefaultConstructor() throws Exception { public void testNoDefaultConstructor() throws Exception {
ObjectNoDefaultConstructor obj = constructor.construct(ObjectNoDefaultConstructor.class); ObjectNoDefaultConstructor obj = constructor.construct(ObjectNoDefaultConstructor.class);
assertNull(obj.stringValue); assertNull(obj.stringValue);
assertEquals(0, obj.intValue); assertEquals(0, obj.intValue);
} }
private static class MyInstanceCreator private static class MyInstanceCreator
implements InstanceCreator<ObjectWithDefaultConstructor> { implements InstanceCreator<ObjectWithDefaultConstructor> {
public ObjectWithDefaultConstructor createInstance(Type type) { public ObjectWithDefaultConstructor createInstance(Type type) {
return new ObjectWithDefaultConstructor("instanceCreator", 10); return new ObjectWithDefaultConstructor("instanceCreator", 10);
} }
} }
private static class ObjectWithDefaultConstructor { private static class ObjectWithDefaultConstructor {
public final String stringValue; public final String stringValue;
public final int intValue; public final int intValue;
private ObjectWithDefaultConstructor() { private ObjectWithDefaultConstructor() {
this("default", 5); this("default", 5);
} }
public ObjectWithDefaultConstructor(String stringValue, int intValue) { public ObjectWithDefaultConstructor(String stringValue, int intValue) {
this.stringValue = stringValue; this.stringValue = stringValue;
this.intValue = intValue; this.intValue = intValue;
} }
} }
private static class ObjectNoDefaultConstructor extends ObjectWithDefaultConstructor { private static class ObjectNoDefaultConstructor extends ObjectWithDefaultConstructor {
@SuppressWarnings("unused") @SuppressWarnings("unused")
public ObjectNoDefaultConstructor(String stringValue, int intValue) { public ObjectNoDefaultConstructor(String stringValue, int intValue) {