We guarantee a @NonNull return and have a well-defined behaviour
on null arguments.
Change-Id: I42532863520529c07b026176acf05c8000626f48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.base.CharMatcher;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import com.google.common.base.CharMatcher;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
-import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
/**
import org.eclipse.jdt.annotation.Nullable;
/**
* @author Robert Varga
*/
@Beta
* @author Robert Varga
*/
@Beta
public final class YangNames {
/**
* A {@link CharMatcher} matching the first character of a YANG {@code identifier} ABNF production,
* {@code (ALPHA / "_")}.
*/
public final class YangNames {
/**
* A {@link CharMatcher} matching the first character of a YANG {@code identifier} ABNF production,
* {@code (ALPHA / "_")}.
*/
- public static final CharMatcher IDENTIFIER_START =
+ public static final @NonNull CharMatcher IDENTIFIER_START =
CharMatcher.inRange('A', 'Z').or(CharMatcher.inRange('a', 'z').or(CharMatcher.is('_'))).precomputed();
/**
* A {@link CharMatcher} NOT matching second and later characters of a YANG {@code identifier} ABNF production,
* {@code (ALPHA / DIGIT / "_" / "-" / ".")}.
*/
CharMatcher.inRange('A', 'Z').or(CharMatcher.inRange('a', 'z').or(CharMatcher.is('_'))).precomputed();
/**
* A {@link CharMatcher} NOT matching second and later characters of a YANG {@code identifier} ABNF production,
* {@code (ALPHA / DIGIT / "_" / "-" / ".")}.
*/
- public static final CharMatcher NOT_IDENTIFIER_PART =
+ public static final @NonNull CharMatcher NOT_IDENTIFIER_PART =
IDENTIFIER_START.or(CharMatcher.inRange('0', '9')).or(CharMatcher.anyOf("-.")).negate().precomputed();
private YangNames() {
IDENTIFIER_START.or(CharMatcher.inRange('0', '9')).or(CharMatcher.anyOf("-.")).negate().precomputed();
private YangNames() {
* @return A tuple containing the module name and parsed revision, if present.
* @throws NullPointerException if {@code baseName} is null
*/
* @return A tuple containing the module name and parsed revision, if present.
* @throws NullPointerException if {@code baseName} is null
*/
- public static Entry<String, @Nullable String> parseFilename(final String baseName) {
+ public static @NonNull Entry<@NonNull String, @Nullable String> parseFilename(final String baseName) {
final int zavinac = baseName.lastIndexOf('@');
if (zavinac < 0) {
return new SimpleEntry<>(baseName, null);
final int zavinac = baseName.lastIndexOf('@');
if (zavinac < 0) {
return new SimpleEntry<>(baseName, null);