The discussion threads ended with both th notion that Formattable was adding no value and final was best added for safety. I checked before making the change. Feel free to propse alternatives... Stephen
On 25 May 2011 15:48, Matt Benson <gudnabr...@gmail.com> wrote: > Way to make unilateral decisions in the name of progress, Stephen! ;P > > Matt > > On Wed, May 25, 2011 at 9:44 AM, <scolebou...@apache.org> wrote: >> Author: scolebourne >> Date: Wed May 25 14:44:04 2011 >> New Revision: 1127546 >> >> URL: http://svn.apache.org/viewvc?rev=1127546&view=rev >> Log: >> Remove Formattable from Pair >> >> Modified: >> >> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java >> >> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java >> >> Modified: >> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java >> URL: >> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java?rev=1127546&r1=1127545&r2=1127546&view=diff >> ============================================================================== >> --- >> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java >> (original) >> +++ >> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java >> Wed May 25 14:44:04 2011 >> @@ -18,12 +18,10 @@ package org.apache.commons.lang3.tuple; >> >> import java.io.Serializable; >> import java.util.Formattable; >> -import java.util.Formatter; >> import java.util.Map; >> >> import org.apache.commons.lang3.ObjectUtils; >> import org.apache.commons.lang3.builder.CompareToBuilder; >> -import org.apache.commons.lang3.text.FormattableUtils; >> >> /** >> * <p>A pair consisting of two elements.</p> >> @@ -42,17 +40,12 @@ import org.apache.commons.lang3.text.For >> * @since Lang 3.0 >> * @version $Id$ >> */ >> -public abstract class Pair<L, R> implements Map.Entry<L, R>, >> Comparable<Pair<L, R>>, Formattable, Serializable { >> +public abstract class Pair<L, R> implements Map.Entry<L, R>, >> Comparable<Pair<L, R>>, Serializable { >> >> /** Serialization version */ >> private static final long serialVersionUID = 4954918890077093841L; >> >> /** >> - * Basic format pattern. >> - */ >> - private static final String DEFAULT_FORMAT_STRING = "(%1$s,%2$s)"; >> - >> - /** >> * <p>Obtains an immutable pair of from two objects inferring the >> generic types.</p> >> * >> * <p>This factory allows the pair to be created using inference to >> @@ -167,23 +160,14 @@ public abstract class Pair<L, R> impleme >> } >> >> /** >> - * <p>Format this {@link Pair}. Basic format is in the form: (L,R).</p> >> + * <p>Formats the receiver using the given format.</p> >> * >> - * @param formatter the target formatter to append to, not null >> - * @param flags the flags for output format, see {@code Formattable} >> - * @param width the width of the output, see {@code Formattable} >> - * @param precision the precision of the output, see {@code Formattable} >> - */ >> - public void formatTo(Formatter formatter, int flags, int width, int >> precision) { >> - FormattableUtils.append(String.format(DEFAULT_FORMAT_STRING, >> getLeft(), getRight()), >> - formatter, flags, width, precision); >> - } >> - >> - /** >> - * Formats the receiver using the given string. >> + * <p>This uses {@link Formattable} to perform the formatting. Two >> variable may >> + * be used to embed the left and right elements. Use {@code %1$} for >> the left >> + * element (key) and {@code %2$} for the right element (value). >> + * The default format used by {@code toString()} is {@code >> (%1$s,%2$s)}.</p> >> * >> - * @param format the {@code Formattable} format string, where {@code >> %1$} is >> - * the left element (key) and {@code %2$} is the right element >> (value), not null >> + * @param format the format string, optionally containing {@code %1$} >> and {@code %2$}, not null >> * @return the formatted string, not null >> */ >> public Object toString(String format) { >> >> Modified: >> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java >> URL: >> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java?rev=1127546&r1=1127545&r2=1127546&view=diff >> ============================================================================== >> --- >> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java >> (original) >> +++ >> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java >> Wed May 25 14:44:04 2011 >> @@ -21,7 +21,6 @@ import static org.junit.Assert.assertEqu >> >> import java.util.Formatter; >> >> -import org.apache.commons.lang3.tuple.Pair; >> import org.junit.Test; >> >> /** >> @@ -115,8 +114,4 @@ public class FormattableUtilsTest { >> assertEquals("+*___", FormattableUtils.append("foo", new >> Formatter(), LEFT_JUSTIFY, 5, 2, '_', "+*").toString()); >> } >> >> - @Test >> - public void testToStringFormattable() { >> - assertEquals("(Key,Value)", >> FormattableUtils.toString(Pair.of("Key", "Value"))); >> - } >> } >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org