/* * Copyright (c) 2014 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.yangtools.yang.model.repo.api; import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.collect.Interner; import com.google.common.collect.Interners; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.concepts.Identifier; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.common.YangConstants; /** * Base class of YANG Schema source identifiers. Source identifiers are designated to be carry only necessary * information to look up YANG module (or submodule) source and to be used by various SchemaSourceProviders. * *
* For further reference see: RFC6020
* and RFC6022.
*/
@Beta
public abstract class SourceIdentifier implements Identifier, Immutable {
private static final Interner
* Returns filename in format
* @see RFC6020
*
* @return Filename for this source identifier.
*/
public @NonNull String toYangFilename() {
return toYangFileName(name, Optional.ofNullable(revision));
}
/**
* Returns filename for this YANG module as specified in RFC 6020.
*
*
* Returns filename in format
* See http://tools.ietf.org/html/rfc6020#section-5.2
*
* @param moduleName module name
* @param revision optional revision
* @return Filename for this source identifier.
*/
public static @NonNull String toYangFileName(final String moduleName, final Optionalname ['@' revision] '.yang'
, where revision is date in format YYYY-mm-dd.
*
* moduleName ['@' revision] '.yang'
,
* where Where revision-date is in format YYYY-mm-dd.
*
*