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.CharSource;
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.api.source.SourceIdentifier;
17 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
18 import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
21 * {@link YangTextSource} serialization proxy.
24 public class YangTextSchemaSourceSerializationProxy implements Serializable {
25 private static final long serialVersionUID = -6361268518176019477L;
27 private final String schemaSource;
28 private final Revision revision;
29 private final String name;
31 public YangTextSchemaSourceSerializationProxy(final YangTextSource source) throws IOException {
32 final var sourceId = source.sourceId();
33 revision = sourceId.revision();
34 name = sourceId.name().getLocalName();
35 schemaSource = source.read();
38 public YangTextSource getRepresentation() {
39 return new DelegatedYangTextSource(new SourceIdentifier(Unqualified.of(name), revision),
40 CharSource.wrap(schemaSource));