Bug 7521: Move DatastoreSnapshotList et al to persisted package
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / DatastoreSnapshotList.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.datastore.messages;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 /**
14  * Stores a list of DatastoreSnapshot instances.
15  *
16  * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList} instead.
17  */
18 @Deprecated
19 public class DatastoreSnapshotList extends ArrayList<DatastoreSnapshot> {
20     private static final long serialVersionUID = 1L;
21
22     public DatastoreSnapshotList() {
23     }
24
25     public DatastoreSnapshotList(List<DatastoreSnapshot> snapshots) {
26         super(snapshots);
27     }
28
29     private Object readResolve() {
30         List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot> snapshots =
31                 new ArrayList<>(size());
32         for (DatastoreSnapshot legacy: this) {
33             snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot(
34                     legacy.getType(), legacy.getShardManagerSnapshot(), fromLegacy(legacy.getShardSnapshots())));
35         }
36
37         return new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList(snapshots);
38     }
39
40     private List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot> fromLegacy(
41             List<DatastoreSnapshot.ShardSnapshot> from) {
42         List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot> snapshots =
43                 new ArrayList<>(from.size());
44         for (DatastoreSnapshot.ShardSnapshot legacy: from) {
45             snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot(
46                     legacy.getName(), legacy.getSnapshot()));
47         }
48
49         return snapshots;
50     }
51 }