import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.generator.api.BindingRuntimeTypes;
import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl;
return found;
}
- private static Type referencedType(final Class<?> type) {
- return new ReferencedTypeImpl(JavaTypeName.create(type));
- }
-
/**
* Returns schema ({@link DataSchemaNode}, {@link AugmentationSchemaNode} or {@link TypeDefinition})
* from which supplied class was generated. Returned schema may be augmented with
return getEnumMapping(findTypeWithSchema(enumClassName));
}
+ private static BiMap<String, String> getEnumMapping(final Entry<GeneratedType, WithStatus> typeWithSchema) {
+ final TypeDefinition<?> typeDef = (TypeDefinition<?>) typeWithSchema.getValue();
+
+ Preconditions.checkArgument(typeDef instanceof EnumTypeDefinition);
+ final EnumTypeDefinition enumType = (EnumTypeDefinition) typeDef;
+
+ final HashBiMap<String, String> mappedEnums = HashBiMap.create();
+
+ for (final EnumTypeDefinition.EnumPair enumPair : enumType.getValues()) {
+ mappedEnums.put(enumPair.getName(), BindingMapping.getClassName(enumPair.getName()));
+ }
+
+ // TODO cache these maps for future use
+ return mappedEnums;
+ }
+
private Entry<GeneratedType, WithStatus> findTypeWithSchema(final String className) {
// All we have is a straight FQCN, which we need to split into a hierarchical JavaTypeName. This involves
// some amount of guesswork -- we do that by peeling components at the dot and trying out, e.g. given
throw new IllegalArgumentException("Failed to find type for " + className);
}
- private static BiMap<String, String> getEnumMapping(final Entry<GeneratedType, WithStatus> typeWithSchema) {
- final TypeDefinition<?> typeDef = (TypeDefinition<?>) typeWithSchema.getValue();
-
- Preconditions.checkArgument(typeDef instanceof EnumTypeDefinition);
- final EnumTypeDefinition enumType = (EnumTypeDefinition) typeDef;
-
- final HashBiMap<String, String> mappedEnums = HashBiMap.create();
-
- for (final EnumTypeDefinition.EnumPair enumPair : enumType.getValues()) {
- mappedEnums.put(enumPair.getName(), BindingMapping.getClassName(enumPair.getName()));
- }
-
- // TODO cache these maps for future use
- return mappedEnums;
- }
-
public Set<Class<?>> getCases(final Class<?> choice) {
final Collection<Type> cazes = runtimeTypes.findCases(referencedType(choice));
final Set<Class<?>> ret = new HashSet<>(cazes.size());
return new AugmentationIdentifier(childNames);
}
+ private static Type referencedType(final Class<?> type) {
+ return new ReferencedTypeImpl(JavaTypeName.create(type));
+ }
+
private static Type referencedType(final Type type) {
if (type instanceof ReferencedTypeImpl) {
return type;