/* * 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/eplv10.html */ package org.opendaylight.yangtools.yang.model.repo.api; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import org.opendaylight.yangtools.concepts.Identifier; import org.opendaylight.yangtools.concepts.Immutable; /** * * YANG Schema source identifier * * Simple transfer object represents identifier of source for YANG schema (module or submodule), * which consists of *
* (For further reference see: http://tools.ietf.org/html/rfc6020#section-5.2 and
* http://tools.ietf.org/html/rfc6022#section-3.1 ).
*
*
*/
public final class SourceIdentifier implements Identifier, Immutable {
private static final long serialVersionUID = 1L;
private final String revision;
private final String name;
/**
*
* Creates new YANG Schema source identifier.
*
* @param name Name of schema
* @param formattedRevision Revision of source in format YYYY-mm-dd
*/
public SourceIdentifier(final String name, final Optional
* Where revision is date in format YYYY-mm-dd.
*
*
* @see http://tools.ietf.org/html/rfc6020#section-5.2
*
* @return Filename for this source identifier.
*/
public String toYangFilename() {
return toYangFileName(name, Optional.fromNullable(revision));
}
@Override
public String toString() {
return "SourceIdentifier [name=" + name + "@" + 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
*
* @return Filename for this source identifier.
*/
public static final String toYangFileName(final String moduleName, final Optionalname ['@' revision] '.yang'
* moduleName ['@' revision] '.yang'
*
* Where Where revision-date is in format YYYY-mm-dd.
*
*