Looks like I was on autopilot for a sec there. I understand the reasoning behind preferring a final class.
On 28 August 2014 00:13, Ralph Goers <[email protected]> wrote: > This class has existed for 3 years (as a final Class). Why is it being > converted to an Interface? I agree with Gary. Please revert this unless you > have an excellent reason. > > Ralph > > > On Aug 27, 2014, at 10:08 PM, Gary Gregory <[email protected]> wrote: > > Noooooooooooo ;-) > > -1 > > This is an old no-no in my book. > > An interface defines a _contract_, using an interface to define constants > is an aberration. Use a class or an enum. > > See Effective Java: > http://books.google.com/books?id=ka2VUBqHiWkC&pg=PA98&lpg=PA98&dq=do+not+use+an+interface+for+constants&source=bl&ots=yZCoKep0N4&sig=y3R6MNeGgz8JY8TdrS0tF6PAR8w&hl=en&sa=X&ei=j7j-U4mdJYvAggTyk4HADQ&ved=0CDoQ6AEwAw#v=onepage&q=do%20not%20use%20an%20interface%20for%20constants&f=false > > Gary > > ---------- Forwarded message ---------- > From: <[email protected]> > Date: Thu, Aug 28, 2014 at 12:28 AM > Subject: svn commit: r1621037 - > /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java > To: [email protected] > > > Author: mattsicker > Date: Thu Aug 28 04:28:33 2014 > New Revision: 1621037 > > URL: http://svn.apache.org/r1621037 > Log: > Convert Constants into an interface. > > Modified: > > logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java > > Modified: > logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java > URL: > http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java?rev=1621037&r1=1621036&r2=1621037&view=diff > > ============================================================================== > --- > logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java > (original) > +++ > logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java > Thu Aug 28 04:28:33 2014 > @@ -21,38 +21,32 @@ import org.apache.logging.log4j.util.Pro > <http://org.apache.logging.log4j.util.pro/> > /** > * Log4j Constants. > */ > -public final class Constants { > +public interface Constants { > > /** > * Name of the system property to use to identify the LogEvent > factory. > */ > - public static final String LOG4J_LOG_EVENT_FACTORY = > "Log4jLogEventFactory"; > + String LOG4J_LOG_EVENT_FACTORY = "Log4jLogEventFactory"; > > /** > * Name of the system property to use to identify the ContextSelector > Class. > */ > - public static final String LOG4J_CONTEXT_SELECTOR = > "Log4jContextSelector"; > + String LOG4J_CONTEXT_SELECTOR = "Log4jContextSelector"; > > - public static final String LOG4J_DEFAULT_STATUS_LEVEL = > "Log4jDefaultStatusLevel"; > + String LOG4J_DEFAULT_STATUS_LEVEL = "Log4jDefaultStatusLevel"; > > /** > * JNDI context name string literal. > */ > - public static final String JNDI_CONTEXT_NAME = > "java:comp/env/log4j/context-name"; > + String JNDI_CONTEXT_NAME = "java:comp/env/log4j/context-name"; > > /** > * Line separator. > */ > - public static final String LINE_SEPARATOR = > PropertiesUtil.getProperties().getStringProperty("line.separator", "\n"); > + String LINE_SEPARATOR = > PropertiesUtil.getProperties().getStringProperty("line.separator", "\n"); > > /** > * Number of milliseconds in a second. > */ > - public static final int MILLIS_IN_SECONDS = 1000; > - > - /** > - * Prevent class instantiation. > - */ > - private Constants() { > - } > + int MILLIS_IN_SECONDS = 1000; > } > > > > > > -- > E-Mail: [email protected] | [email protected] > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > > > -- Matt Sicker <[email protected]>
