2 * Copyright (c) 2018 Pantheon Technologies s.r.o. 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621;
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision;
17 * Utility methods for working with {@link Revision}s.
19 * @author Robert Varga
23 public final class RevisionUtils {
24 private static final Revision EMPTY_REVISION = new Revision("");
26 private RevisionUtils() {
31 * Return an empty {@link Revision}.
33 * @return An empty Revision.
35 public static Revision emptyRevision() {
36 return EMPTY_REVISION;
40 * Create a {@link Revision} from an optional {@link org.opendaylight.yangtools.yang.common.Revision}.
42 * @param revision Optional {@link org.opendaylight.yangtools.yang.common.Revision}
44 * @throws NullPointerException if revision is null
46 public static Revision fromYangCommon(final Optional<org.opendaylight.yangtools.yang.common.Revision> revision) {
47 return revision.map(rev -> new Revision(new RevisionIdentifier(rev.toString()))).orElse(EMPTY_REVISION);
51 * Create an optional {@link org.opendaylight.yangtools.yang.common.Revision} from a {@link Revision}.
53 * @param revision A Revision
54 * @return Optional {@link org.opendaylight.yangtools.yang.common.Revision}
55 * @throws NullPointerException if revision is null
57 public static Optional<org.opendaylight.yangtools.yang.common.Revision> toYangCommon(final Revision revision) {
58 final @Nullable RevisionIdentifier id = revision.getRevisionIdentifier();
59 return id != null ? Optional.of(org.opendaylight.yangtools.yang.common.Revision.of(id.getValue()))