logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remko Popma <rem...@yahoo.com>
Subject [commit] moved classes to helpers package
Date Sun, 28 Apr 2013 20:42:41 GMT
I have moved the Clock interface, ClockFactory class and Clock impl classes 
from the core.async package to core.helpers.
Updated the manual/async.xml page accordingly.

It may be an idea to replace all calls to System.currentTimeMillis()
with ClockFactory.getClock().currentTimeMillis().

In the async package this is done for performance (allow users to switch to
a faster impl), but another reason would be to facilitate testing. 
Eg. in a JUnit test you can set a clock that always
returns a fixed time and use this to test time format in patterns, etc.


Also moved the Assert class from core.jmx to core.helpers.
Where before you would write
public void MyConstructor(MyParam param) {
  if (param == null) {
    throw new NullPointerException("param is null");
  }
  this.param = param;
}

You can now write:
public void MyConstructor(MyParam param) {
  this.param = Assert.isNotNull(param, "param");
}

(similar to java.util.Objects.requireNonNull() in java 7)
Mime
View raw message