Appendable is not rich enough IMO. Creating a custom interface and then a StringBuilder wrapper seems like a lot for perhaps no gain beyond the abstraction. Since there is no use case for this abstraction now, YAGNI, let's stick with StringBuilder IMO.
Gary On Feb 22, 2016 2:35 PM, "Remko Popma" <[email protected]> wrote: > I agree it is preferable to use an interface, but the API that Appendable > offers is not nearly as rich as StringBuilder's. :-( > Specifically, I want to leverage StringBuilder's excellent support for > primitives. It also has special support for classes known to hold char[] > data. > > Sent from my iPhone > > On 2016/02/23, at 2:42, Matt Sicker <[email protected]> wrote: > > Could this be weakened to use Appendable instead of StringBuilder? > > ---------- Forwarded message ---------- > From: <[email protected]> > Date: 21 February 2016 at 23:58 > Subject: [1/2] logging-log4j2 git commit: LOG4J2-1293 > StringBuilderFormattable initial version > To: [email protected] > > > Repository: logging-log4j2 > Updated Branches: > refs/heads/master aa5bc42bd -> 33ef3f81d > > > LOG4J2-1293 StringBuilderFormattable initial version > > > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo > Commit: > http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a2c9ba8e > Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a2c9ba8e > Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a2c9ba8e > > Branch: refs/heads/master > Commit: a2c9ba8e2c859094df4d91b894302179e723f198 > Parents: 7ff4c96 > Author: rpopma <[email protected]> > Authored: Mon Feb 22 14:58:08 2016 +0900 > Committer: rpopma <[email protected]> > Committed: Mon Feb 22 14:58:08 2016 +0900 > > ---------------------------------------------------------------------- > .../log4j/util/StringBuilderFormattable.java | 33 ++++++++++++++++++++ > 1 file changed, 33 insertions(+) > ---------------------------------------------------------------------- > > > > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2c9ba8e/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java > ---------------------------------------------------------------------- > diff --git > a/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java > b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java > new file mode 100644 > index 0000000..5da9b61 > --- /dev/null > +++ > b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java > @@ -0,0 +1,33 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache license, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > + * See the license for the specific language governing permissions and > + * limitations under the license. > + */ > +package org.apache.logging.log4j.util; > + > +/** > + * Objects that implement this interface can be converted to text without > allocating temporary objects. > + * > + * @since 2.6s > + */ > +public interface StringBuilderFormattable { > + > + /** > + * Writes a text representation of this object into the specified > {@code StringBuilder}, ideally without allocating > + * temporary objects. > + * > + * @param buffer the StringBuilder to write into > + */ > + void formatTo(StringBuilder buffer); > +} > > > > > -- > Matt Sicker <[email protected]> > >
