import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.util.ReferencedTypeImpl;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
}
public static <T extends DataNodeContainer & AugmentationTarget & DataSchemaNode> TOAttribute create(
- T containerSchemaNode, TypeProviderWrapper typeProviderWrapper, String packageName) {
+ final T containerSchemaNode, final TypeProviderWrapper typeProviderWrapper, final String packageName) {
// Transfer Object: get the leaves
- Map<String, AttributeIfc> map = new HashMap<>();
- Map<String, String> attributeNameMap = new HashMap<>();
- for (DataSchemaNode dataSchemaNode : containerSchemaNode
- .getChildNodes()) {
+ final Map<String, AttributeIfc> map = new HashMap<>();
+ final Map<String, String> attributeNameMap = new HashMap<>();
+ for (final DataSchemaNode dataSchemaNode : containerSchemaNode.getChildNodes()) {
try {
- String yangName = dataSchemaNode.getQName().getLocalName();
- map.put(yangName,
- createInnerAttribute(dataSchemaNode,
- typeProviderWrapper, packageName));
- } catch (IllegalArgumentException e) {
+ final String yangName = dataSchemaNode.getQName().getLocalName();
+ map.put(yangName, createInnerAttribute(dataSchemaNode, typeProviderWrapper, packageName));
+ } catch (final IllegalArgumentException e) {
throw new IllegalStateException("Unable to create TO", e);
}
}
return new TOAttribute(containerSchemaNode, map, attributeNameMap,
- containerSchemaNode.getDescription(), packageName);
+ containerSchemaNode.getDescription().orElse(null), packageName);
}
private static AttributeIfc createInnerAttribute(
- DataSchemaNode dataSchemaNode,
- TypeProviderWrapper typeProviderWrapper, String packageName) {
- Class<? extends DataSchemaNode> type = isAllowedType(dataSchemaNode);
+ final DataSchemaNode dataSchemaNode,
+ final TypeProviderWrapper typeProviderWrapper, final String packageName) {
+ final Class<? extends DataSchemaNode> type = isAllowedType(dataSchemaNode);
if (type.equals(LeafSchemaNode.class)) {
- return new JavaAttribute((LeafSchemaNode) dataSchemaNode,
- typeProviderWrapper);
+ return new JavaAttribute((LeafSchemaNode) dataSchemaNode, typeProviderWrapper);
} else if (type.equals(ListSchemaNode.class)) {
- return ListAttribute.create((ListSchemaNode) dataSchemaNode,
- typeProviderWrapper, packageName);
+ return ListAttribute.create((ListSchemaNode) dataSchemaNode, typeProviderWrapper, packageName);
} else if (type.equals(LeafListSchemaNode.class)) {
- return ListAttribute.create((LeafListSchemaNode) dataSchemaNode,
- typeProviderWrapper);
+ return ListAttribute.create((LeafListSchemaNode) dataSchemaNode, typeProviderWrapper);
} else if (type.equals(ContainerSchemaNode.class)) {
- return TOAttribute.create((ContainerSchemaNode) dataSchemaNode,
- typeProviderWrapper, packageName);
+ return TOAttribute.create((ContainerSchemaNode) dataSchemaNode, typeProviderWrapper, packageName);
}
throw new IllegalStateException("This should never happen");
}
private static Class<? extends DataSchemaNode> isAllowedType(
- DataSchemaNode dataSchemaNode) {
- for (Class<? extends DataSchemaNode> allowedType : ALLOWED_CHILDREN) {
- if (allowedType.isAssignableFrom(dataSchemaNode.getClass()) == true) {
+ final DataSchemaNode dataSchemaNode) {
+ for (final Class<? extends DataSchemaNode> allowedType : ALLOWED_CHILDREN) {
+ if (allowedType.isAssignableFrom(dataSchemaNode.getClass())) {
return allowedType;
}
}
+ ALLOWED_CHILDREN);
}
- private TOAttribute(DataSchemaNode attrNode,
- Map<String, AttributeIfc> transferObject,
- Map<String, String> attributeNameMap, String nullableDescription, String packageName) {
+ private TOAttribute(final DataSchemaNode attrNode,
+ final Map<String, AttributeIfc> transferObject,
+ final Map<String, String> attributeNameMap, final String nullableDescription, final String packageName) {
super(attrNode);
- yangNameToAttributeMap = transferObject;
+ this.yangNameToAttributeMap = transferObject;
this.attributeNameMap = attributeNameMap;
this.nullableDescription = nullableDescription;
- nullableDefault = null;
+ this.nullableDefault = null;
this.packageName = packageName;
}
public Map<String, String> getAttributeNameMap() {
- return attributeNameMap;
+ return this.attributeNameMap;
}
public Map<String, AttributeIfc> getCapitalizedPropertiesToTypesMap() {
- Map<String, AttributeIfc> capitalizedPropertiesToTypesMap = Maps
+ final Map<String, AttributeIfc> capitalizedPropertiesToTypesMap = Maps
.newHashMap();
- for (Entry<String, AttributeIfc> entry : yangNameToAttributeMap
+ for (final Entry<String, AttributeIfc> entry : this.yangNameToAttributeMap
.entrySet()) {
capitalizedPropertiesToTypesMap.put(
}
public Map<String, AttributeIfc> getJmxPropertiesToTypesMap() {
- Map<String, AttributeIfc> jmxPropertiesToTypesMap = Maps.newHashMap();
- for (Entry<String, AttributeIfc> entry : yangNameToAttributeMap
+ final Map<String, AttributeIfc> jmxPropertiesToTypesMap = Maps.newHashMap();
+ for (final Entry<String, AttributeIfc> entry : this.yangNameToAttributeMap
.entrySet()) {
jmxPropertiesToTypesMap.put(
}
public Map<String, AttributeIfc> getYangPropertiesToTypesMap() {
- return yangNameToAttributeMap;
+ return this.yangNameToAttributeMap;
}
@Override
public String getNullableDescription() {
- return nullableDescription;
+ return this.nullableDescription;
}
@Override
public String getNullableDefault() {
- return nullableDefault;
+ return this.nullableDefault;
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) {
return true;
}
return false;
}
- TOAttribute that = (TOAttribute) o;
+ final TOAttribute that = (TOAttribute) o;
- if (nullableDefault != null ? !nullableDefault
+ if (this.nullableDefault != null ? !this.nullableDefault
.equals(that.nullableDefault) : that.nullableDefault != null) {
return false;
}
- if (nullableDescription != null ? !nullableDescription
+ if (this.nullableDescription != null ? !this.nullableDescription
.equals(that.nullableDescription)
: that.nullableDescription != null) {
return false;
}
- if (yangNameToAttributeMap != null ? !yangNameToAttributeMap
+ if (this.yangNameToAttributeMap != null ? !this.yangNameToAttributeMap
.equals(that.yangNameToAttributeMap)
: that.yangNameToAttributeMap != null) {
return false;
int result = super.hashCode();
result = 31
* result
- + (nullableDescription != null ? nullableDescription.hashCode()
+ + (this.nullableDescription != null ? this.nullableDescription.hashCode()
: 0);
result = 31 * result
- + (nullableDefault != null ? nullableDefault.hashCode() : 0);
+ + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
result = 31
* result
- + (yangNameToAttributeMap != null ? yangNameToAttributeMap
+ + (this.yangNameToAttributeMap != null ? this.yangNameToAttributeMap
.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "TOAttribute{" + getAttributeYangName() + "," + "to="
- + yangNameToAttributeMap + '}';
+ + this.yangNameToAttributeMap + '}';
}
@Override
public Type getType() {
// TODO: ReferencedTypeImpl from Types
- return new ReferencedTypeImpl(packageName, getUpperCaseCammelCase());
+ return new ReferencedTypeImpl(JavaTypeName.create(this.packageName, getUpperCaseCammelCase()));
}
@Override
public CompositeType getOpenType() {
- String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+ final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
- FunctionImpl functionImpl = new FunctionImpl();
- Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
- OpenType<?>[] itemTypes = Collections2.transform(
+ final FunctionImpl functionImpl = new FunctionImpl();
+ final Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
+ final OpenType<?>[] itemTypes = Collections2.transform(
jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(
new OpenType<?>[] {});
- String[] itemNames = functionImpl.getItemNames();
+ final String[] itemNames = functionImpl.getItemNames();
try {
// TODO add package name to create fully qualified name for this
// type
- CompositeType compositeType = new CompositeType(
+ final CompositeType compositeType = new CompositeType(
getUpperCaseCammelCase(), description, itemNames,
itemNames, itemTypes);
return compositeType;
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create CompositeType for "
+ this, e);
}
}
public String getPackageName() {
- return packageName;
+ return this.packageName;
}
}
private final List<String> itemNames = new ArrayList<>();
@Override
- public OpenType<?> apply(Entry<String, AttributeIfc> input) {
- AttributeIfc innerType = input.getValue();
- itemNames.add(input.getKey());
+ public OpenType<?> apply(final Entry<String, AttributeIfc> input) {
+ final AttributeIfc innerType = input.getValue();
+ this.itemNames.add(input.getKey());
return innerType.getOpenType();
}
public String[] getItemNames(){
- return itemNames.toArray(new String[itemNames.size()]);
+ return this.itemNames.toArray(new String[this.itemNames.size()]);
}
}