Alonso Gonzalez created LANG-1762:
-------------------------------------
Summary: New StopWatch methods should not delegate to deprecated
methods
Key: LANG-1762
URL: https://issues.apache.org/jira/browse/LANG-1762
Project: Commons Lang
Issue Type: Improvement
Components: lang.time.*
Affects Versions: 3.17.0, 3.16.0
Reporter: Alonso Gonzalez
{{getStartTime()}} and {{getStopTime()}} were deprecated in 3.16.0 but the new
methods don't use the new fields startInstant and stopInstant directly. Instead
the new methods delegate to the deprecated methods.
Thus calling the new {{getStartTime()}} method means:
* call deprecated method {{getStartTime()}}
* extract millis from available Instant startInstant
* create a new Instant with the extracted millis
The new methods should use the existing instants directly and the deprecated
methods should delegate to the new methods:
{code:java}
public Instant getStartInstant() {
if (runningState == State.UNSTARTED) {
throw new IllegalStateException("Stopwatch has not been started");
}
return startInstant;
}
@Deprecated
public long getStartTime() {
return getStartInstant().toEpochMilli();
}
{code}
This would avoid unnecessary object creations.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)