Fixup checkstyle
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / InitialClientActorContext.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.access.client;
9
10 import static java.util.Objects.requireNonNull;
11
12 import akka.actor.ActorSystem;
13 import akka.persistence.SnapshotSelectionCriteria;
14 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
15
16 /**
17  * The initial context for an actor.
18  *
19  * @author Robert Varga
20  */
21 final class InitialClientActorContext extends AbstractClientActorContext {
22     private final AbstractClientActor actor;
23
24     InitialClientActorContext(final AbstractClientActor actor, final String persistenceId) {
25         super(actor.self(), persistenceId);
26         this.actor = requireNonNull(actor);
27     }
28
29     void saveSnapshot(final ClientIdentifier snapshot) {
30         actor.saveSnapshot(snapshot);
31     }
32
33     void deleteSnapshots(final SnapshotSelectionCriteria criteria) {
34         actor.deleteSnapshots(criteria);
35     }
36
37     ClientActorBehavior<?> createBehavior(final ClientIdentifier clientId) {
38         final ActorSystem system = actor.getContext().system();
39         final ClientActorContext context = new ClientActorContext(self(), persistenceId(), system,
40             clientId, actor.getClientActorConfig());
41
42         return actor.initialBehavior(context);
43     }
44
45     void stash() {
46         actor.stash();
47     }
48
49     void unstash() {
50         actor.unstashAll();
51     }
52 }