X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fmdsal-binding-java-api-generator%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fjava%2Fapi%2Fgenerator%2FGeneratorUtil.java;h=0e224b8d2e90d1c8e7225eba2eb670e90446117b;hb=62d1bb7f2cf0c96ce34ca181462132dc95555daf;hp=3c719d15d2151f2a5753e6ff5816f0b46e7ee140;hpb=0f351bbc28ddf2cddfe30c8d018646d81953fa17;p=mdsal.git
diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorUtil.java b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorUtil.java
index 3c719d15d2..0e224b8d2e 100644
--- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorUtil.java
+++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorUtil.java
@@ -28,25 +28,18 @@ import org.opendaylight.mdsal.binding.model.util.TypeConstants;
import org.opendaylight.mdsal.binding.model.util.Types;
public final class GeneratorUtil {
-
- /**
- * It doesn't have the sense to create the instances of this class.
- */
private GeneratorUtil() {
throw new UnsupportedOperationException();
}
/**
- * Returns the map of imports. The map maps the type name to the package
- * name. To the map are added packages for genType
and for all
- * enclosed types, constants, methods (parameter types, return values),
+ * Returns the map of imports. The map maps the type name to the package name. To the map are added packages
+ * for genType
and for all enclosed types, constants, methods (parameter types, return values),
* implemented types.
*
- * @param genType
- * generated type for which the map of the imports is created
+ * @param genType generated type for which the map of the imports is created
* @return map of the necessary imports
- * @throws IllegalArgumentException
- * if genType
equals null
+ * @throws IllegalArgumentException if genType
equals null
*/
static Map createImports(final GeneratedType genType) {
if (genType == null) {
@@ -97,18 +90,12 @@ public final class GeneratorUtil {
}
/**
- * Evaluates if it is necessary to add the package name for
- * type
to the map of imports for parentGenType
.
- * If it is so the package name is saved to the map imports
.
+ * Evaluates if it is necessary to add the package name for type
to the map of imports for
+ * parentGenType
. If it is so the package name is saved to the map imports
.
*
- * @param parentGenType
- * generated type for which is the map of the necessary imports
- * built
- * @param type
- * JAVA Type
for which is the necessary of the
- * package import evaluated
- * @param imports
- * map of the imports for parentGenType
+ * @param parentGenType generated type for which is the map of the necessary imports built
+ * @param type JAVA Type
for which is the necessary of the package import evaluated
+ * @param imports map of the imports for parentGenType
* @throws IllegalArgumentException
*
* - if the
parentGenType
equals
@@ -157,14 +144,11 @@ public final class GeneratorUtil {
}
/**
- * Checks if the constant with the name constName
is in the
- * list of the constant definition for genTO
.
+ * Checks if the constant with the name constName
is in the list of the constant definition for
+ * genTO
.
*
- * @param constName
- * string with the name of constant which is sought
- * @param genTO
- * generated transfer object in which is constName
- * sought
+ * @param constName string with the name of constant which is sought
+ * @param genTO generated transfer object in which is constName
sought
* @return boolean value
*
* - true - if
constName
is in the list of the
@@ -191,14 +175,11 @@ public final class GeneratorUtil {
}
/**
- * Creates the map which maps the type name to package name and contains
- * only package names for enclosed types of genType
and
- * recursively their enclosed types.
+ * Creates the map which maps the type name to package name and contains only package names for enclosed types
+ * of genType
and recursively their enclosed types.
*
- * @param genType
- * JAVA Type
for which is the map created
- * @return map of the package names for all the enclosed types and
- * recursively their enclosed types
+ * @param genType JAVA Type
for which is the map created
+ * @return map of the package names for all the enclosed types and recursively their enclosed types
*/
static Map createChildImports(final GeneratedType genType) {
Map childImports = new LinkedHashMap<>();
@@ -210,19 +191,13 @@ public final class GeneratorUtil {
}
/**
- * Builds the string which contains either the full path to the type
- * (package name with type) or only type name if the package is among
- * imports
.
+ * Builds the string which contains either the full path to the type (package name with type) or only type name
+ * if the package is among imports
.
*
- * @param parentGenType
- * generated type which contains type
- * @param type
- * JAVA Type
for which is the string with type info
- * generated
- * @param imports
- * map of necessary imports for parentGenType
- * @return string with type name for type
in the full format or
- * in the short format
+ * @param parentGenType generated type which contains type
+ * @param type JAVA Type
for which is the string with type info generated
+ * @param imports map of necessary imports for parentGenType
+ * @return string with type name for type
in the full format or in the short format
* @throws IllegalArgumentException
*
* - if the
type
equals null
@@ -257,19 +232,13 @@ public final class GeneratorUtil {
}
/**
- * Adds actual type parameters from type
to
- * builder
if type
is
+ * Adds actual type parameters from type
to builder
if type
is
* ParametrizedType
.
*
- * @param builder
- * string builder which contains type name
- * @param type
- * JAVA Type
for which is the string with type info
- * generated
- * @param parentGenType
- * generated type which contains type
- * @param imports
- * map of necessary imports for parentGenType
+ * @param builder string builder which contains type name
+ * @param type JAVA Type
for which is the string with type info generated
+ * @param parentGenType generated type which contains type
+ * @param imports map of necessary imports for parentGenType
* @return if type
is of the type ParametrizedType
* - then
builder
+ actual type
* parameters - else only
builder
@@ -279,37 +248,31 @@ public final class GeneratorUtil {
if (type instanceof ParameterizedType) {
final ParameterizedType pType = (ParameterizedType) type;
final Type[] pTypes = pType.getActualTypeArguments();
- builder.append("<");
- builder.append(getParameters(parentGenType, pTypes, imports));
- builder.append(">");
+ builder.append('<').append(getParameters(parentGenType, pTypes, imports)).append('>');
}
return builder;
}
/**
- * Generates the string with all actual type parameters from
- * pTypes
+ * Generates the string with all actual type parameters from pTypes
.
*
- * @param parentGenType
- * generated type for which is the JAVA code generated
- * @param pTypes
- * array of Type
instances = actual type parameters
- * @param availableImports
- * map of imports for parentGenType
+ * @param parentGenType generated type for which is the JAVA code generated
+ * @param paramTypes array of Type
instances = actual type parameters
+ * @param availableImports map of imports for parentGenType
* @return string with all actual type parameters from pTypes
*/
- private static String getParameters(final GeneratedType parentGenType, final Type[] pTypes,
+ private static String getParameters(final GeneratedType parentGenType, final Type[] paramTypes,
final Map availableImports) {
- if (pTypes == null || pTypes.length == 0) {
+ if (paramTypes == null || paramTypes.length == 0) {
return "?";
}
final StringBuilder builder = new StringBuilder();
- for (int i = 0; i < pTypes.length; i++) {
- final Type t = pTypes[i];
+ for (int i = 0; i < paramTypes.length; i++) {
+ final Type t = paramTypes[i];
String separator = COMMA;
- if (i == pTypes.length - 1) {
+ if (i == paramTypes.length - 1) {
separator = "";
}
@@ -328,14 +291,11 @@ public final class GeneratorUtil {
/**
* Returns the reference to highest (top parent) Generated Transfer Object.
*
- * @param childTransportObject
- * is generated transfer object which can be extended by other
- * generated transfer object
- * @return in first case that childTransportObject
isn't
- * extended then childTransportObject
is returned. In
- * second case the method is recursive called until first case.
- * @throws IllegalArgumentException
- * if childTransportObject
equals null
+ * @param childTransportObject is generated transfer object which can be extended by other generated transfer object
+ * @return in first case that childTransportObject
is not extended then
+ * childTransportObject
is returned. In second case the method is recursive called until first
+ * case.
+ * @throws IllegalArgumentException if childTransportObject
equals null
*/
static GeneratedTransferObject getTopParentTransportObject(final GeneratedTransferObject childTransportObject) {
if (childTransportObject == null) {
@@ -343,19 +303,16 @@ public final class GeneratorUtil {
}
if (childTransportObject.getSuperType() == null) {
return childTransportObject;
- } else {
- return getTopParentTransportObject(childTransportObject.getSuperType());
}
+
+ return getTopParentTransportObject(childTransportObject.getSuperType());
}
/**
- * Selects from input list of properties only those which have read only
- * attribute set to true.
+ * Selects from input list of properties only those which have read only attribute set to true.
*
- * @param properties
- * list of properties of generated transfer object
- * @return subset of properties
which have read only attribute
- * set to true
+ * @param properties list of properties of generated transfer object
+ * @return subset of properties
which have read only attribute set to true
*/
static List resolveReadOnlyPropertiesFromTO(final List properties) {
List readOnlyProperties = new ArrayList<>();
@@ -370,16 +327,12 @@ public final class GeneratorUtil {
}
/**
- * Returns the list of the read only properties of all extending generated
- * transfer object from genTO
to highest parent generated
- * transfer object
+ * Returns the list of the read only properties of all extending generated transfer object from genTO
+ * to highest parent generated transfer object.
*
- * @param genTO
- * generated transfer object for which is the list of read only
- * properties generated
- * @return list of all read only properties from actual to highest parent
- * generated transfer object. In case when extension exists the
- * method is recursive called.
+ * @param genTO generated transfer object for which is the list of read only properties generated
+ * @return list of all read only properties from actual to highest parent generated transfer object. In case when
+ * extension exists the method is recursive called.
*/
static List getPropertiesOfAllParents(final GeneratedTransferObject genTO) {
List propertiesOfAllParents = new ArrayList<>();