@Beta public final class JavaIdentifierNormalizer extends Object
There is special case in CLASS, INTERFACE, ENUM, ENUM VALUE, CONSTANT, METHOD and VARIABLE if identifier contains single dash - then the converter ignores the single dash in the way of the non-java chars. In other way, if dash is the first or the last char in the identifier or there is more dashes in a row in the identifier, then these dashes are converted as non-java chars. Example:
Next special case talks about normalizing class name which already exists in package - but with different camel cases (foo, Foo, fOo, ...). To every next classes with same names will by added their actual rank (serial number), except the first one. This working for CLASS, ENUM and INTEFACE java identifiers. If there exist the same ENUM VALUES in ENUM (with different camel cases), then it's parsed with same logic like CLASSES, ENUMS and INTERFACES but according to list of pairs of their ENUM parent. Example:
type enumeration { enum foo; enum Foo; }
Modifier and Type | Field and Description |
---|---|
static Set<String> |
SPECIAL_RESERVED_PATHS |
Modifier and Type | Method and Description |
---|---|
static String |
normalizeEnumValueIdentifier(String name,
List<Enumeration.Pair> values)
According to YANG RFC 7950,
all assigned names in an enumeration MUST be unique.
|
static String |
normalizeFullPackageName(String fullPackageName)
Normalizing full package name by non java chars and reserved keywords.
|
static String |
normalizeSpecificIdentifier(String identifier,
JavaIdentifier javaIdentifier)
Find and convert non Java chars in identifiers of generated transfer objects, initially
derived from corresponding YANG.
|
public static String normalizeEnumValueIdentifier(String name, List<Enumeration.Pair> values)
According to YANG RFC 7950,
all assigned names in an enumeration MUST be unique. Created names are contained in the list
of Enumeration.Pair
. This method adds actual index with underscore behind name of new
enum value only if this name already exists in one of the list of Enumeration.Pair
.
Then, the name will be converted to java chars according to JavaIdentifier.ENUM_VALUE
and returned.
type enumeration { enum foo; enum Foo; }
YANG enum values will be mapped to 'FOO' and 'FOO_1' Java enum values.
name
- - name of new enum valuevalues
- - list of all actual enum valuespublic static String normalizeFullPackageName(String fullPackageName)
fullPackageName
- - full package namepublic static String normalizeSpecificIdentifier(String identifier, JavaIdentifier javaIdentifier)
identifier
- - name of identifierjavaIdentifier
- - java type of identifierCopyright © 2019 OpenDaylight. All rights reserved.