- Fix checkstyle issues and activate enforcement.
Change-Id: I5e83540c54650f899afa9e711d17f4c3efb2e9f0
Signed-off-by: Jie Han <han.jie@zte.com.cn>
<artifactId>yang-parser-impl</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
import org.opendaylight.mdsal.binding.javav2.model.api.Type;
/**
- * This class represents ancestor for other <code>Type</code>s
+ * This class represents ancestor for other <code>Type</code>s.
*/
@Beta
public abstract class AbstractBaseType implements Type {
* @param name
* string with the name for this <code>Type</code>
*/
- protected AbstractBaseType(final String pkName, final String name, ModuleContext context) {
+ protected AbstractBaseType(final String pkName, final String name, final ModuleContext context) {
Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!");
Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!");
this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName);
- Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " +
- "ModuleContext instance must be provided.");
+ Preconditions.checkNotNull(context,
+ "In case of not having identifiers normalized, ModuleContext instance must be provided.");
this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context);
}
* true if pkName and name are normalized
*/
protected AbstractBaseType(final String pkName, final String name, final boolean isNormalized,
- ModuleContext context) {
+ final ModuleContext context) {
Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!");
Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!");
if (isNormalized) {
this.name = name;
} else {
this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName);
- Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " +
- "ModuleContext instance must be provided.");
+ Preconditions.checkNotNull(context,
+ "In case of not having identifiers normalized, ModuleContext instance must be provided.");
this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context);
}
}
protected AbstractBaseType(final String pkName, final String name, final boolean isPkNameNormalized,
- final boolean isTypeNormalized, ModuleContext context ) {
+ final boolean isTypeNormalized, final ModuleContext context) {
Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!");
Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!");
if (isPkNameNormalized) {
if (isTypeNormalized) {
this.name = name;
} else {
- Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " +
- "ModuleContext instance must be provided.");
+ Preconditions.checkNotNull(context,
+ "In case of not having identifiers normalized ModuleContext instance must be provided.");
this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context);
}
}
}
/**
- * Encodes angle brackets in yang statement description
+ * Encodes angle brackets in yang statement description.
* @param description description of a yang statement which is used to generate javadoc comments
* @return string with encoded angle brackets
*/
public static long computeDefaultSUID(final GeneratedTypeBuilderBase<?> to) {
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
- try (final DataOutputStream dout = new DataOutputStream(bout)) {
+ try (DataOutputStream dout = new DataOutputStream(bout)) {
dout.writeUTF(to.getName());
dout.writeInt(to.isAbstract() ? 3 : 7);
* Creates package name from specified <code>basePackageName</code> (package
* name for module) and <code>schemaPath</code>.
*
+ * <p>
* Resulting package name is concatenation of <code>basePackageName</code>
* and all local names of YANG nodes which are parents of some node for
* which <code>schemaPath</code> is specified.
*
+ * <p>
* Based on type of node, there is also possible suffix added in order
* to prevent package name conflicts.
*
if (size <= 0) {
if (namespaceType != null) {
final StringBuilder sb = new StringBuilder();
- sb.append(basePackageName)
- .append('.')
- .append(namespaceType.getPackagePrefix());
+ sb.append(basePackageName).append('.').append(namespaceType.getPackagePrefix());
return JavaIdentifierNormalizer.normalizeFullPackageName(sb.toString());
}
return JavaIdentifierNormalizer.normalizeFullPackageName(basePackageName);
* Creates package name from specified <code>basePackageName</code> (package
* name for module) and <code>namespaceType</code>.
*
+ * <p>
* Resulting package name is concatenation of <code>basePackageName</code>
* and prefix of <code>namespaceType</code>.
*
public Optional<? extends RangeConstraint<?>> getRangeConstraint() {
return range;
}
+
@Override
public List<PatternConstraint> getPatternConstraints() {
return pattern;
}
+
@Override
public Optional<LengthConstraint> getLengthConstraint() {
return length;
}
+
@Override
public boolean isEmpty() {
return false;
* Creates package name from specified <code>basePackageName</code> (package
* name for module) and <code>schemaPath</code> which crosses an augmentation.
*
+ * <p>
* Resulting package name is concatenation of <code>basePackageName</code>
* and all local names of YANG nodes which are parents of some node for
* which <code>schemaPath</code> is specified.
*
+ * <p>
* Based on type of node, there is also possible suffix added in order
* to prevent package name conflicts.
*
* @return string with valid JAVA package name
* @throws NullPointerException if any of the arguments are null
*/
- public static String packageNameForAugmentedGeneratedType(final String basePackageName, final SchemaPath schemaPath) {
+ public static String packageNameForAugmentedGeneratedType(final String basePackageName,
+ final SchemaPath schemaPath) {
final Iterable<QName> pathTowardsRoot = schemaPath.getPathTowardsRoot();
final Iterable<QName> pathFromRoot = schemaPath.getPathFromRoot();
final int size = Iterables.size(pathTowardsRoot);
* Creates package name from <code>parentAugmentPackageName</code> (package
* name for direct parent augmentation) and <code>augmentationSchema</code> .
*
+ * <p>
* Resulting package name is concatenation of <code>parentAugmentPackageName</code>
* and the local name of <code>schemaPath</code>.
*
+ * <p>
* Based on type of node, there is also possible suffix added in order
* to prevent package name conflicts.
*
return def.getRangeConstraint();
}
- public static String replaceAllIllegalChars(final CharSequence stringBuilder){
+ public static String replaceAllIllegalChars(final CharSequence stringBuilder) {
final String ret = UNICODE_CHAR_PATTERN.matcher(stringBuilder).replaceAll("\\\\\\\\u");
return ret.isEmpty() ? "" : ret;
}
import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentable;
import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentation;
import org.opendaylight.mdsal.binding.javav2.spec.structural.TreeChildNode;
-import org.opendaylight.yangtools.concepts.Identifier;
import org.opendaylight.yangtools.concepts.Identifiable;
+import org.opendaylight.yangtools.concepts.Identifier;
public final class BindingTypes {
throw new UnsupportedOperationException("Utility class");
}
- public static ParameterizedType augmentable(Type t) {
- return parameterizedTypeFor(AUGMENTABLE, t);
+ public static ParameterizedType augmentable(Type type) {
+ return parameterizedTypeFor(AUGMENTABLE, type);
}
}
import org.opendaylight.yangtools.yang.common.QName;
/**
- * Util class
+ * Util class.
*/
@Beta
public final class FormattingUtils {
}
/**
- * Used in #yangtemplateformodule.scala.txt for formating revision description
+ * Used in #yangtemplateformodule.scala.txt for formating revision description.
*
* @param text Content of tag description
* @param nextLineIndent Number of spaces from left side default is 12
}
/**
- * Used in all yangtemplates for formating augmentation target
+ * Used in all yangtemplates for formating augmentation target.
*
* @param schemaPath path to augmented node
* @return path in string format
* <li>variable</li>
* <li>constant</li>
* <li>package</li>
- * </ul>
+ * </ul>.
*/
@Beta
public enum JavaIdentifier {
* </li>
* </ul>
*
+ * <p>
* 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
* </li>
* </ul>
*
+ * <p>
* 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),
* }
* </pre>
*
+ * <p>
* YANG enum values will be mapped to 'FOO' and 'FOO_1' Java enum values.
*
* @param name
return normalizeClassIdentifier(basePackageName, convertedClassName, convertedClassName, 1, context);
}
+ /**
+ * Checking while there doesn't exist any class name with the same name
+ * (regardless of camel cases) in package.
+ *
+ * @param packageName
+ * - package of class name
+ * @param origClassName
+ * - original class name
+ * @param actualClassName
+ * - actual class name with rank (serial number)
+ * @param rank
+ * - actual rank (serial number)
+ * @return converted identifier
+ */
+ private static String normalizeClassIdentifier(final String packageName, final String origClassName,
+ final String actualClassName, final int rank, final ModuleContext context) {
+
+ final ListMultimap<String, String> packagesMap = context.getPackagesMap();
+
+ synchronized (packagesMap) {
+ if (packagesMap.containsKey(packageName)) {
+ for (final String existingName : packagesMap.get(packageName)) {
+ if (actualClassName.equalsIgnoreCase(existingName)) {
+ return normalizeClassIdentifier(packageName, origClassName, origClassName + rank,
+ rank + 1, context);
+ }
+ }
+ }
+ context.putToPackagesMap(packageName, actualClassName);
+ return actualClassName;
+ }
+ }
+
/**
* Find and convert non Java chars in identifiers of generated transfer objects, initially
* derived from corresponding YANG.
}
/**
- * Checking while there doesn't exist any class name with the same name
- * (regardless of camel cases) in package.
- *
- * @param packageName
- * - package of class name
- * @param origClassName
- * - original class name
- * @param actualClassName
- * - actual class name with rank (serial number)
- * @param rank
- * - actual rank (serial number)
- * @return converted identifier
- */
- private static String normalizeClassIdentifier(final String packageName, final String origClassName,
- final String actualClassName, final int rank, final ModuleContext context) {
-
- final ListMultimap<String, String> packagesMap = context.getPackagesMap();
-
- synchronized (packagesMap) {
- if (packagesMap.containsKey(packageName)) {
- for (final String existingName : packagesMap.get(packageName)) {
- if (actualClassName.equalsIgnoreCase(existingName)) {
- return normalizeClassIdentifier(packageName, origClassName, origClassName + rank,
- rank + 1, context);
- }
- }
- }
- context.putToPackagesMap(packageName, actualClassName);
- return actualClassName;
- }
- }
-
- /**
- * Fix cases of converted identifiers by Java type
+ * Fix cases of converted identifiers by Java type.
*
* @param convertedIdentifier
* - converted identifier
}
/**
- * Check if there exist next char in identifier behind actual char position
+ * Check if there exist next char in identifier behind actual char position.
*
* @param identifier
* - original identifier
/**
* Converting first char of identifier. This happen only if this char is
- * non-java char
+ * non-java char.
*
- * @param c
+ * @param firstChar
* - first char
* @param existNext
* - existing of next char behind actual char
* @return converted char
*/
- private static String convertFirst(final char c, final boolean existNext) {
- final String name = DASH_OR_SPACE_MATCHER.replaceFrom(Character.getName(c), UNDERSCORE);
+ private static String convertFirst(final char firstChar, final boolean existNext) {
+ final String name = DASH_OR_SPACE_MATCHER.replaceFrom(Character.getName(firstChar), UNDERSCORE);
return existNext ? name + '_' : name;
}
/**
* Converting any char in java identifier, This happen only if this char is
- * non-java char
+ * non-java char.
*
- * @param c
+ * @param actualChar
* - actual char
* @param existNext
* - existing of next char behind actual char
* - last char of partial converted identifier
* @return converted char
*/
- private static String convert(final char c, final boolean existNext, final char partialLastChar) {
- return partialLastChar == '_' ? convertFirst(c, existNext) : "_" + convertFirst(c, existNext);
+ private static String convert(final char actualChar, final boolean existNext, final char partialLastChar) {
+ return partialLastChar == '_' ? convertFirst(actualChar, existNext) : "_" + convertFirst(actualChar, existNext);
}
/**
- * Capitalize input string
+ * Capitalize input string.
*
* @param identifier
* - string to be capitalized
import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
/**
- *
* Wraps combination of <code>packageName</code> and <code>name</code> to the
- * object representation
+ * object representation.
*
*/
public final class ReferencedTypeImpl extends AbstractBaseType {
/**
- * Creates instance of this class with concrete package name and type name
+ * Creates instance of this class with concrete package name and type name.
*
* @param packageName
* string with the package name
/**
* Creates instance of this class with concrete package name and type name
- * for already normalized identifier
+ * for already normalized identifier.
*
* @param packageName
* string with the package name
.addEscape('@', "@").build();
private static final Pattern TAIL_COMMENT_PATTERN = Pattern.compile("*/", Pattern.LITERAL);
+ private TypeComments() {
+ //Defeat initialization.
+ }
+
/**
* Create a {@link TypeComment} for a javadoc-compliant text snippet. This snippet must be eligible for direct
* inclusion in a Java comment without further escaping.
import com.google.common.collect.Iterables;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
+
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+
import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
import org.opendaylight.mdsal.binding.javav2.model.api.BaseTypeWithRestrictions;
import org.opendaylight.mdsal.binding.javav2.model.api.ConcreteType;
@Beta
public final class Types {
private static final CacheLoader<Class<?>, ConcreteType> TYPE_LOADER =
- new CacheLoader<Class<?>, ConcreteType>() {
+ new CacheLoader<Class<?>, ConcreteType>() {
- @Override
- public ConcreteType load(@Nonnull final Class<?> key) throws Exception {
- return new ConcreteTypeImpl(key.getPackage().getName(), key.getSimpleName(), null);
- }
- };
+ @Override
+ public ConcreteType load(@Nonnull final Class<?> key) throws Exception {
+ return new ConcreteTypeImpl(key.getPackage().getName(), key.getSimpleName(), null);
+ }
+ };
private static final LoadingCache<Class<?>, ConcreteType> TYPE_CACHE =
CacheBuilder.newBuilder().weakKeys().build(TYPE_LOADER);
* ConcreteType} which represents JAVA <code>void</code> type.
*
* @return <code>ConcreteType</code> instance which represents JAVA
- * <code>void</code>
+ * <code>void</code>
*/
public static ConcreteType voidType() {
return VOID;
* ConcreteType} which represents primitive JAVA type for which package
* doesn't exist.
*
- * @param primitiveType
- * string containing programmatic construction based on
- * primitive type (e.g byte[])
+ * @param primitiveType string containing programmatic construction based on
+ * primitive type (e.g byte[])
* @return <code>ConcreteType</code> instance which represents programmatic
- * construction with primitive JAVA type
+ * construction with primitive JAVA type
*/
public static ConcreteType primitiveType(final String primitiveType, final Restrictions restrictions) {
return new ConcreteTypeImpl("", primitiveType, restrictions);
}
/**
- * Returns an instance of {@link ConcreteType} describing the class
+ * Returns an instance of {@link ConcreteType} describing the class.
*
- * @param cls
- * Class to describe
+ * @param cls Class to describe
* @return Description of class
*/
public static ConcreteType typeForClass(final Class<?> cls) {
}
public static ConcreteType typeForClass(final Class<?> cls, final Restrictions restrictions,
- final ModuleContext moduleContext) {
+ final ModuleContext moduleContext) {
if (restrictions == null) {
return typeForClass(cls);
}
return new ConcreteTypeImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions);
} else {
return new BaseTypeWithRestrictionsImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions,
- moduleContext);
+ moduleContext);
}
}
/**
- * Returns an instance of {@link ParameterizedType} describing the typed
+ * Returns an instance of {@link ParameterizedType} describing the typed.
* {@link Map}<K,V>
*
- * @param keyType
- * Key Type
- * @param valueType
- * Value Type
+ * @param keyType Key Type
+ * @param valueType Value Type
* @return Description of generic type instance
*/
public static ParameterizedType mapTypeFor(final Type keyType, final Type valueType) {
* Returns an instance of {@link ParameterizedType} describing the typed
* {@link Set}<V> with concrete type of value.
*
- * @param valueType
- * Value Type
+ * @param valueType Value Type
* @return Description of generic type instance of Set
*/
public static ParameterizedType setTypeFor(final Type valueType) {
* Returns an instance of {@link ParameterizedType} describing the typed
* {@link List}<V> with concrete type of value.
*
- * @param valueType
- * Value Type
+ * @param valueType Value Type
* @return Description of type instance of List
*/
public static ParameterizedType listTypeFor(final Type valueType) {
}
/**
- * Creates instance of type
- * {@link ParameterizedType
- * ParameterizedType}
+ * Creates instance of type {@link ParameterizedType ParameterizedType}.
*
- * @param type
- * JAVA <code>Type</code> for raw type
- * @param parameters
- * JAVA <code>Type</code>s for actual parameter types
+ * @param type JAVA <code>Type</code> for raw type
+ * @param parameters JAVA <code>Type</code>s for actual parameter types
* @return <code>ParametrizedType</code> reprezentation of <code>type</code>
- * and its parameters <code>parameters</code>
+ * and its parameters <code>parameters</code>
*/
public static ParameterizedType parameterizedTypeFor(final Type type, final Type... parameters) {
return new ParameterizedTypeImpl(type, parameters);
}
/**
- * Creates instance of type
- * {@link WildcardType
- * WildcardType}
+ * Creates instance of type {@link WildcardType WildcardType}.
*
- * @param packageName
- * string with the package name
- * @param typeName
- * string with the type name
+ * @param packageName string with the package name
+ * @param typeName string with the type name
* @return <code>WildcardType</code> representation of
- * <code>packageName</code> and <code>typeName</code>
+ * <code>packageName</code> and <code>typeName</code>
*/
public static WildcardType wildcardTypeFor(final String packageName, final String typeName) {
return new WildcardTypeImpl(packageName, typeName);
}
/**
- * Creates instance of type
- * {@link WildcardType
- * WildcardType}
+ * Creates instance of type {@link WildcardType WildcardType}.
*
- * @param packageName
- * string with the package name
- * @param typeName
- * string with the type name
- * @param isPkNameNormalized
- * if the package name has been normalized
- * @param isTypeNormalized
- * if the type name has been normalized
+ * @param packageName string with the package name
+ * @param typeName string with the type name
+ * @param isPkNameNormalized if the package name has been normalized
+ * @param isTypeNormalized if the type name has been normalized
* @return <code>WildcardType</code> representation of
- * <code>packageName</code> and <code>typeName</code>
+ * <code>packageName</code> and <code>typeName</code>
*/
public static WildcardType wildcardTypeFor(final String packageName, final String typeName,
- final boolean isPkNameNormalized, final boolean isTypeNormalized, final ModuleContext context) {
+ final boolean isPkNameNormalized, final boolean isTypeNormalized,
+ final ModuleContext context) {
return new WildcardTypeImpl(packageName, typeName, isPkNameNormalized, isTypeNormalized, context);
}
* {@link Augmentable} and actual
* parameter is <code>valueType</code>.
*
- * @param valueType
- * JAVA <code>Type</code> with actual parameter
+ * @param valueType JAVA <code>Type</code> with actual parameter
* @return <code>ParametrizedType</code> representation of raw type
- * <code>Augmentable</code> with actual parameter
- * <code>valueType</code>
+ * <code>Augmentable</code> with actual parameter
+ * <code>valueType</code>
*/
public static ParameterizedType augmentableTypeFor(final Type valueType) {
final Type augmentable = typeForClass(Augmentable.class);
* {@link Augmentation} and actual
* parameter is <code>valueType</code>.
*
- * @param valueType
- * JAVA <code>Type</code> with actual parameter
+ * @param valueType JAVA <code>Type</code> with actual parameter
* @return <code>ParametrizedType</code> reprezentation of raw type
- * <code>Augmentation</code> with actual parameter
- * <code>valueType</code>
+ * <code>Augmentation</code> with actual parameter
+ * <code>valueType</code>
*/
public static ParameterizedType augmentationTypeFor(final Type valueType) {
final Type augmentation = typeForClass(Augmentation.class);
}
/**
- *
* Represents concrete JAVA type.
- *
*/
private static final class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType {
* Creates instance of this class with package <code>pkName</code> and
* with the type name <code>name</code>.
*
- * @param pkName
- * string with package name
- * @param name
- * string with the name of the type
+ * @param pkName string with package name
+ * @param name string with the name of the type
*/
private ConcreteTypeImpl(final String pkName, final String name, final Restrictions restrictions) {
- super(pkName, name, true,null);
+ super(pkName, name, true, null);
this.restrictions = restrictions;
}
}
/**
- *
* Represents concrete JAVA type with changed restriction values.
- *
*/
- private static final class BaseTypeWithRestrictionsImpl extends AbstractBaseType implements BaseTypeWithRestrictions {
+ private static final class BaseTypeWithRestrictionsImpl extends AbstractBaseType implements
+ BaseTypeWithRestrictions {
private final Restrictions restrictions;
/**
* Creates instance of this class with package <code>pkName</code> and
* with the type name <code>name</code>.
*
- * @param pkName
- * string with package name
- * @param name
- * string with the name of the type
+ * @param pkName string with package name
+ * @param name string with the name of the type
*/
private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions) {
super(pkName, name, null);
}
private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions,
- final ModuleContext moduleContext) {
+ final ModuleContext moduleContext) {
super(pkName, name, moduleContext);
this.restrictions = Preconditions.checkNotNull(restrictions);
}
}
/**
- *
* Represents parametrized JAVA type.
- *
*/
private static class ParameterizedTypeImpl extends AbstractBaseType implements ParameterizedType {
/**
private final Type[] actualTypes;
/**
- * JAVA raw type (like List, Set, Map...)
+ * JAVA raw type (like List, Set, Map...).
*/
private final Type rawType;
* Creates instance of this class with concrete rawType and array of
* actual parameters.
*
- * @param rawType
- * JAVA <code>Type</code> for raw type
- * @param actTypes
- * array of actual parameters
+ * @param rawType JAVA <code>Type</code> for raw type
+ * @param actTypes array of actual parameters
*/
- public ParameterizedTypeImpl(final Type rawType, final Type[] actTypes) {
+ ParameterizedTypeImpl(final Type rawType, final Type[] actTypes) {
super(rawType.getPackageName(), rawType.getName(), true, null);
this.rawType = rawType;
this.actualTypes = actTypes.clone();
}
/**
- *
* Represents JAVA bounded wildcard type.
- *
*/
private static class WildcardTypeImpl extends AbstractBaseType implements WildcardType {
/**
* Creates instance of this class with concrete package and type name.
*
- * @param packageName
- * string with the package name
- * @param typeName
- * string with the name of type
+ * @param packageName string with the package name
+ * @param typeName string with the name of type
*/
//FIXME: doesn't seem to be called at all
- public WildcardTypeImpl(final String packageName, final String typeName) {
+ WildcardTypeImpl(final String packageName, final String typeName) {
super(packageName, typeName, null);
}
/**
* Creates instance of this class with concrete package and type name.
*
- * @param packageName
- * string with the package name
- * @param typeName
- * string with the name of type
- * @param isPkNameNormalized
- * if the package name has been normalized
- * @param isTypeNormalized
- * if the type name has been normalized
+ * @param packageName string with the package name
+ * @param typeName string with the name of type
+ * @param isPkNameNormalized if the package name has been normalized
+ * @param isTypeNormalized if the type name has been normalized
*/
- public WildcardTypeImpl(final String packageName, final String typeName, final boolean isPkNameNormalized,
- final boolean isTypeNormalized, final ModuleContext context) {
+ WildcardTypeImpl(final String packageName, final String typeName, final boolean isPkNameNormalized,
+ final boolean isTypeNormalized, final ModuleContext context) {
super(packageName, typeName, isPkNameNormalized, isTypeNormalized, context);
}
}
public static <T extends Number & Comparable<T>> DefaultRestrictions<T> getDefaultRestrictions(final T min,
- final T max) {
+ final T max) {
return new DefaultRestrictions<>(min, max);
}
import org.apache.commons.lang3.StringUtils;
/**
- * Utility class for cleaning yang models of excess whitespaces
+ * Utility class for cleaning yang models of excess whitespaces.
*/
@Beta
public final class YangSnippetCleaner {
}
/**
- * Cleaning yang model of excess whitespaces, adding indentations
+ * Cleaning yang model of excess whitespaces, adding indentations.
*
* @param unformedYang
* - unformed yang model
indentCount = lineIndent(sb, indentCount, line);
sb.append(line).append(NEW_LINE);
if (!StringUtils.startsWithAny(line, RESERVED_LINES) && indentCount == 1 && i != 0) {
- sb.append(NEW_LINE);
+ sb.append(NEW_LINE);
}
}
}
}
private static int mergeWithPrevious(final StringBuilder sb, final int indentCount) {
- int newIndentCount = indentCount;
removeRemainingWhitespace(sb);
sb.append(SPACE);
sb.append(START_BODY);
sb.append(NEW_LINE);
+ int newIndentCount = indentCount;
return ++newIndentCount;
}
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
+
import org.opendaylight.mdsal.binding.javav2.generator.util.AbstractBaseType;
import org.opendaylight.mdsal.binding.javav2.model.api.AnnotationType;
import org.opendaylight.mdsal.binding.javav2.model.api.Constant;
private final YangSourceDefinition definition;
private final BindingNamespaceType namespaceType;
- public AbstractGeneratedType(final AbstractGeneratedTypeBuilder<?> builder) {
+ AbstractGeneratedType(final AbstractGeneratedTypeBuilder<?> builder) {
super(builder.getPackageName(), builder.getName(), true, null);
this.parent = builder.getParent();
this.parentTypeForBuilder = builder.getParentTypeForBuilder();
}
}
- private static List<GeneratedType> toUnmodifiableEnclosedTypes(final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
- final List<GeneratedTOBuilder> enclosedGenTOBuilders) {
- final ArrayList<GeneratedType> enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size() + enclosedGenTOBuilders.size());
- enclosedTypesList.addAll(enclosedGenTypeBuilders.stream().filter(Objects::nonNull).map(GeneratedTypeBuilder::toInstance).collect(Collectors.toList()));
+ private static List<GeneratedType> toUnmodifiableEnclosedTypes(
+ final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+ final List<GeneratedTOBuilder> enclosedGenTOBuilders) {
+ final ArrayList<GeneratedType> enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size()
+ + enclosedGenTOBuilders.size());
+ enclosedTypesList.addAll(enclosedGenTypeBuilders.stream().filter(Objects::nonNull)
+ .map(GeneratedTypeBuilder::toInstance).collect(Collectors.toList()));
- enclosedTypesList.addAll(enclosedGenTOBuilders.stream().filter(Objects::nonNull).map(GeneratedTOBuilder::toInstance).collect(Collectors.toList()));
+ enclosedTypesList.addAll(enclosedGenTOBuilders.stream().filter(Objects::nonNull)
+ .map(GeneratedTOBuilder::toInstance).collect(Collectors.toList()));
return makeUnmodifiable(enclosedTypesList);
}
- protected static final List<AnnotationType> toUnmodifiableAnnotations(final List<AnnotationTypeBuilder> annotationBuilders) {
+ protected static final List<AnnotationType> toUnmodifiableAnnotations(final List<AnnotationTypeBuilder>
+ annotationBuilders) {
final List<AnnotationType> annotationList = new ArrayList<>(annotationBuilders.size());
- annotationList.addAll(annotationBuilders.stream().map(AnnotationTypeBuilder::toInstance).collect(Collectors.toList()));
+ annotationList.addAll(annotationBuilders.stream().map(AnnotationTypeBuilder::toInstance).collect(Collectors
+ .toList()));
return makeUnmodifiable(annotationList);
}
protected final List<MethodSignature> toUnmodifiableMethods(final List<MethodSignatureBuilder> methodBuilders) {
final List<MethodSignature> methods = new ArrayList<>(methodBuilders.size());
- methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this)).collect(Collectors.toList()));
+ methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this))
+ .collect(Collectors.toList()));
return makeUnmodifiable(methods);
}
protected final List<Enumeration> toUnmodifiableEnumerations(final List<EnumBuilder> enumBuilders) {
final List<Enumeration> enums = new ArrayList<>(enumBuilders.size());
- enums.addAll(enumBuilders.stream().map(enumBuilder -> enumBuilder.toInstance(this)).collect(Collectors.toList()));
+ enums.addAll(enumBuilders.stream().map(enumBuilder -> enumBuilder.toInstance(this))
+ .collect(Collectors.toList()));
return makeUnmodifiable(enums);
}
- protected final List<GeneratedProperty> toUnmodifiableProperties(final List<GeneratedPropertyBuilder> methodBuilders) {
+ protected final List<GeneratedProperty> toUnmodifiableProperties(final List<GeneratedPropertyBuilder>
+ methodBuilders) {
final List<GeneratedProperty> methods = new ArrayList<>(methodBuilders.size());
- methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this)).collect(Collectors.toList()));
+ methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this))
+ .collect(Collectors.toList()));
return makeUnmodifiable(methods);
}
} else {
builder.append(", parent=null");
}
- final TypeComment comment = getComment();
- if (comment != null) {
+
+ if (getComment() != null) {
builder.append(", comment=");
- builder.append(comment.getJavadoc());
+ builder.append(getComment().getJavadoc());
}
builder.append(", annotations=");
builder.append(this.annotations);
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
+
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+
import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
import org.opendaylight.mdsal.binding.javav2.generator.util.AbstractBaseType;
import org.opendaylight.mdsal.binding.javav2.model.api.AccessModifier;
}
protected AbstractGeneratedTypeBuilder(final String packageName, final String name, final boolean isNormalized,
- ModuleContext context) {
+ ModuleContext context) {
super(packageName, name, true, null);
}
- protected AbstractGeneratedTypeBuilder(final String packageName, final String name, final boolean isPkNameNormalized,
- final boolean isTypeNormalized, ModuleContext context) {
+ protected AbstractGeneratedTypeBuilder(final String packageName, final String name,
+ final boolean isPkNameNormalized, final boolean isTypeNormalized, ModuleContext context) {
super(packageName, name, isPkNameNormalized, isTypeNormalized, context);
}
Preconditions.checkArgument(name != null, "Name for Enclosing Generated Transfer Object cannot be null!");
GeneratedTOBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name, true);
- Preconditions.checkArgument(!enclosedTransferObjects.contains(builder), "This generated type already contains equal enclosing transfer object.");
+ Preconditions.checkArgument(!enclosedTransferObjects.contains(builder),
+ "This generated type already contains equal enclosing transfer object.");
enclosedTransferObjects = LazyCollections.lazyAdd(enclosedTransferObjects, builder);
return builder;
}
@Override
public T addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder) {
Preconditions.checkArgument(genTOBuilder != null, "Parameter genTOBuilder cannot be null!");
- Preconditions.checkArgument(!enclosedTransferObjects.contains(genTOBuilder), "This generated type already contains equal enclosing transfer object.");
+ Preconditions.checkArgument(!enclosedTransferObjects.contains(genTOBuilder),
+ "This generated type already contains equal enclosing transfer object.");
enclosedTransferObjects = LazyCollections.lazyAdd(enclosedTransferObjects, genTOBuilder);
return thisInstance();
}
@Override
- public T addComment(final TypeComment comment) {
- this.comment = Preconditions.checkNotNull(comment);
+ public T addComment(final TypeComment typeComment) {
+ this.comment = Preconditions.checkNotNull(typeComment);
return thisInstance();
}
final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
- Preconditions.checkArgument(!annotationBuilders.contains(builder), "This generated type already contains equal annotation.");
+ Preconditions.checkArgument(!annotationBuilders.contains(builder),
+ "This generated type already contains equal annotation.");
annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
return builder;
}
@Override
- public T setAbstract(final boolean isAbstract) {
- this.isAbstract = isAbstract;
+ public T setAbstract(final boolean isabstract) {
+ this.isAbstract = isabstract;
return thisInstance();
}
@Override
public T addImplementsType(final Type genType) {
Preconditions.checkArgument(genType != null, "Type cannot be null");
- Preconditions.checkArgument(!implementsTypes.contains(genType), "This generated type already contains equal implements type.");
+ Preconditions.checkArgument(!implementsTypes.contains(genType),
+ "This generated type already contains equal implements type.");
implementsTypes = LazyCollections.lazyAdd(implementsTypes, genType);
return thisInstance();
}
public Constant addConstant(final Type type, final String name, final Object value) {
Preconditions.checkArgument(type != null, "Returning Type for Constant cannot be null!");
Preconditions.checkArgument(name != null, "Name of constant cannot be null!");
- Preconditions.checkArgument(!containsConstant(name), "This generated type already contains constant with the same name.");
+ Preconditions.checkArgument(!containsConstant(name),
+ "This generated type already contains constant with the same name.");
final Constant constant = new ConstantImpl(this, type, name, value);
constants = LazyCollections.lazyAdd(constants, constant);
}
-
@Override
public Type setParentTypeForBuilder(Type type) {
return this.parentTypeForBuilder = type;
}
@Override
- public void setBindingNamespaceType(BindingNamespaceType namespaceType) {
- this.namespaceType = namespaceType;
+ public void setBindingNamespaceType(BindingNamespaceType type) {
+ this.namespaceType = type;
}
public boolean containsConstant(final String name) {
final EnumBuilder builder = new EnumerationBuilderImpl(getFullyQualifiedName(), name, true, false,
context);
- Preconditions.checkArgument(!enumDefinitions.contains(builder), "This generated type already contains equal enumeration.");
+ Preconditions.checkArgument(!enumDefinitions.contains(builder),
+ "This generated type already contains equal enumeration.");
enumDefinitions = LazyCollections.lazyAdd(enumDefinitions, builder);
return builder;
}
@Override
public GeneratedPropertyBuilder addProperty(final String name) {
Preconditions.checkArgument(name != null, "Parameter name can't be null");
- Preconditions.checkArgument(!containsProperty(name), "This generated type already contains property with the same name.");
+ Preconditions.checkArgument(!containsProperty(name),
+ "This generated type already contains property with the same name.");
final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name);
builder.setAccessModifier(AccessModifier.PUBLIC);
private AccessModifier accessModifier;
private List<AnnotationTypeBuilder> annotationBuilders = ImmutableList.of();
- public AbstractTypeMemberBuilder(final String name) {
+ AbstractTypeMemberBuilder(final String name) {
this.name = name;
}
@Override
- public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+ public AnnotationTypeBuilder addAnnotation(final String packageName, final String typeName) {
Preconditions.checkArgument(packageName != null, "Annotation Type cannot have package name null!");
- Preconditions.checkArgument(name != null, "Annotation Type cannot have name as null!");
+ Preconditions.checkArgument(typeName != null, "Annotation Type cannot have name as null!");
- final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+ final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, typeName);
annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
return builder;
}
}
@Override
- public T setReturnType(final Type returnType) {
- Preconditions.checkArgument(returnType != null, "Return Type of member cannot be null!");
- this.returnType = returnType;
+ public T setReturnType(final Type retType) {
+ Preconditions.checkArgument(retType != null, "Return Type of member cannot be null!");
+ this.returnType = retType;
return thisInstance();
}
}
@Override
- public T setComment(final String comment) {
- if (comment == null) {
+ public T setComment(final String commentText) {
+ if (commentText == null) {
this.comment = "";
}
- this.comment = comment;
+ this.comment = commentText;
return thisInstance();
}
@Override
- public T setFinal(final boolean isFinal) {
- this.isFinal = isFinal;
+ public T setFinal(final boolean finalOrNot) {
+ this.isFinal = finalOrNot;
return thisInstance();
}
@Override
- public T setStatic(final boolean isStatic) {
- this.isStatic = isStatic;
+ public T setStatic(final boolean staticOrNot) {
+ this.isStatic = staticOrNot;
return thisInstance();
}
private List<AnnotationTypeBuilder> annotationBuilders = ImmutableList.of();
private List<AnnotationType.Parameter> parameters = ImmutableList.of();
- public AnnotationTypeBuilderImpl(final String packageName, final String name) {
+ AnnotationTypeBuilderImpl(final String packageName, final String name) {
super(packageName, name, true, null);
this.packageName = packageName;
this.name = name;
}
@Override
- public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
- if (packageName != null && name != null) {
- final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+ public AnnotationTypeBuilder addAnnotation(final String pkgName, final String typeName) {
+ if (pkgName != null && typeName != null) {
+ final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(pkgName, typeName);
if (!annotationBuilders.contains(builder)) {
annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
return builder;
private final List<AnnotationType.Parameter> parameters;
private final List<String> paramNames;
- public AnnotationTypeImpl(final String packageName, final String name,
+ AnnotationTypeImpl(final String packageName, final String name,
final List<AnnotationTypeBuilder> annotationBuilders,
final List<AnnotationType.Parameter> parameters) {
this.packageName = packageName;
.compare(this.name, other.getName())
.compare(this.packageName, other.getPackageName())
//FIXME: what is natural ordering for AnnotationType?
- .compare(this.annotations, other.getAnnotations(), Ordering.<AnnotationType>natural().lexicographical())
+ .compare(this.annotations, other.getAnnotations(),
+ Ordering.<AnnotationType>natural().lexicographical())
.compare(this.paramNames, other.getParameterNames(), Ordering.<String>natural().lexicographical())
.result();
}
private final String value;
private final List<String> values;
- public ParameterImpl(final String name, final String value) {
+ ParameterImpl(final String name, final String value) {
this.name = name;
this.value = value;
this.values = ImmutableList.of();
}
- public ParameterImpl(final String name, final List<String> values) {
+ ParameterImpl(final String name, final List<String> values) {
this.name = name;
this.values = values;
this.value = null;
@Override
public int hashCode() {
- return Objects.hash(name);
+ return Objects.hash(name);
}
@Override
}
ConstantImpl other = (ConstantImpl) obj;
- return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value);
+ return Objects.equals(name, other.name) && Objects.equals(type, other.type)
+ && Objects.equals(value, other.value);
}
@Override
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
+
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+
import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
import org.opendaylight.mdsal.binding.javav2.generator.util.AbstractBaseType;
import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer;
}
public EnumerationBuilderImpl(final String packageName, final String name, final boolean isPkNameNormalized,
- final boolean isTypeNormalized, final ModuleContext context) {
+ final boolean isTypeNormalized, final ModuleContext context) {
super(packageName, name, isPkNameNormalized, isTypeNormalized, context);
}
}
@Override
- public void addValue(final String name, final int value, final String description, final String reference, final Status status) {
- final EnumPairImpl p = new EnumPairImpl(name, value, description, reference, status, this.values);
+ public void addValue(final String name, final int value, final String desc, final String ref,
+ final Status status) {
+ final EnumPairImpl p = new EnumPairImpl(name, value, desc, ref, status, this.values);
this.values = LazyCollections.lazyAdd(this.values, p);
}
@Override
public Enumeration toInstance(final Type definingType) {
- return new EnumerationImpl(definingType, this.annotationBuilders, this.packageName, this.name, this.values, this.description,
- this.reference, this.moduleName, this.schemaPath);
+ return new EnumerationImpl(definingType, this.annotationBuilders, this.packageName, this.name, this.values,
+ this.description, this.reference, this.moduleName, this.schemaPath);
}
@Override
private final String reference;
private final Status status;
- public EnumPairImpl(final String name, final int value, final String description,
- final String reference, final Status status, final List<Pair> values) {
+ EnumPairImpl(final String name, final int value, final String description,
+ final String reference, final Status status, final List<Pair> values) {
this.name = name;
this.mappedName = JavaIdentifierNormalizer.normalizeEnumValueIdentifier(name, values);
@Nonnull
@Override
public Status getStatus() {
- return this.status;
+ return this.status;
}
@Override
private final List<Pair> values;
private final List<AnnotationType> annotations;
- public EnumerationImpl(final Type definingType, final List<AnnotationTypeBuilder> annotationBuilders,
- final String packageName, final String name, final List<Pair> values, final String description,
- final String reference, final String moduleName, final List<QName> schemaPath) {
+ EnumerationImpl(final Type definingType, final List<AnnotationTypeBuilder> annotationBuilders,
+ final String packageName, final String name, final List<Pair> values, final String
+ description,
+ final String reference, final String moduleName, final List<QName> schemaPath) {
super(packageName, name, true, null);
this.definingType = definingType;
this.values = values;
builder.append(" {");
builder.append("\n");
- int i = 0;
+ int count = 0;
for (final Enumeration.Pair valPair : this.values) {
builder.append("\t");
builder.append(' ');
builder.append(" (");
builder.append(valPair.getValue());
- if (i == this.values.size() - 1) {
+ if (count == this.values.size() - 1) {
builder.append(" );");
} else {
builder.append(" ),");
}
- ++i;
+ ++count;
}
builder.append("\n}");
return builder.toString();
}
@Override
- public GeneratedPropertyBuilder setValue(String value) {
- this.value = value;
+ public GeneratedPropertyBuilder setValue(String valueString) {
+ this.value = valueString;
return this;
}
@Override
- public GeneratedPropertyBuilder setReadOnly(boolean isReadOnly) {
- this.isReadOnly = isReadOnly;
+ public GeneratedPropertyBuilder setReadOnly(boolean readOnlyOrNot) {
+ this.isReadOnly = readOnlyOrNot;
return this;
}
private String value;
private boolean isReadOnly;
- public GeneratedPropertyImpl(Type definingType, String name, List<AnnotationType> annotations, String comment,
+ GeneratedPropertyImpl(Type definingType, String name, List<AnnotationType> annotations, String comment,
AccessModifier accessModifier, Type returnType, boolean isFinal, boolean isStatic,
boolean isReadOnly, String value) {
super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
+
import java.util.List;
import java.util.Optional;
+
import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedProperty;
import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedTransferObject;
}
public GeneratedTOBuilderImpl(final String packageName, final String name, final boolean isPkNameNormalized,
- final boolean isTypeNormalized, ModuleContext context) {
+ final boolean isTypeNormalized, ModuleContext context) {
super(packageName, name, isPkNameNormalized, isTypeNormalized, context);
setAbstract(false);
}
* {TypeMemberBuilder#setFinal(boolean)} and
* {TypeMemberBuilder#setAccessModifier(boolean)}
*
- * @param name
- * Name of Method
+ * @param name Name of Method
* @return <code>new</code> instance of Method Signature Builder.
*/
@Override
}
@Override
- public void setTypedef(boolean isTypedef) {
- this.isTypedef = isTypedef;
+ public void setTypedef(boolean typedefOrNot) {
+ this.isTypedef = typedefOrNot;
}
@Override
}
@Override
- public void setIsUnionBuilder(boolean isUnionTypeBuilder) {
- this.isUnionTypeBuilder = isUnionTypeBuilder;
+ public void setIsUnionBuilder(boolean unionTypeBuilderOrNot) {
+ this.isUnionTypeBuilder = unionTypeBuilderOrNot;
}
@Override
- public void setSUID(GeneratedPropertyBuilder suid) {
- this.suid = suid;
+ public void setSUID(GeneratedPropertyBuilder suidBuilder) {
+ this.suid = suidBuilder;
}
@Override
return builder.toString();
}
- private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements GeneratedTransferObject {
+ private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements
+ GeneratedTransferObject {
private final List<GeneratedProperty> equalsProperties;
private final List<GeneratedProperty> hashCodeProperties;
private final String moduleName;
private final List<QName> schemaPath;
- public GeneratedTransferObjectImpl(final GeneratedTOBuilderImpl builder) {
+ GeneratedTransferObjectImpl(final GeneratedTOBuilderImpl builder) {
super(builder);
this.extendsType = builder.extendsType;
private final String moduleName;
private final List<QName> schemaPath;
- public GeneratedTypeImpl(final GeneratedTypeBuilderImpl builder) {
+ GeneratedTypeImpl(final GeneratedTypeBuilderImpl builder) {
super(builder);
this.description = builder.description;
private final String basePackageName;
private final String builderPackageName;
- public GeneratedTypeWithBuilderImpl(GeneratedTypeBuilderImpl builder) {
+ GeneratedTypeWithBuilderImpl(GeneratedTypeBuilderImpl builder) {
super(builder);
Preconditions.checkState(builder.getBasePackageName() != null,
"Base package name can not be null for type with builder!");
private final String name;
private final Type type;
- public MethodParameterImpl(final String name, final Type type) {
+ MethodParameterImpl(final String name, final Type type) {
this.name = name;
this.type = type;
}
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
+
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+
import org.opendaylight.mdsal.binding.javav2.model.api.AnnotationType;
import org.opendaylight.mdsal.binding.javav2.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.javav2.model.api.Type;
import org.opendaylight.yangtools.util.LazyCollections;
@Beta
-final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder> implements MethodSignatureBuilder {
+final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder> implements
+ MethodSignatureBuilder {
private List<MethodSignature.Parameter> parameters = ImmutableList.of();
- private List<MethodSignature.Parameter> unmodifiableParams = ImmutableList.of();
+ private List<MethodSignature.Parameter> unmodifiableParams = ImmutableList.of();
private boolean isAbstract;
- public MethodSignatureBuilderImpl(final String name) {
+ MethodSignatureBuilderImpl(final String name) {
super(name);
}
@Override
- public MethodSignatureBuilder setAbstract(final boolean isAbstract) {
- this.isAbstract = isAbstract;
+ public MethodSignatureBuilder setAbstract(final boolean abstractOrNot) {
+ this.isAbstract = abstractOrNot;
return this;
}
private final List<Parameter> params;
private final boolean isAbstract;
- public MethodSignatureImpl(final Type definingType, final String name,
+ MethodSignatureImpl(final Type definingType, final String name,
final List<AnnotationType> annotations,
final String comment, final AccessModifier accessModifier,
final Type returnType, final List<Parameter> params, final boolean isFinal,
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
import org.opendaylight.mdsal.binding.javav2.util.BindingMapping;
// Augmentable - reserved & non reserved
normalizeIdentifier = JavaIdentifierNormalizer
- .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable", context);
+ .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable",
+ context);
assertEquals("Augmentable", normalizeIdentifier);
// again reserved
normalizeIdentifier = JavaIdentifierNormalizer
- .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable", context);
+ .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable",
+ context);
assertEquals("Augmentable", normalizeIdentifier);
// non reserved
normalizeIdentifier = JavaIdentifierNormalizer
normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("java.lang", "String", context);
assertEquals("String", normalizeIdentifier);
// non reserved
- normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String", context);
+ normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String",
+ context);
assertEquals("String", normalizeIdentifier);
// again non reserved
- normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String", context);
+ normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String",
+ context);
assertEquals("String1", normalizeIdentifier);
}
String normalizeIdentifier2 =
JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next", "fOo", context);
final String normalizeIdentifier3 =
- JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next.next", "foo", context);
+ JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next.next", "foo",
+ context);
assertEquals(normalizeIdentifier1, "Foo");
assertEquals(normalizeIdentifier2, "Foo");
assertEquals(normalizeIdentifier3, "Foo");
normalizeIdentifier1 = JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package", "*",
context);
normalizeIdentifier2 =
- JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next", "asterisk", context);
+ JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next", "asterisk",
+ context);
assertEquals(normalizeIdentifier1, "Asterisk");
assertEquals(normalizeIdentifier2, "Asterisk");
}
final String normalizeIdentifier1 =
JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package", "int", context);
final String normalizeIdentifier2 =
- JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package.next", "InT", context);
+ JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package.next", "InT",
+ context);
final String normalizeIdentifier3 =
JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package.next.next",
"inT", context);
}
private void assertTest(final String testedIdentifier, final String acceptable,
- final JavaIdentifier javaTypeOfIdentifier) {
+ final JavaIdentifier javaTypeOfIdentifier) {
final String convertedIdentifier =
JavaIdentifierNormalizer.normalizeSpecificIdentifier(testedIdentifier, javaTypeOfIdentifier);
assertNotNull(convertedIdentifier);
@Test
public void sameEnumTest() {
ModuleContext context = new ModuleContext();
- EnumerationBuilderImpl enumerationBuilderImpl = new EnumerationBuilderImpl("package.same.test", "test", context);
+ EnumerationBuilderImpl enumerationBuilderImpl = new EnumerationBuilderImpl("package.same.test", "test",
+ context);
Enumeration enumeration = enumerationBuilderImpl.toInstance(enumerationBuilderImpl);
String formattedString = enumeration.toFormattedString();