From a6135697b71d38e99807f826d7479284a717d847 Mon Sep 17 00:00:00 2001 From: erik Date: Sun, 24 Jul 2011 18:58:25 +0000 Subject: [PATCH 1/1] UTILS-14: Add clock abstraction. --- .../main/java/org/wamblee/general/Clock.java | 29 ++++++++++++++++++ .../java/org/wamblee/general/SystemClock.java | 30 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 support/general/src/main/java/org/wamblee/general/Clock.java create mode 100644 support/general/src/main/java/org/wamblee/general/SystemClock.java diff --git a/support/general/src/main/java/org/wamblee/general/Clock.java b/support/general/src/main/java/org/wamblee/general/Clock.java new file mode 100644 index 00000000..e5510eda --- /dev/null +++ b/support/general/src/main/java/org/wamblee/general/Clock.java @@ -0,0 +1,29 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed 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.wamblee.general; + +/** + * Clock abstraction for {@link System#currentTimeMillis()}. + * + * @author Erik Brakkee + */ +public interface Clock { + + /** + * @return Current time. + */ + long currentTimeMillis(); +} diff --git a/support/general/src/main/java/org/wamblee/general/SystemClock.java b/support/general/src/main/java/org/wamblee/general/SystemClock.java new file mode 100644 index 00000000..1295258c --- /dev/null +++ b/support/general/src/main/java/org/wamblee/general/SystemClock.java @@ -0,0 +1,30 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed 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.wamblee.general; + +/** + * Default clock implementation delegating to the system clock. + * + * @author Erik Brakkee + */ +public class SystemClock implements Clock { + + @Override + public long currentTimeMillis() { + return System.currentTimeMillis(); + } + +} -- 2.31.1