From 29066c6e89a16ccdc3210e4ad616a58901cbcf21 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 11 Apr 2011 18:07:54 +0000 Subject: [PATCH] Add Pair.toString(String) git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1091156 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/lang3/Pair.java | 9 +++++++++ src/test/java/org/apache/commons/lang3/PairTest.java | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/org/apache/commons/lang3/Pair.java b/src/main/java/org/apache/commons/lang3/Pair.java index 9398013ac..3b09c4b29 100644 --- a/src/main/java/org/apache/commons/lang3/Pair.java +++ b/src/main/java/org/apache/commons/lang3/Pair.java @@ -17,6 +17,7 @@ package org.apache.commons.lang3; import java.io.Serializable; +import java.util.Formatter; import java.util.Map; import org.apache.commons.lang3.builder.CompareToBuilder; @@ -163,4 +164,12 @@ public abstract class Pair implements Map.Entry, Comparable pair = Pair.of("Key", "Value"); + assertEquals("ImmutablePair", pair.toString("%1$s")); + assertEquals("Key", pair.toString("%2$s")); + assertEquals("Value", pair.toString("%3$s")); + assertEquals("Key: Value", pair.toString("%2$s: %3$s")); + pair = Pair.of(null, null); + assertEquals("null: null", pair.toString("%2$s: %3$s")); + } + }