BindingMapping { public static BiMap<String, String> mapEnumAssignedNames(final Collection<String> assignedNames) { final BiMap<String, String> javaToYang = HashBiMap.create(assignedNames.size()); boolean valid = true; for (String name : assignedNames) { checkArgument(!name.isEmpty()); if (!javaToYang.containsValue(name)) { final String mappedName = getClassName(name); if (!isValidJavaIdentifier(mappedName) || javaToYang.forcePut(mappedName, name) != null) { valid = false; break; } } } if (!valid) { javaToYang.clear(); for (String name : assignedNames) { javaToYang.put(mapEnumAssignedName(name), name); } } return javaToYang.inverse(); } private  BindingMapping(); static @NonNull String getRootPackageName(final QName module); static @NonNull String getRootPackageName(final QNameModule module); static @NonNull String normalizePackageName(final String packageName); static @NonNull String getClassName(final String localName); static @NonNull String getClassName(final QName name); static @NonNull String getMethodName(final String yangIdentifier); static @NonNull String getMethodName(final QName name); static @NonNull String getGetterPrefix(final boolean isBoolean); static @NonNull String getGetterMethodName(final String localName, final boolean isBoolean); static @NonNull String getGetterMethodName(final QName name, final boolean isBoolean); static boolean isGetterMethodName(final String methodName); static @NonNull String getGetterMethodForNonnull(final String methodName); static @NonNull String getNonnullMethodName(final String localName); static boolean isNonnullMethodName(final String methodName); static @NonNull String getGetterSuffix(final QName name); static @NonNull String getPropertyName(final String yangIdentifier); static @NonNull String getRpcMethodName(final @NonNull QName qname); static BiMap<String, String> mapEnumAssignedNames(final Collection<String> assignedNames); static final @NonNull String VERSION; static final ImmutableSet<String> JAVA_RESERVED_WORDS; static final @NonNull String DATA_ROOT_SUFFIX; static final @NonNull String RPC_SERVICE_SUFFIX; static final @NonNull String NOTIFICATION_LISTENER_SUFFIX; static final @NonNull String QNAME_STATIC_FIELD_NAME; static final @NonNull String PACKAGE_PREFIX; static final @NonNull String AUGMENTATION_FIELD; static final @NonNull String MODULE_INFO_CLASS_NAME; static final @NonNull String MODULE_INFO_QNAMEOF_METHOD_NAME; static final @NonNull String MODEL_BINDING_PROVIDER_CLASS_NAME; static final @NonNull String AUGMENTABLE_AUGMENTATION_NAME; static final @NonNull String IDENTIFIABLE_KEY_NAME; static final @NonNull String DATA_CONTAINER_IMPLEMENTED_INTERFACE_NAME; static final @NonNull String BINDING_HASHCODE_NAME; static final @NonNull String BINDING_EQUALS_NAME; static final @NonNull String BINDING_TO_STRING_NAME; static final @NonNull String SCALAR_TYPE_OBJECT_GET_VALUE_NAME; static final @NonNull String BOOLEAN_GETTER_PREFIX; static final @NonNull String GETTER_PREFIX; static final @NonNull String NONNULL_PREFIX; static final @NonNull String RPC_INPUT_SUFFIX; static final @NonNull String RPC_OUTPUT_SUFFIX; }
@Test public void mapEnumAssignedNamesTest() { assertEqualMapping("__", "__"); assertEqualMapping("True", "true"); assertEqualMapping("ĽaľahoPapľuhu", "ľaľaho papľuhu"); assertEqualMapping("$", "$"); assertEqualMapping("$abc", "$abc"); assertEqualMapping("A$bc", "a$bc"); assertEqualMapping("Ab$c", "ab$c"); assertEqualMapping("Abc$", "abc$"); assertEqualMapping(of("AZ", "_09"), of("a-z", "0-9")); assertEqualMapping("$_", "_"); assertEqualMapping("$$2A$", "*"); assertEqualMapping("$$2E$", "."); assertEqualMapping("$$2F$", "/"); assertEqualMapping("$$3F$", "?"); assertEqualMapping("$a$2A$a", "a*a"); assertEqualMapping(of("_09", "$0$2D$9"), of("_09", "0-9")); assertEqualMapping(of("$09", "$0$2D$9"), of("09", "0-9")); assertEqualMapping(of("aZ", "$a$2D$z"), of("aZ", "a-z")); assertEqualMapping(of("$a2$2E$5", "a25"), of("a2.5", "a25")); assertEqualMapping(of("$a2$2E$5", "$a2$2D$5"), of("a2.5", "a2-5")); assertEqualMapping(of("$ľaľaho$20$papľuhu", "$ľaľaho$20$$20$papľuhu"), of("ľaľaho papľuhu", "ľaľaho papľuhu")); }