From ddb0c8c825db2c7194241ba9abb2bfd5fea05838 Mon Sep 17 00:00:00 2001 From: Joel Leitch Date: Wed, 6 Apr 2011 00:43:57 +0000 Subject: [PATCH] Minor formatting fixes. --- .../gson/ModifyFirstLetterNamingPolicy.java | 4 ++-- .../gson/MappedObjectConstructorTest.java | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java b/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java index 4de407fd..8fec8c95 100644 --- a/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java +++ b/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java @@ -101,8 +101,8 @@ final class ModifyFirstLetterNamingPolicy extends RecursiveFieldNamingPolicy { } private String modifyString(char firstCharacter, String srcString, int indexOfSubstring) { - return indexOfSubstring < srcString.length() ? - firstCharacter + srcString.substring(indexOfSubstring) + return (indexOfSubstring < srcString.length()) + ? firstCharacter + srcString.substring(indexOfSubstring) : String.valueOf(firstCharacter); } } diff --git a/gson/src/test/java/com/google/gson/MappedObjectConstructorTest.java b/gson/src/test/java/com/google/gson/MappedObjectConstructorTest.java index 8bd5d860..3b224210 100644 --- a/gson/src/test/java/com/google/gson/MappedObjectConstructorTest.java +++ b/gson/src/test/java/com/google/gson/MappedObjectConstructorTest.java @@ -16,10 +16,10 @@ package com.google.gson; -import java.lang.reflect.Type; - import junit.framework.TestCase; +import java.lang.reflect.Type; + /** * Unit tests for the {@link MappedObjectConstructor} class. * @@ -28,7 +28,7 @@ import junit.framework.TestCase; public class MappedObjectConstructorTest extends TestCase { private ParameterizedTypeHandlerMap> creatorMap; private MappedObjectConstructor constructor; - + @Override protected void setUp() throws Exception { super.setUp(); @@ -38,47 +38,47 @@ public class MappedObjectConstructorTest extends TestCase { public void testInstanceCreatorTakesTopPrecedence() throws Exception { creatorMap.register(ObjectWithDefaultConstructor.class, new MyInstanceCreator()); - ObjectWithDefaultConstructor obj = + ObjectWithDefaultConstructor obj = constructor.construct(ObjectWithDefaultConstructor.class); assertEquals("instanceCreator", obj.stringValue); assertEquals(10, obj.intValue); } - + public void testNoInstanceCreatorInvokesDefaultConstructor() throws Exception { ObjectWithDefaultConstructor expected = new ObjectWithDefaultConstructor(); - ObjectWithDefaultConstructor obj = + ObjectWithDefaultConstructor obj = constructor.construct(ObjectWithDefaultConstructor.class); assertEquals(expected.stringValue, obj.stringValue); assertEquals(expected.intValue, obj.intValue); } - + public void testNoDefaultConstructor() throws Exception { ObjectNoDefaultConstructor obj = constructor.construct(ObjectNoDefaultConstructor.class); assertNull(obj.stringValue); assertEquals(0, obj.intValue); } - + private static class MyInstanceCreator implements InstanceCreator { public ObjectWithDefaultConstructor createInstance(Type type) { return new ObjectWithDefaultConstructor("instanceCreator", 10); } } - + private static class ObjectWithDefaultConstructor { public final String stringValue; public final int intValue; - + private ObjectWithDefaultConstructor() { this("default", 5); } - + public ObjectWithDefaultConstructor(String stringValue, int intValue) { this.stringValue = stringValue; this.intValue = intValue; } } - + private static class ObjectNoDefaultConstructor extends ObjectWithDefaultConstructor { @SuppressWarnings("unused") public ObjectNoDefaultConstructor(String stringValue, int intValue) {