You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Remko Popma <re...@yahoo.com> on 2013/04/28 22:42:41 UTC

[commit] moved classes to helpers package

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)