2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.schema.provider.impl;
10 import com.google.common.annotations.Beta;
11 import com.google.common.io.ByteSource;
12 import java.io.IOException;
13 import java.io.Serializable;
14 import org.opendaylight.yangtools.yang.common.Revision;
15 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
16 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
17 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
20 * {@link org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource} serialization proxy.
23 public class YangTextSchemaSourceSerializationProxy implements Serializable {
24 private static final long serialVersionUID = -6361268518176019477L;
26 private final byte[] schemaSource;
27 private final Revision revision;
28 private final String name;
30 public YangTextSchemaSourceSerializationProxy(final YangTextSchemaSource source) throws IOException {
31 final var id = source.getIdentifier();
32 revision = id.revision();
33 name = id.name().getLocalName();
34 schemaSource = source.read();
37 public YangTextSchemaSource getRepresentation() {
38 return YangTextSchemaSource.delegateForByteSource(new SourceIdentifier(Unqualified.of(name), revision),
39 ByteSource.wrap(schemaSource));