Expose BindingDataContainerWriter
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / DoNotLeakSpotbugs.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.common;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.annotation.Nullable;
13
14 /**
15  * Utility methods to hide operations that incur SpotBugs wrath used by public classes where we do not want to leak
16  * {@link SuppressFBWarnings}.
17  */
18 final class DoNotLeakSpotbugs {
19     private DoNotLeakSpotbugs() {
20         // Hidden on purpose
21     }
22
23     @SuppressFBWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ", justification = "Interning identity check")
24     static @Nullable String internedString(final @NonNull String str) {
25         final var interned = str.intern();
26         return interned == str ? null : interned;
27     }
28 }