commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1091197 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Pair.java
Date Mon, 11 Apr 2011 20:31:14 GMT
Author: mbenson
Date: Mon Apr 11 20:31:14 2011
New Revision: 1091197

URL: http://svn.apache.org/viewvc?rev=1091197&view=rev
Log:
defer default toString() handling to toString(format)

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Pair.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Pair.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Pair.java?rev=1091197&r1=1091196&r2=1091197&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Pair.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Pair.java Mon Apr 11
20:31:14 2011
@@ -44,6 +44,8 @@ public abstract class Pair<L, R> impleme
     /** Serialization version */
     private static final long serialVersionUID = 4954918890077093841L;
 
+    private static final String DEFAULT_FORMAT_STRING = "(%2$s,%3$s)";
+
     /**
      * <p>Obtains an immutable pair of from two objects inferring the generic types.</p>
      * 
@@ -155,13 +157,7 @@ public abstract class Pair<L, R> impleme
      */
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("(");
-        builder.append(getLeftElement());
-        builder.append(",");
-        builder.append(getRightElement());
-        builder.append(")");
-        return builder.toString();
+        return toString(DEFAULT_FORMAT_STRING);
     }
 
     /**



Mime
View raw message