109: removed implementation coupling from Clock interface. DefaultClock.INSTANCE achieves the same thing without coupling.

This commit is contained in:
Les Hazlewood 2016-04-01 18:26:59 -07:00
parent 9e1ee67582
commit 3dfae9a31d
3 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,5 @@
package io.jsonwebtoken; package io.jsonwebtoken;
import io.jsonwebtoken.impl.DefaultClock;
import java.util.Date; import java.util.Date;
/** /**
@ -11,8 +9,6 @@ import java.util.Date;
*/ */
public interface Clock { public interface Clock {
public static final Clock DEFAULT = new DefaultClock();
/** /**
* Returns the clock's current timestamp at the instant the method is invoked. * Returns the clock's current timestamp at the instant the method is invoked.
* *

View File

@ -11,6 +11,11 @@ import java.util.Date;
*/ */
public class DefaultClock implements Clock { public class DefaultClock implements Clock {
/**
* Default static instance that may be shared. It is thread-safe.
*/
public static final Clock INSTANCE = new DefaultClock();
/** /**
* Simply returns <code>new {@link Date}()</code>. * Simply returns <code>new {@link Date}()</code>.
* *

View File

@ -70,7 +70,7 @@ public class DefaultJwtParser implements JwtParser {
Claims expectedClaims = new DefaultClaims(); Claims expectedClaims = new DefaultClaims();
private Clock clock = Clock.DEFAULT; private Clock clock = DefaultClock.INSTANCE;
@Override @Override
public JwtParser requireIssuedAt(Date issuedAt) { public JwtParser requireIssuedAt(Date issuedAt) {