Introduce Activatable#NOOP_INSTANCE

... and use it instead of CachedViewCB#EMPTY_MODEL
This commit is contained in:
Chris Beams 2014-11-22 15:38:09 +01:00
parent eb310baae0
commit 892e3c33f9
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
2 changed files with 13 additions and 11 deletions

View File

@ -21,4 +21,16 @@ public interface Activatable {
void activate();
void deactivate();
Activatable NOOP_INSTANCE = new Activatable() {;
@Override
public void activate() {
}
@Override
public void deactivate() {
}
};
}

View File

@ -33,22 +33,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class CachedViewCB<M extends Activatable> extends ViewCB<M> implements Activatable {
private static final Logger log = LoggerFactory.getLogger(CachedViewCB.class);
protected static final Activatable EMPTY_MODEL = new Activatable() {
@Override
public void activate() {
}
@Override
public void deactivate() {
}
};
public CachedViewCB(M model) {
super(checkNotNull(model, "Model must not be null"));
}
public CachedViewCB() {
this((M) EMPTY_MODEL);
this((M) Activatable.NOOP_INSTANCE);
}