public final class CodeHelpers extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
appendValue(com.google.common.base.MoreObjects.ToStringHelper helper,
String name,
byte[] value)
Append a named value to a ToStringHelper.
|
static void |
appendValue(@NonNull com.google.common.base.MoreObjects.ToStringHelper helper,
@NonNull String name,
@Nullable Object value)
Append a named value to a ToStringHelper.
|
static void |
checkPattern(String value,
Pattern[] patterns,
String[] regexes)
Check whether a specified string value matches specified patterns.
|
static void |
checkPattern(String value,
Pattern pattern,
String regex)
Check whether a specified string value matches a specified pattern.
|
static @NonNull Pattern[] |
compilePatterns(@NonNull List<String> patterns)
Compile a list of pattern regular expressions and return them as an array.
|
static <T> T |
nonNullValue(T value,
@NonNull String name)
Require an argument being received.
|
static void |
throwInvalidLength(String expected,
byte[] actual)
Throw an IllegalArgument exception describing a length violation.
|
static void |
throwInvalidLength(String expected,
Object actual)
Throw an IllegalArgument exception describing a length violation.
|
static void |
throwInvalidRange(Object[] expected,
Object actual)
Throw an IllegalArgument exception describing a range violation.
|
static void |
throwInvalidRange(String expected,
Object actual)
Throw an IllegalArgument exception describing a range violation.
|
static void |
validValue(boolean expression,
Object value,
String options)
Require that an a value-related expression is true.
|
public static void validValue(boolean expression,
Object value,
String options)
expression - Expression to evaluatevalue - Value being validatedoptions - Valid value options checkedIllegalArgumentException - if expression is falsepublic static <T> T nonNullValue(T value,
@NonNull String name)
Objects.requireNonNull(Object), but
throws an IllegalArgumentException.
Implementation note: we expect argName to be a string literal or a constant, so that it's non-nullness can be quickly discovered for a call site (where we are going to be inlined).
value - Value itselfname - Symbolic nameIllegalArgumentException - if value is nullNullPointerException - if name is nullpublic static void appendValue(@NonNull com.google.common.base.MoreObjects.ToStringHelper helper,
@NonNull String name,
@Nullable Object value)
helper - Helper to append toname - Name of the valuevalue - Value to appendNullPointerException - if the name or helper is nullpublic static void appendValue(com.google.common.base.MoreObjects.ToStringHelper helper,
String name,
byte[] value)
helper - Helper to append toname - Name of the valuevalue - Value to appendNullPointerException - if the name or helper is nullpublic static @NonNull Pattern[] compilePatterns(@NonNull List<String> patterns)
patterns - Patterns to compileNullPointerException - if the list or any of its elements is nullcom.google.common.base.VerifyException - if the list has fewer than two elementspublic static void checkPattern(String value, Pattern pattern, String regex)
Pattern which may reflect negation.value - Value to be checked.pattern - Enforcement patternregex - Source regular expression, as defined in YANG modelIllegalArgumentException - if the value does not match the patternNullPointerException - if any of the arguments are nullpublic static void checkPattern(String value, Pattern[] patterns, String[] regexes)
Pattern which may reflect negation.value - Value to be checked.patterns - Enforcement patternsregexes - Source regular expression, as defined in YANG model. Size and order must match patterns.IllegalArgumentException - if the value does not match the patternNullPointerException - if any of the arguments are nullcom.google.common.base.VerifyException - if the size of patterns and regexes does not matchpublic static void throwInvalidLength(String expected, Object actual)
expected - String describing expected lengthsactual - Actual observed objectIllegalArgumentException - alwayspublic static void throwInvalidLength(String expected, byte[] actual)
expected - String describing expected lengthsactual - Actual observed byte arrayIllegalArgumentException - alwayspublic static void throwInvalidRange(String expected, Object actual)
expected - String describing expected rangesactual - Actual observed objectIllegalArgumentException - alwayspublic static void throwInvalidRange(Object[] expected, Object actual)
expected - Objects describing expected rangesactual - Actual observed byte arrayIllegalArgumentException - alwaysCopyright © 2018 OpenDaylight. All rights reserved.