Skip to content

Commit

Permalink
minor cleanup - a faster and more inclusive ConversionUtil checks
Browse files Browse the repository at this point in the history
* Will cover String, StringBuffer and StringBuilder in one shot.
  Not that many people apply ConversionUtil to builders...
  • Loading branch information
andrus committed Dec 8, 2018
1 parent 34ad525 commit 8984621
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

package org.apache.cayenne.util;

import org.apache.cayenne.exp.ExpressionException;

import java.math.BigDecimal;
import java.math.BigInteger;

import org.apache.cayenne.exp.ExpressionException;

/**
* A collection of static conversion utility methods.
*
Expand Down Expand Up @@ -139,9 +139,7 @@ public static Comparable toComparable(Object object) {
public static String toString(Object object) {
if (object == null) {
return null;
} else if (object instanceof String) {
return (String) object;
} else if (object instanceof StringBuffer) {
} else if (object instanceof CharSequence) {
return object.toString();
} else if (object instanceof char[]) {
return new String((char[]) object);
Expand All @@ -155,7 +153,7 @@ public static String toString(Object object) {
* Attempts to convert an object to an uppercase string.
*/
public static Object toUpperCase(Object object) {
if ((object instanceof String) || (object instanceof StringBuffer)) {
if (object instanceof CharSequence) {
return object.toString().toUpperCase();
} else if (object instanceof char[]) {
return new String((char[]) object).toUpperCase();
Expand Down

0 comments on commit 8984621

Please sign in to comment.