2 * Copyright (c) 2014 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.yangtools.yang.model.api.source;
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import com.google.common.io.CharSource;
13 import java.io.Reader;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
17 * YANG text schema source representation. Exposes an RFC6020 or RFC7950 text representation as a {@link Reader}.
20 public abstract class YangTextSource extends CharSource implements YangSourceRepresentation {
22 public final Class<YangTextSource> getType() {
23 return YangTextSource.class;
27 public final String toString() {
28 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
32 * Add subclass-specific attributes to the output {@link #toString()} output. Since
33 * subclasses are prevented from overriding {@link #toString()} for consistency
34 * reasons, they can add their specific attributes to the resulting string by attaching
35 * attributes to the supplied {@link ToStringHelper}.
37 * @param toStringHelper ToStringHelper onto the attributes can be added
38 * @return ToStringHelper supplied as input argument.
40 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
41 return toStringHelper.add("identifier", sourceId());