X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fschema%2Fprovider%2Fimpl%2FYangTextSchemaSourceSerializationProxy.java;fp=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fschema%2Fprovider%2Fimpl%2FYangTextSchemaSourceSerializationProxy.java;h=8c1f8d0c1368ec4ea4a60bcae9d31a164f98d781;hp=0000000000000000000000000000000000000000;hb=f2aa0c3d35d7ec7b61fafe614128042c1a0251d8;hpb=6e744645da016deeaa4d6791161e760a3edc7fe0 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java new file mode 100644 index 0000000000..8c1f8d0c13 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.schema.provider.impl; + +import com.google.common.annotations.Beta; +import com.google.common.io.ByteSource; +import java.io.IOException; +import java.io.Serializable; +import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; + +/** + * {@link org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource} serialization proxy. + */ +@Beta +public class YangTextSchemaSourceSerializationProxy implements Serializable { + private static long serialVersionUID = 1L; + + private final byte[] schemaSource; + private final String revision; + private final String name; + + public YangTextSchemaSourceSerializationProxy(final YangTextSchemaSource source) throws IOException { + this.revision = source.getIdentifier().getRevision(); + this.name = source.getIdentifier().getName(); + this.schemaSource = source.read(); + } + + public YangTextSchemaSource getRepresentation() { + return YangTextSchemaSource.delegateForByteSource(new SourceIdentifier(name, revision), ByteSource.wrap(schemaSource)); + } +}