@@ -27,7 +27,7 @@ public class OsonDocumentReader implements JsonDocumentReader {
2727 final private OracleJsonParser parser ;
2828 private String currentKeyName ;
2929 private Object currentValue ;
30- private boolean currentValueIsAString ; // avoid later introspection
30+
3131 /**
3232 * Creates a new <code>OsonDocumentReader</code> on top of a <code>OracleJsonParser</code>
3333 * @param parser the parser
@@ -48,7 +48,6 @@ public JsonDocumentItemType next() {
4848 OracleJsonParser .Event evt = this .parser .next ();
4949 currentKeyName = null ;
5050 currentValue = null ;
51- currentValueIsAString = false ;
5251 switch (evt ) {
5352 case OracleJsonParser .Event .START_OBJECT :
5453 return JsonDocumentItemType .OBJECT_START ;
@@ -76,7 +75,6 @@ public JsonDocumentItemType next() {
7675 return JsonDocumentItemType .VALUE ;
7776 case OracleJsonParser .Event .VALUE_STRING :
7877 currentValue = this .parser .getString ();
79- currentValueIsAString = true ;
8078 return JsonDocumentItemType .VALUE ;
8179 case OracleJsonParser .Event .VALUE_TRUE :
8280 currentValue = Boolean .TRUE ;
@@ -128,51 +126,52 @@ public BigInteger getBigIntegerValue() {
128126
129127 @ Override
130128 public double getDoubleValue () {
131- if (currentValueIsAString ) return Double .parseDouble ( (String )currentValue );
129+ if (currentValue instanceof String )
130+ return Double .parseDouble ( (String )currentValue );
132131 return ((Double )currentValue ).doubleValue ();
133132 }
134133
135134 @ Override
136135 public float getFloatValue () {
137- if (currentValueIsAString ) return Float .parseFloat ( (String )currentValue );
136+ if (currentValue instanceof String ) return Float .parseFloat ( (String )currentValue );
138137 return ((Float )currentValue ).floatValue ();
139138 }
140139
141140 @ Override
142141 public long getLongValue () {
143- if (currentValueIsAString ) return Long .parseLong ( (String )currentValue );
142+ if (currentValue instanceof String ) return Long .parseLong ( (String )currentValue );
144143 return ((BigDecimal )currentValue ).longValue ();
145144 }
146145
147146 @ Override
148147 public int getIntegerValue () {
149- if (currentValueIsAString ) return Integer .parseInt ( (String )currentValue );
148+ if (currentValue instanceof String ) return Integer .parseInt ( (String )currentValue );
150149 return ((BigDecimal )currentValue ).intValue ();
151150 }
152151
153152 @ Override
154153 public short getShortValue () {
155- if (currentValueIsAString ) return Short .parseShort ( (String )currentValue );
154+ if (currentValue instanceof String ) return Short .parseShort ( (String )currentValue );
156155 return ((BigDecimal )currentValue ).shortValue ();
157156 }
158157
159158 @ Override
160159 public byte getByteValue () {
161- if (currentValueIsAString ) return Byte .parseByte ( (String )currentValue );
160+ if (currentValue instanceof String ) return Byte .parseByte ( (String )currentValue );
162161 return ((Byte )currentValue ).byteValue ();
163162 }
164163
165164 @ Override
166165 public boolean getBooleanValue () {
167- if (currentValueIsAString ) return BooleanJavaType .INSTANCE .fromEncodedString ((String )currentValue );
166+ if (currentValue instanceof String ) return BooleanJavaType .INSTANCE .fromEncodedString ((String )currentValue );
168167 return ((Boolean )currentValue ).booleanValue ();
169168 }
170169
171170
172171
173172 @ Override
174173 public <T > T getValue (JavaType <T > javaType , WrapperOptions options ) {
175- if ( currentValueIsAString ) {
174+ if ( currentValue instanceof String ) {
176175 if (javaType .equals (PrimitiveByteArrayJavaType .INSTANCE )) {
177176 // be sure that we have only allowed characters.
178177 // that may happen for string representation of UUID (i.e 53886a8a-7082-4879-b430-25cb94415be8) for instance
@@ -183,7 +182,7 @@ public <T> T getValue(JavaType<T> javaType, WrapperOptions options) {
183182
184183 Object theOneToBeUsed = currentValue ;
185184 // handle special cases for Date things
186- if ( currentValue . getClass () == LocalDateTime . class ) {
185+ if ( currentValue instanceof LocalDateTime ) {
187186 if ( java .sql .Date .class .isAssignableFrom ( javaType .getJavaTypeClass () ) ) {
188187 theOneToBeUsed = Date .valueOf ( ((LocalDateTime )currentValue ).toLocalDate () );
189188 }
0 commit comments