Remote yang text source provider implementation
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / schema / repository / impl / YangTextSchemaSourceSerializationProxy.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.controller.cluster.schema.repository.impl;
10
11 import com.google.common.annotations.Beta;
12 import com.google.common.io.ByteSource;
13 import java.io.IOException;
14 import java.io.Serializable;
15 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
16 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
17
18 /**
19  * {@link org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource} serialization proxy.
20  */
21 @Beta
22 public class YangTextSchemaSourceSerializationProxy implements Serializable {
23     private static long serialVersionUID = 1L;
24
25     private final byte[] schemaSource;
26     private final String revision;
27     private final String name;
28
29     public YangTextSchemaSourceSerializationProxy(final YangTextSchemaSource source) throws IOException {
30         this.revision = source.getIdentifier().getRevision();
31         this.name = source.getIdentifier().getName();
32         this.schemaSource = source.read();
33     }
34
35     public YangTextSchemaSource getRepresentation() {
36         return YangTextSchemaSource.delegateForByteSource(new SourceIdentifier(name, revision), ByteSource.wrap(schemaSource));
37     }
38 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.