This fixes violations and flips enforcement on.
Change-Id: Ibc12e6595498c4349695d62bcd74f3d126f4b8e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
<artifactId>yang-test-util</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.model.api.Type;
/**
- * It is used only as ancestor for other <code>Type</code>s
+ * It is used only as ancestor for other <code>Type</code>s.
*/
public class AbstractBaseType implements Type {
/**
import org.opendaylight.mdsal.binding.model.api.type.builder.TypeMemberBuilder;
import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
public final class BindingGeneratorUtil {
/**
- * Impossible to instantiate this class. All of the methods or attributes
- * are static.
+ * Impossible to instantiate this class. All of the methods or attributes are static.
*/
private BindingGeneratorUtil() {
+
}
/**
private static final Comparator<Type> SUID_NAME_COMPARATOR = Comparator.comparing(Type::getFullyQualifiedName);
/**
- * Converts <code>parameterName</code> to valid JAVA parameter name.
- *
- * If the <code>parameterName</code> is one of the JAVA reserved words then
- * it is prefixed with underscore character.
+ * Converts <code>parameterName</code> to valid JAVA parameter name. If the <code>parameterName</code> is one
+ * of the JAVA reserved words then it is prefixed with underscore character.
*
- * @param parameterName
- * string with the parameter name
+ * @param parameterName string with the parameter name
* @return string with the admissible parameter name
*/
public static String resolveJavaReservedWordEquivalency(final String parameterName) {
}
/**
- * Creates package name from specified <code>basePackageName</code> (package
- * name for module) and <code>schemaPath</code>.
- *
- * 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.
+ * Creates package name from specified <code>basePackageName</code> (package name for module)
+ * and <code>schemaPath</code>. 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.
*
- * @param basePackageName
- * string with package name of the module, MUST be normalized,
- * otherwise this method may return an invalid string.
- * @param schemaPath
- * list of names of YANG nodes which are parents of some node +
- * name of this node
+ * @param basePackageName string with package name of the module, MUST be normalized, otherwise this method may
+ * return an invalid string.
+ * @param schemaPath list of names of YANG nodes which are parents of some node + name of this node
* @return string with valid JAVA package name
* @throws NullPointerException if any of the arguments are null
*/
}
/**
- * Creates package name from specified <code>basePackageName</code> (package
- * name for module) and <code>schemaPath</code> which crosses an augmentation.
+ * Creates package name from specified <code>basePackageName</code> (package name for module)
+ * and <code>schemaPath</code> which crosses an augmentation. 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.
*
- * 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.
- *
- * @param basePackageName
- * string with package name of the module, MUST be normalized,
- * otherwise this method may return an invalid string.
- * @param schemaPath
- * list of names of YANG nodes which are parents of some node +
- * name of this node
+ * @param basePackageName string with package name of the module, MUST be normalized, otherwise this method may
+ * return an invalid string.
+ * @param schemaPath list of names of YANG nodes which are parents of some node + name of this node
* @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 int size = Iterables.size(schemaPath.getPathTowardsRoot());
if (size == 0) {
return basePackageName;
}
/**
- *
* Converts string <code>token</code> to the cammel case format.
*
- * @param token
- * string which should be converted to the cammel case format
- * @param uppercase
- * boolean value which says whether the first character of the
- * <code>token</code> should|shuldn't be uppercased
- * @return string in the cammel case format
+ * @param token string which should be converted to the cammel case format
+ * @param uppercase boolean value which says whether the first character of the <code>token</code> should be
+ * upper-cased or not
+ * @return string in the camel case format
* @throws IllegalArgumentException
* <ul>
* <li>if <code>token</code> without white spaces is empty</li>
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);
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;
}
/**
- * 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
*/
return description;
}
- 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.model.api.JavaTypeName;
/**
- *
- * Wraps combination of <code>packageName</code> and <code>name</code> to the
- * object representation
+ * Wraps combination of <code>packageName</code> and <code>name</code> to the 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 identifier JavaTypeName of the referenced type
*/
.addEscape('@', "@").build();
private static final Pattern TAIL_COMMENT_PATTERN = Pattern.compile("*/", Pattern.LITERAL);
+ private TypeComments() {
+
+ }
+
/**
* 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.
private static final ConcreteType SET_TYPE = typeForClass(Set.class);
/**
- * It is not desirable to create instance of this class
+ * It is not desirable to create instance of this class.
*/
private Types() {
}
}
/**
- * 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) {
}
/**
- * Returns an instance of {@link ParameterizedType} describing the typed
- * {@link Map}<K,V>
+ * 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.
+ * 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.
+ * 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) {
}
/**
- * Returns an instance of {@link ParameterizedType} describing the typed
- * {@link ListenableFuture}<V> with concrete type of value.
+ * Returns an instance of {@link ParameterizedType} describing the typed {@link ListenableFuture}<V>
+ * with concrete type of value.
*
- * @param valueType
- * Value Type
+ * @param valueType Value Type
* @return Description of type instance of ListenableFuture
*/
public static ParameterizedType listenableFutureTypeFor(final Type valueType) {
}
/**
- * Creates instance of type
- * {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType
- * ParameterizedType}
+ * Creates instance of type {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType ParameterizedType}.
*
- * @param type
- * JAVA <code>Type</code> for raw type
- * @param parameters
- * JAVA <code>Type</code>s for actual parameter types
- * @return <code>ParametrizedType</code> representation of <code>type</code>
- * and its parameters <code>parameters</code>
+ * @param type JAVA <code>Type</code> for raw type
+ * @param parameters JAVA <code>Type</code>s for actual parameter types
+ * @return <code>ParametrizedType</code> representation of <code>type</code> and its <code>parameters</code>
* @throws NullPointerException if any argument or any member of {@code parameters} is null
*/
public static ParameterizedType parameterizedTypeFor(final Type type, final Type... parameters) {
* {@link org.opendaylight.yangtools.yang.binding.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>
}
/**
- * Creates instance of
- * {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType
- * ParameterizedType} where raw type is
- * {@link org.opendaylight.yangtools.yang.binding.Augmentation} and actual
- * parameter is <code>valueType</code>.
+ * Creates instance of {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType ParameterizedType} where
+ * raw type is {@link org.opendaylight.yangtools.yang.binding.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>
}
/**
- *
* Represents concrete JAVA type.
- *
*/
private static final class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType {
private final Restrictions restrictions;
/**
- * Creates instance of this class with package <code>pkName</code> and
- * with the type name <code>name</code>.
+ * 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
*/
ConcreteTypeImpl(final JavaTypeName identifier, final Restrictions restrictions) {
super(identifier);
/**
* 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>.
+ * 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
*/
BaseTypeWithRestrictionsImpl(final JavaTypeName identifier, final Restrictions restrictions) {
super(identifier);
private final Type[] actualTypes;
/**
- * JAVA raw type (like List, Set, Map...)
+ * JAVA raw type (like List, Set, Map...).
*/
private final Type rawType;
- @Override
- public Type[] getActualTypeArguments() {
-
- return this.actualTypes;
- }
-
- @Override
- public Type getRawType() {
- return this.rawType;
- }
-
/**
- * Creates instance of this class with concrete rawType and array of
- * actual parameters.
+ * 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 ParametrizedTypeImpl(final Type rawType, final Type[] actTypes) {
+ ParametrizedTypeImpl(final Type rawType, final Type[] actTypes) {
super(rawType.getIdentifier());
this.rawType = requireNonNull(rawType);
actualTypes = actTypes.clone();
throw new NullPointerException("actTypes contains a null");
}
}
+
+ @Override
+ public Type[] getActualTypeArguments() {
+
+ return this.actualTypes;
+ }
+
+ @Override
+ public Type getRawType() {
+ return this.rawType;
+ }
}
/**
/**
* 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
*/
WildcardTypeImpl(final JavaTypeName identifier) {
super(identifier);
}
}
- public static <T extends Number& Comparable<T>> DefaultRestrictions<T> getDefaultRestrictions(final T min,
+ public static <T extends Number & Comparable<T>> DefaultRestrictions<T> getDefaultRestrictions(final T min,
final T max) {
return new DefaultRestrictions<>(min, max);
}
import org.opendaylight.mdsal.binding.model.api.Enumeration;
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.Type;
-import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
import org.opendaylight.mdsal.binding.model.util.AbstractBaseType;
public abstract void setSchemaPath(SchemaPath schemaPath);
abstract AbstractPair createEnumPair(String name, String mappedName, int value, Status status, String description,
- final String reference);
+ String reference);
/*
* (non-Javadoc)
builder.append(" {");
builder.append("\n");
- int i = 0;
+ int offset = 0;
for (final Enumeration.Pair valPair : this.values) {
- builder.append("\t");
- builder.append(" ");
+ builder.append("\t ");
builder.append(valPair.getMappedName());
builder.append(" (");
builder.append(valPair.getValue());
- if (i == this.values.size() - 1) {
+ if (offset == this.values.size() - 1) {
builder.append(" );");
} else {
builder.append(" ),");
}
- ++i;
+ ++offset;
}
builder.append("\n}");
return builder.toString();
}
@Override
- public final void setTypedef(final boolean isTypedef) {
- this.isTypedef = isTypedef;
+ public final void setTypedef(final boolean newIsTypedef) {
+ this.isTypedef = newIsTypedef;
}
@Override
}
@Override
- public final void setIsUnion(final boolean isUnion) {
- this.isUnionType = isUnion;
+ public final void setIsUnion(final boolean newIsUnion) {
+ this.isUnionType = newIsUnion;
}
@Override
}
@Override
- public final void setIsUnionBuilder(final boolean isUnionTypeBuilder) {
- this.isUnionTypeBuilder = isUnionTypeBuilder;
+ public final void setIsUnionBuilder(final boolean newIsUnionTypeBuilder) {
+ this.isUnionTypeBuilder = newIsUnionTypeBuilder;
}
- static abstract class AbstractGeneratedTransferObject extends AbstractGeneratedType implements
- GeneratedTransferObject {
+ abstract static class AbstractGeneratedTransferObject extends AbstractGeneratedType implements
+ GeneratedTransferObject {
private final List<GeneratedProperty> equalsProperties;
private final List<GeneratedProperty> hashCodeProperties;
import org.opendaylight.mdsal.binding.model.api.Enumeration;
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.api.TypeComment;
-import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.YangSourceDefinition;
import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
protected static final <T> List<T> makeUnmodifiable(final List<T> list) {
switch (list.size()) {
- case 0:
- return Collections.emptyList();
- case 1:
- return Collections.singletonList(list.get(0));
- default:
- return Collections.unmodifiableList(list);
+ case 0:
+ return Collections.emptyList();
+ case 1:
+ return Collections.singletonList(list.get(0));
+ default:
+ return Collections.unmodifiableList(list);
}
}
- private static List<GeneratedType> toUnmodifiableEnclosedTypes(final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+ private static List<GeneratedType> toUnmodifiableEnclosedTypes(
+ final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
final List<GeneratedTOBuilder> enclosedGenTOBuilders) {
- final ArrayList<GeneratedType> enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size() + enclosedGenTOBuilders.size());
+ final ArrayList<GeneratedType> enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size()
+ + enclosedGenTOBuilders.size());
for (final GeneratedTypeBuilder builder : enclosedGenTypeBuilders) {
if (builder != null) {
enclosedTypesList.add(builder.build());
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());
for (final GeneratedPropertyBuilder methodBuilder : methodBuilders) {
methods.add(methodBuilder.toInstance(this));
*/
package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@Override
public GeneratedTOBuilder addEnclosingTransferObject(final String name) {
- Preconditions.checkArgument(name != null, "Name for Enclosing Generated Transfer Object cannot be null!");
+ checkArgument(name != null, "Name for Enclosing Generated Transfer Object cannot be null!");
final GeneratedTOBuilder builder = new CodegenGeneratedTOBuilder(getIdentifier().createEnclosed(name));
- Preconditions.checkArgument(!this.enclosedTransferObjects.contains(builder),
+ checkArgument(!enclosedTransferObjects.contains(builder),
"This generated type already contains equal enclosing transfer object.");
this.enclosedTransferObjects = LazyCollections.lazyAdd(this.enclosedTransferObjects, builder);
return builder;
@Override
public T addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder) {
- Preconditions.checkArgument(genTOBuilder != null, "Parameter genTOBuilder cannot be null!");
- Preconditions.checkArgument(!this.enclosedTransferObjects.contains(genTOBuilder),
+ checkArgument(genTOBuilder != null, "Parameter genTOBuilder cannot be null!");
+ checkArgument(!enclosedTransferObjects.contains(genTOBuilder),
"This generated type already contains equal enclosing transfer object.");
this.enclosedTransferObjects = LazyCollections.lazyAdd(this.enclosedTransferObjects, genTOBuilder);
return thisInstance();
}
@Override
- public T addComment(final TypeComment comment) {
- this.comment = Preconditions.checkNotNull(comment);
+ public T addComment(final TypeComment newComment) {
+ this.comment = requireNonNull(newComment);
return thisInstance();
}
public AnnotationTypeBuilder addAnnotation(final JavaTypeName identifier) {
final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(identifier);
- Preconditions.checkArgument(!this.annotationBuilders.contains(builder),
- "This generated type already contains equal annotation.");
+ checkArgument(!annotationBuilders.contains(builder), "This generated type already contains equal annotation.");
this.annotationBuilders = LazyCollections.lazyAdd(this.annotationBuilders, builder);
return builder;
}
@Override
- public T setAbstract(final boolean isAbstract) {
- this.isAbstract = isAbstract;
+ public T setAbstract(final boolean newIsAbstract) {
+ this.isAbstract = newIsAbstract;
return thisInstance();
}
@Override
public T addImplementsType(final Type genType) {
- Preconditions.checkArgument(genType != null, "Type cannot be null");
- Preconditions.checkArgument(!this.implementsTypes.contains(genType),
+ checkArgument(genType != null, "Type cannot be null");
+ checkArgument(!implementsTypes.contains(genType),
"This generated type already contains equal implements type.");
this.implementsTypes = LazyCollections.lazyAdd(this.implementsTypes, genType);
return thisInstance();
@Override
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),
+ checkArgument(type != null, "Returning Type for Constant cannot be null!");
+ checkArgument(name != null, "Name of constant cannot be null!");
+ checkArgument(!containsConstant(name),
"This generated type already contains constant with the same name.");
final Constant constant = new ConstantImpl(this, type, name, value);
}
public boolean containsConstant(final String name) {
- Preconditions.checkArgument(name != null, "Parameter name can't be null");
+ checkArgument(name != null, "Parameter name can't be null");
for (final Constant constant : this.constants) {
if (name.equals(constant.getName())) {
return true;
@Override
public EnumBuilder addEnumeration(String name) {
- Preconditions.checkArgument(name != null, "Name of enumeration cannot be null!");
+ checkArgument(name != null, "Name of enumeration cannot be null!");
// This enumeration may be generated from a leaf, which may end up colliding with its enclosing type
// hierarchy. Check it and assign another name if that should be the case.
}
final EnumBuilder builder = newEnumerationBuilder(getIdentifier().createEnclosed(name));
- Preconditions.checkArgument(!this.enumDefinitions.contains(builder),
+ checkArgument(!enumDefinitions.contains(builder),
"Generated type %s already contains an enumeration for %s", this, builder);
this.enumDefinitions = LazyCollections.lazyAdd(this.enumDefinitions, builder);
return builder;
@Override
public MethodSignatureBuilder addMethod(final String name) {
- Preconditions.checkArgument(name != null, "Name of method cannot be null!");
+ checkArgument(name != null, "Name of method cannot be null!");
final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name);
builder.setAccessModifier(AccessModifier.PUBLIC);
builder.setAbstract(true);
@Override
public boolean containsMethod(final String name) {
- Preconditions.checkArgument(name != null, "Parameter name can't be null");
+ checkArgument(name != null, "Parameter name can't be null");
for (final MethodSignatureBuilder methodDefinition : this.methodDefinitions) {
if (name.equals(methodDefinition.getName())) {
return true;
@Override
public GeneratedPropertyBuilder addProperty(final String name) {
- Preconditions.checkArgument(name != null, "Parameter name can't be null");
- Preconditions.checkArgument(!containsProperty(name),
+ checkArgument(name != null, "Parameter name can't be null");
+ checkArgument(!containsProperty(name),
"This generated type already contains property with the same name.");
final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name);
@Override
public boolean containsProperty(final String name) {
- Preconditions.checkArgument(name != null, "Parameter name can't be null");
+ checkArgument(name != null, "Parameter name can't be null");
for (final GeneratedPropertyBuilder property : this.properties) {
if (name.equals(property.getName())) {
return true;
@Override
public void setYangSourceDefinition(final YangSourceDefinition definition) {
- yangSourceDefinition = Preconditions.checkNotNull(definition);
+ yangSourceDefinition = requireNonNull(definition);
}
@Override
*/
package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import org.opendaylight.mdsal.binding.model.api.AccessModifier;
import org.opendaylight.mdsal.binding.model.api.AnnotationType;
-import org.opendaylight.mdsal.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.api.type.builder.AnnotationTypeBuilder;
import org.opendaylight.mdsal.binding.model.api.type.builder.TypeMemberBuilder;
import org.opendaylight.yangtools.util.LazyCollections;
private boolean isStatic;
private AccessModifier accessModifier;
- public AbstractTypeMemberBuilder(final String name) {
+ AbstractTypeMemberBuilder(final String name) {
this.name = name;
}
protected abstract T thisInstance();
@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 newReturnType) {
+ checkArgument(newReturnType != null, "Return Type of member cannot be null!");
+ this.returnType = newReturnType;
return thisInstance();
}
@Override
public T setAccessModifier(final AccessModifier modifier) {
- Preconditions.checkArgument(modifier != null, "Access Modifier for member type cannot be null!");
+ checkArgument(modifier != null, "Access Modifier for member type cannot be null!");
this.accessModifier = modifier;
return thisInstance();
}
@Override
- public T setComment(final String comment) {
- if (comment == null) {
- this.comment = "";
- }
- this.comment = comment;
+ public T setComment(final String newComment) {
+ this.comment = newComment;
return thisInstance();
}
@Override
- public T setFinal(final boolean isFinal) {
- this.isFinal = isFinal;
+ public T setFinal(final boolean newIsFinal) {
+ this.isFinal = newIsFinal;
return thisInstance();
}
@Override
- public T setStatic(final boolean isStatic) {
- this.isStatic = isStatic;
+ public T setStatic(final boolean newIsStatic) {
+ this.isStatic = newIsStatic;
return thisInstance();
}
return new AnnotationTypeImpl(getIdentifier(), this.annotationBuilders, this.parameters);
}
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
@Override
public boolean equals(final Object obj) {
if (this == obj) {
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 = Collections.emptyList();
}
- 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;
import java.util.Optional;
import org.opendaylight.mdsal.binding.model.api.Enumeration;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.api.TypeComment;
-import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.YangSourceDefinition;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@Override
EnumPair createEnumPair(final String name, final String mappedName, final int value, final Status status,
- final String description, final String reference) {
- return new EnumPair(name, mappedName, value, status, description, reference);
+ final String enumDescription, final String enumReference) {
+ return new EnumPair(name, mappedName, value, status, enumDescription, enumReference);
}
private static final class EnumPair extends AbstractPair {
private final String reference;
private final Status status;
- EnumPair(final String name, final String mappedName, final int value, final Status status, final String description,
- final String reference) {
+ EnumPair(final String name, final String mappedName, final int value, final Status status,
+ final String description, final String reference) {
super(name, mappedName, value);
this.status = requireNonNull(status);
this.description = description;
}
private static final class EnumerationImpl extends AbstractEnumeration {
-
private final String description;
private final String reference;
private final String moduleName;
public final class CodegenGeneratedTOBuilder extends AbstractGeneratedTOBuilder {
private Restrictions restrictions;
- private GeneratedPropertyBuilder SUID;
+ private GeneratedPropertyBuilder suid;
private String reference;
private String description;
private String moduleName;
}
@Override
- public void setSUID(final GeneratedPropertyBuilder suid) {
- this.SUID = suid;
+ public void setSUID(final GeneratedPropertyBuilder newSuid) {
+ this.suid = newSuid;
}
@Override
private static final class GTO extends AbstractGeneratedTransferObject {
private final Restrictions restrictions;
- private final GeneratedProperty SUID;
+ private final GeneratedProperty suid;
private final String reference;
private final String description;
private final String moduleName;
this.moduleName = builder.moduleName;
this.schemaPath = builder.schemaPath;
- if (builder.SUID == null) {
- this.SUID = null;
+ if (builder.suid == null) {
+ this.suid = null;
} else {
- this.SUID = builder.SUID.toInstance(GTO.this);
+ this.suid = builder.suid.toInstance(GTO.this);
}
}
@Override
public GeneratedProperty getSUID() {
- return this.SUID;
+ return this.suid;
}
@Override
package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
-import org.opendaylight.mdsal.binding.model.api.TypeComment;
import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.TypeComment;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
private final String moduleName;
private final SchemaPath schemaPath;
- public GeneratedTypeImpl(final CodegenGeneratedTypeBuilder builder) {
+ GeneratedTypeImpl(final CodegenGeneratedTypeBuilder builder) {
super(builder);
this.description = builder.description;
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (obj == null || getClass() != obj.getClass()) {
return false;
}
final ConstantImpl other = (ConstantImpl) obj;
- return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type) && Objects.equals(this.value, other.value);
+ return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type)
+ && Objects.equals(this.value, other.value);
}
@Override
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
-public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder<GeneratedPropertyBuilder> implements GeneratedPropertyBuilder {
+public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder<GeneratedPropertyBuilder>
+ implements GeneratedPropertyBuilder {
private String value;
- private boolean isReadOnly;
+ private boolean readOnly;
public GeneratedPropertyBuilderImpl(final String name) {
super(name);
- this.isReadOnly = true;
+ this.readOnly = true;
}
@Override
@Override
public GeneratedPropertyBuilderImpl setReadOnly(final boolean isReadOnly) {
- this.isReadOnly = isReadOnly;
+ this.readOnly = isReadOnly;
return this;
}
public GeneratedProperty toInstance(final Type definingType) {
final List<AnnotationType> annotations = toAnnotationTypes();
return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
- getReturnType(), isFinal(), isStatic(), this.isReadOnly, this.value);
+ getReturnType(), isFinal(), isStatic(), this.readOnly, this.value);
}
@Override
builder.append(", isFinal=");
builder.append(isFinal());
builder.append(", isReadOnly=");
- builder.append(this.isReadOnly);
+ builder.append(this.readOnly);
builder.append(", modifier=");
builder.append(getAccessModifier());
builder.append("]");
final class GeneratedPropertyImpl extends AbstractTypeMember implements GeneratedProperty {
private final String value;
- private final boolean isReadOnly;
+ private final boolean readOnly;
- public GeneratedPropertyImpl(final Type definingType, final String name, final List<AnnotationType> annotations, final String comment,
- final AccessModifier accessModifier, final Type returnType, final boolean isFinal, final boolean isStatic, final boolean isReadOnly, final String value) {
+ GeneratedPropertyImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
+ final String comment, final AccessModifier accessModifier, final Type returnType, final boolean isFinal,
+ final boolean isStatic, final boolean isReadOnly, final String value) {
super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
this.value = value;
- this.isReadOnly = isReadOnly;
+ this.readOnly = isReadOnly;
}
@Override
@Override
public boolean isReadOnly() {
- return this.isReadOnly;
+ return this.readOnly;
}
@Override
builder.append(", isFinal=");
builder.append(isFinal());
builder.append(", isReadOnly=");
- builder.append(this.isReadOnly);
+ builder.append(this.readOnly);
builder.append(", modifier=");
builder.append(getAccessModifier());
builder.append("]");
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;
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = (prime * result) + Objects.hashCode(this.name);
- result = (prime * result) + Objects.hashCode(this.type);
+ result = prime * result + Objects.hashCode(this.name);
+ result = prime * result + Objects.hashCode(this.type);
return result;
}
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (obj == null || getClass() != obj.getClass()) {
return false;
}
final MethodParameterImpl other = (MethodParameterImpl) obj;
import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
import org.opendaylight.yangtools.util.LazyCollections;
-final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder> implements MethodSignatureBuilder {
+final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder>
+ implements MethodSignatureBuilder {
private List<MethodSignature.Parameter> parameters = Collections.emptyList();
- private List<MethodSignature.Parameter> unmodifiableParams = Collections.emptyList();
+ private List<MethodSignature.Parameter> unmodifiableParams = Collections.emptyList();
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 newIsAbstract) {
+ this.isAbstract = newIsAbstract;
return this;
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = (prime * result) + Objects.hashCode(getName());
- result = (prime * result) + Objects.hashCode(this.parameters);
- result = (prime * result) + Objects.hashCode(getReturnType());
+ result = prime * result + Objects.hashCode(getName());
+ result = prime * result + Objects.hashCode(this.parameters);
+ result = prime * result + Objects.hashCode(getReturnType());
return result;
}
private final List<Parameter> params;
private final boolean isAbstract;
- public 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,
- final boolean isAbstract, final boolean isStatic) {
+ 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, final boolean isAbstract, final boolean isStatic) {
super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
this.params = params;
this.isAbstract = isAbstract;
public int hashCode() {
final int prime = 31;
int result = 1;
- result = (prime * result) + Objects.hashCode(getName());
- result = (prime * result) + Objects.hashCode(this.params);
- result = (prime * result) + Objects.hashCode(getReturnType());
+ result = prime * result + Objects.hashCode(getName());
+ result = prime * result + Objects.hashCode(this.params);
+ result = prime * result + Objects.hashCode(getReturnType());
return result;
}
import java.util.Optional;
import org.opendaylight.mdsal.binding.model.api.Enumeration;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.api.TypeComment;
-import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.YangSourceDefinition;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.mdsal.binding.model.api.Restrictions;
import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.Restrictions;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
-import org.opendaylight.mdsal.binding.model.api.TypeComment;
import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.TypeComment;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@Rule
public ExpectedException expectedEx = ExpectedException.none();
- /**
+ /*
* Tests methods:
* <ul>
* <li>moduleNamespaceToPackageName</li> - with revision
assertNotEquals(computedSUID, computedSUID2);
}
- /**
+ /*
* Test for the method
* <ul>
* <li>{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
BindingGeneratorUtil.packageNameForGeneratedType(null, null);
}
- /**
+ /*
* Test for the method
* <ul>
* <li>{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
BindingGeneratorUtil.packageNameForGeneratedType("test.package", null);
}
- /**
+ /*
* Test for the method
* <ul>
* <li>{@link BindingGeneratorUtil#resolveJavaReservedWordEquivalency(String)
BindingGeneratorUtil.resolveJavaReservedWordEquivalency("case"));
}
- /**
+ /*
* Tests the methods:
* <ul>
* <li>parseToClassName</li>
assertEquals("IDENTIFIER", typeForClass(Identifier.class), BindingTypes.IDENTIFIER);
assertEquals("INSTANCE_IDENTIFIER", typeForClass(InstanceIdentifier.class), BindingTypes.INSTANCE_IDENTIFIER);
assertEquals("NOTIFICATION", typeForClass(Notification.class), BindingTypes.NOTIFICATION);
- assertEquals("NOTIFICATION_LISTENER", typeForClass(NotificationListener.class), BindingTypes.NOTIFICATION_LISTENER);
+ assertEquals("NOTIFICATION_LISTENER", typeForClass(NotificationListener.class),
+ BindingTypes.NOTIFICATION_LISTENER);
assertEquals("RPC_SERVICE", typeForClass(RpcService.class), BindingTypes.RPC_SERVICE);
}
@Test
public void testEquals() {
- JavaTypeName baseType1 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test");
- JavaTypeName baseType2 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test2");
- JavaTypeName baseType3 = null;
- JavaTypeName baseType4 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test");
- JavaTypeName baseType5 = JavaTypeName.create("org.opendaylight.yangtools.test1", "Test");
+ final JavaTypeName baseType1 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test");
+ final JavaTypeName baseType2 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test2");
+ final JavaTypeName baseType4 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test");
+ final JavaTypeName baseType5 = JavaTypeName.create("org.opendaylight.yangtools.test1", "Test");
assertFalse(baseType1.equals(baseType2));
- assertFalse(baseType1.equals(baseType3));
+ assertFalse(baseType1.equals(null));
assertTrue(baseType1.equals(baseType4));
assertFalse(baseType1.equals(baseType5));
assertFalse(baseType1.equals(null));
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature;
public class AbstractTypeMemberTest {
@Test
public void annotationTypeBuilderEqualsTest() {
- AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
+ final AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
JavaTypeName.create("my.package", "MyName"));
- AnnotationTypeBuilder annotationTypeBuilder2 = new AnnotationTypeBuilderImpl(
+ final AnnotationTypeBuilder annotationTypeBuilder2 = new AnnotationTypeBuilderImpl(
JavaTypeName.create("my.package2", "MyName"));
- AnnotationTypeBuilder annotationTypeBuilder3 = new AnnotationTypeBuilderImpl(
+ final AnnotationTypeBuilder annotationTypeBuilder3 = new AnnotationTypeBuilderImpl(
JavaTypeName.create("my.package", "MyName2"));
- AnnotationTypeBuilder annotationTypeBuilder4 = new AnnotationTypeBuilderImpl(
+ final AnnotationTypeBuilder annotationTypeBuilder4 = new AnnotationTypeBuilderImpl(
JavaTypeName.create("my.package", "MyName"));
assertFalse(annotationTypeBuilder.equals(null));
assertFalse(annotationTypeBuilder.equals(annotationTypeBuilder3));
AnnotationType instance = annotationTypeBuilder.build();
- AnnotationType instance2 = annotationTypeBuilder2.build();
- AnnotationType instance3 = annotationTypeBuilder3.build();
- AnnotationType instance4 = annotationTypeBuilder4.build();
-
assertFalse(instance.equals(null));
assertFalse(instance.equals(new Object()));
assertTrue(instance.equals(instance));
+ AnnotationType instance2 = annotationTypeBuilder2.build();
assertFalse(instance.equals(instance2));
+
+ final AnnotationType instance3 = annotationTypeBuilder3.build();
assertFalse(instance.equals(instance3));
+ final AnnotationType instance4 = annotationTypeBuilder4.build();
assertTrue(instance.equals(instance4));
annotationTypeBuilder.addParameter("myName", "myValue1");
instance = annotationTypeBuilder.build();
instance2 = annotationTypeBuilder2.build();
- Parameter parameter = instance.getParameter("myName");
- Parameter parameter2 = instance.getParameter("myName2");
- Parameter parameter3 = instance2.getParameter("myName");
+ final Parameter parameter = instance.getParameter("myName");
+ final Parameter parameter2 = instance.getParameter("myName2");
+ final Parameter parameter3 = instance2.getParameter("myName");
assertFalse(parameter.equals(null));
assertFalse(parameter.equals(new Object()));
annotationTypeBuilder.addAnnotation("my.package", "MySubAnnotationName");
annotationTypeBuilder.addParameter("MyParameter", "myValue");
- assertEquals(
- "AnnotationTypeBuilder [packageName=my.package, name=MyAnnotationName, annotationBuilders=[AnnotationTypeBuilder [packageName=my.package, name=MySubAnnotationName, annotationBuilders=[], parameters=[]]], parameters=[ParameterImpl [name=MyParameter, value=myValue, values=[]]]]",
- annotationTypeBuilder.toString());
+ assertEquals("AnnotationTypeBuilder [packageName=my.package, name=MyAnnotationName, "
+ + "annotationBuilders=[AnnotationTypeBuilder [packageName=my.package, name=MySubAnnotationName, "
+ + "annotationBuilders=[], parameters=[]]], parameters=[ParameterImpl [name=MyParameter, value=myValue, "
+ + "values=[]]]]", annotationTypeBuilder.toString());
AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
assertEquals("my.package.MyAnnotationName", annotationTypeInstance.getFullyQualifiedName());
- assertEquals(
- "AnnotationType [packageName=my.package, name=MyAnnotationName, annotations=[AnnotationType [packageName=my.package, name=MySubAnnotationName, annotations=[], parameters=[]]], parameters=[ParameterImpl [name=MyParameter, value=myValue, values=[]]]]",
+ assertEquals("AnnotationType [packageName=my.package, name=MyAnnotationName, annotations=[AnnotationType "
+ + "[packageName=my.package, name=MySubAnnotationName, annotations=[], parameters=[]]], "
+ + "parameters=[ParameterImpl [name=MyParameter, value=myValue, values=[]]]]",
annotationTypeInstance.toString());
}
public class EnumerationBuilderImplTest {
- private final QName qName = QName.create("TestQName", "2014-10-10", "TestLocalQName");
- private final String DESCRIPTION = "Test description of Enum";
+ private final QName qname = QName.create("TestQName", "2014-10-10", "TestLocalQName");
+ private static final String DESCRIPTION = "Test description of Enum";
private final String packageName = "org.opendaylight.test";
private final String name = "TestName";
private final String moduleName = "TestModuleName";
enumerationBuilder.setDescription(DESCRIPTION);
enumerationBuilder.setModuleName(moduleName);
enumerationBuilder.setReference(reference);
- enumerationBuilder.setSchemaPath(SchemaPath.create(true, qName));
+ enumerationBuilder.setSchemaPath(SchemaPath.create(true, qname));
enumerationBuilder.addValue(valueName, valueName, value, Status.CURRENT, valueDescription, null);
enumerationBuilder.addAnnotation(packageName, "TestAnnotation");
enumerationBuilderSame = new CodegenEnumerationBuilder(JavaTypeName.create(packageName, name));
enumerationBuilderOtherName = new CodegenEnumerationBuilder(JavaTypeName.create(packageName, "SomeOtherName"));
- enumerationBuilderOtherPackage = new CodegenEnumerationBuilder(JavaTypeName.create("org.opendaylight.other", name));
+ enumerationBuilderOtherPackage = new CodegenEnumerationBuilder(JavaTypeName.create("org.opendaylight.other",
+ name));
enumeration = enumerationBuilder.toInstance(enumerationBuilder);
}
assertEquals(moduleName, enumeration.getModuleName());
assertEquals(packageName + '.' + name, enumeration.getFullyQualifiedName());
assertEquals(reference, enumeration.getReference());
- assertEquals(Collections.singletonList(qName), enumeration.getSchemaPath());
+ assertEquals(Collections.singletonList(qname), enumeration.getSchemaPath());
assertEquals(Collections.EMPTY_LIST, enumeration.getEnclosedTypes());
assertEquals(Collections.EMPTY_LIST, enumeration.getEnumerations());
assertEquals(Collections.EMPTY_LIST, enumeration.getMethodDefinitions());
assertEquals(enumeration, enumeration);
assertNotEquals(enumeration, "string");
- final Enumeration enumerationOtherPackage = enumerationBuilderOtherPackage.toInstance(enumerationBuilderOtherPackage);
+ final Enumeration enumerationOtherPackage = enumerationBuilderOtherPackage
+ .toInstance(enumerationBuilderOtherPackage);
assertNotEquals(enumeration, enumerationOtherPackage);
final Enumeration enumerationOtherName = enumerationBuilderOtherName.toInstance(enumerationBuilderOtherName);
@Test
public void testEnumerationToString() {
- final String formattedString =
- "public enum " + name + " {\n" +
- "\t TestValue " + "(12 );\n" +
- "}";
+ final String formattedString = "public enum " + name + " {\n"
+ + "\t TestValue " + "(12 );\n"
+ + "}";
final String s = "Enumeration [packageName=" + packageName + ", definingType=" + packageName + "." + name
+ ", name=" + name + ", values=[EnumPair [name=TestValue, mappedName=TestValue, value=12]]]";
assertEquals(s, enumeration.toString());
assertEquals(formattedString, enumeration.toFormattedString());
- assertEquals("EnumerationBuilderImpl " +
- "[packageName=org.opendaylight.test, name=TestName, " +
- "values=[EnumPair [name=TestValue, mappedName=TestValue, value=12]]]",
+ assertEquals("EnumerationBuilderImpl [packageName=org.opendaylight.test, name=TestName, "
+ + "values=[EnumPair [name=TestValue, mappedName=TestValue, value=12]]]",
enumerationBuilder.toString());
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
-import org.opendaylight.mdsal.binding.model.util.Types;
import org.opendaylight.mdsal.binding.model.api.AccessModifier;
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
+import org.opendaylight.mdsal.binding.model.util.Types;
public class GeneratedPropertyBuilderImplTest {
generatedPropertyBuilderImpl.setAccessModifier(AccessModifier.PUBLIC);
generatedPropertyBuilderImpl.setReturnType(Types.BOOLEAN);
- assertEquals(
- "GeneratedPropertyImpl [name=myPropertyName, annotations=[], comment=null, returnType=Type (java.lang.Boolean), isFinal=true, isReadOnly=false, modifier=PUBLIC]",
+ assertEquals("GeneratedPropertyImpl [name=myPropertyName, annotations=[], comment=null, returnType=Type "
+ + "(java.lang.Boolean), isFinal=true, isReadOnly=false, modifier=PUBLIC]",
generatedPropertyBuilderImpl.toString());
GeneratedProperty instance = generatedPropertyBuilderImpl.toInstance(null);
@Test
public void generatedPropertyBuilderImplEqualsAndHashCodeTest() {
- GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl = new GeneratedPropertyBuilderImpl("myPropertyName");
- GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl2 = new GeneratedPropertyBuilderImpl("myPropertyName");
- GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl3 = new GeneratedPropertyBuilderImpl("myPropertyName3");
- GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl4 = new GeneratedPropertyBuilderImpl("myPropertyName");
+ final GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl =
+ new GeneratedPropertyBuilderImpl("myPropertyName");
+ final GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl2 =
+ new GeneratedPropertyBuilderImpl("myPropertyName");
+ final GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl3 =
+ new GeneratedPropertyBuilderImpl("myPropertyName3");
+ final GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl4 =
+ new GeneratedPropertyBuilderImpl("myPropertyName");
assertNotNull(generatedPropertyBuilderImpl);
assertNotNull(generatedPropertyBuilderImpl2);
assertFalse(generatedPropertyBuilderImpl.hashCode() == generatedPropertyBuilderImpl3.hashCode());
assertFalse(generatedPropertyBuilderImpl.hashCode() == generatedPropertyBuilderImpl4.hashCode());
}
-
}
public void generatedPropertyImplEqualsAndHashCodeTest() {
GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl = new GeneratedPropertyBuilderImpl("myPropertyName");
GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl2 = new GeneratedPropertyBuilderImpl("myPropertyName");
- GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl3 = new GeneratedPropertyBuilderImpl("myPropertyName3");
- GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl4 = new GeneratedPropertyBuilderImpl("myPropertyName");
+ final GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl3 =
+ new GeneratedPropertyBuilderImpl("myPropertyName3");
+ final GeneratedPropertyBuilderImpl generatedPropertyBuilderImpl4 =
+ new GeneratedPropertyBuilderImpl("myPropertyName");
generatedPropertyBuilderImpl.setReturnType(Types.BOOLEAN);
generatedPropertyBuilderImpl2.setReturnType(Types.BOOLEAN);
generatedPropertyBuilderImpl3.setReturnType(Types.BOOLEAN);
generatedPropertyBuilderImpl4.setReturnType(Types.STRING);
- GeneratedProperty property = generatedPropertyBuilderImpl.toInstance(null);
- GeneratedProperty property2 = generatedPropertyBuilderImpl2.toInstance(null);
- GeneratedProperty property3 = generatedPropertyBuilderImpl3.toInstance(null);
- GeneratedProperty property4 = generatedPropertyBuilderImpl4.toInstance(null);
+ final GeneratedProperty property = generatedPropertyBuilderImpl.toInstance(null);
+ final GeneratedProperty property2 = generatedPropertyBuilderImpl2.toInstance(null);
+ final GeneratedProperty property3 = generatedPropertyBuilderImpl3.toInstance(null);
+ final GeneratedProperty property4 = generatedPropertyBuilderImpl4.toInstance(null);
assertNotNull(property);
assertNotNull(property2);
@Test
public void testMethodsForGeneratedPropertyImpl() {
- final GeneratedPropertyImpl propertyImpl = new GeneratedPropertyImpl(null, "Test", null, "test property", AccessModifier.PRIVATE, null, true, true, true, "test value");
+ final GeneratedPropertyImpl propertyImpl = new GeneratedPropertyImpl(null, "Test", null, "test property",
+ AccessModifier.PRIVATE, null, true, true, true, "test value");
assertEquals("test value", propertyImpl.getValue());
assertTrue(propertyImpl.isReadOnly());
import java.util.Optional;
import org.junit.Test;
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.mdsal.binding.model.api.Restrictions;
import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.Restrictions;
import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
import org.opendaylight.mdsal.binding.model.api.Enumeration;
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.Type;
-import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder;
Constant constant3 = new ConstantImpl(generatedTypeBuilder, Types.typeForClass(String.class), "myConstant",
"myConstantValue");
- Constant constant4 = new ConstantImpl(generatedTypeBuilder, Types.typeForClass(String.class), "myConstant2",
- "myConstantValue");
- Constant constant5 = new ConstantImpl(generatedTypeBuilder, Types.typeForClass(String.class), "myConstant",
- "myConstantValue2");
+ final Constant constant4 = new ConstantImpl(generatedTypeBuilder, Types.typeForClass(String.class),
+ "myConstant2", "myConstantValue");
+ final Constant constant5 = new ConstantImpl(generatedTypeBuilder, Types.typeForClass(String.class),
+ "myConstant", "myConstantValue2");
assertNotNull(constant);
assertNotNull(constant2);
assertFalse(constant.hashCode() == constant4.hashCode());
assertTrue(constant.hashCode() == constant5.hashCode());
- assertEquals(
- "Constant [type=Type (java.lang.String), name=myConstant, value=myConstantValue, definingType=my.package.MyName]",
- constant.toString());
+ assertEquals("Constant [type=Type (java.lang.String), name=myConstant, value=myConstantValue, "
+ + "definingType=my.package.MyName]", constant.toString());
assertEquals("Type (java.lang.String) myConstant myConstantValue", constant.toFormattedString());
@Test
public void generatedTypeBuilderEqualsAndHashCodeTest() {
- CodegenGeneratedTypeBuilder generatedTypeBuilder = new CodegenGeneratedTypeBuilder(
+ final CodegenGeneratedTypeBuilder generatedTypeBuilder = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("my.package", "MyName"));
- CodegenGeneratedTypeBuilder generatedTypeBuilder2 = new CodegenGeneratedTypeBuilder(
+ final CodegenGeneratedTypeBuilder generatedTypeBuilder2 = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("my.package", "MyName"));
- CodegenGeneratedTypeBuilder generatedTypeBuilder3 = new CodegenGeneratedTypeBuilder(
+ final CodegenGeneratedTypeBuilder generatedTypeBuilder3 = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("my.package", "MyName2"));
- CodegenGeneratedTypeBuilder generatedTypeBuilder4 = new CodegenGeneratedTypeBuilder(
+ final CodegenGeneratedTypeBuilder generatedTypeBuilder4 = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("my.package2", "MyName"));
assertFalse(generatedTypeBuilder.equals(null));
assertTrue(enumerations.contains(enumBuilder.toInstance(instance)));
assertTrue(enumerations.contains(enumBuilder2.toInstance(instance)));
- assertFalse(enumerations.contains(new CodegenEnumerationBuilder(JavaTypeName.create("my.package", "myEnumName3"))
+ assertFalse(enumerations.contains(new CodegenEnumerationBuilder(JavaTypeName.create("my.package",
+ "myEnumName3"))
.toInstance(instance)));
}
@Test(expected = IllegalArgumentException.class)
public void addEnclosingTransferObjectIllegalArgumentTest() {
- new CodegenGeneratedTypeBuilder(JavaTypeName.create("my.package", "MyName"))
- .addEnclosingTransferObject((String) null);
+ new CodegenGeneratedTypeBuilder(JavaTypeName.create("my.package", "MyName")).addEnclosingTransferObject(
+ (String) null);
}
@Test(expected = IllegalArgumentException.class)
public void addEnclosingTransferObjectIllegalArgumentTest2() {
- new CodegenGeneratedTypeBuilder(JavaTypeName.create("my.package", "MyName"))
- .addEnclosingTransferObject((GeneratedTOBuilder) null);
+ new CodegenGeneratedTypeBuilder(JavaTypeName.create("my.package", "MyName")).addEnclosingTransferObject(
+ (GeneratedTOBuilder) null);
}
@Test
assertEquals("My description ...", instance.getDescription());
assertEquals("myModuleName", instance.getModuleName());
assertEquals("myReference", instance.getReference());
- assertEquals(SchemaPath.create(true, QName.create("test", "/path")).getPathFromRoot(), instance.getSchemaPath());
+ assertEquals(SchemaPath.create(true, QName.create("test", "/path")).getPathFromRoot(),
+ instance.getSchemaPath());
assertEquals("My comment..", instance.getComment().getJavadoc());
}
}
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.model.util.Types;
import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.util.Types;
public class MethodParameterImplTest {
- private MethodParameterImpl parameter1, parameter2, parameter3, parameter4;
- private int hash1, hash2, hash3, hash4;
+ private MethodParameterImpl parameter1;
+ private MethodParameterImpl parameter2;
+ private MethodParameterImpl parameter3;
+ private MethodParameterImpl parameter4;
+ private int hash1;
+ private int hash2;
+ private int hash3;
+ private int hash4;
@Before
- public void Setup() {
+ public void before() {
String name = "customParameter";
Type type = Types.STRING;
parameter1 = new MethodParameterImpl(name, type);
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature;
public class MethodSignatureBuilderImplTest {
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.model.util.Types;
import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.mdsal.binding.model.util.Types;
public class MethodSignatureBuilderTest {
- private MethodSignatureBuilder builder1, builder2, builder3, builder4;
- private int hash1, hash2, hash3;
+ private MethodSignatureBuilder builder1;
+ private MethodSignatureBuilder builder2;
+ private MethodSignatureBuilder builder3;
+ private MethodSignatureBuilder builder4;
+ private int hash1;
+ private int hash2;
+ private int hash3;
@Before
public void setup() {
import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.model.util.Types;
import org.opendaylight.mdsal.binding.model.api.AccessModifier;
import org.opendaylight.mdsal.binding.model.api.AnnotationType;
import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter;
import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.util.Types;
public class MethodSignatureImplTest {
- private MethodSignatureImpl signature1, signature2, signature3, signature4;
- private int hash1, hash4;
+ private MethodSignatureImpl signature1;
+ private MethodSignatureImpl signature2;
+ private MethodSignatureImpl signature3;
+ private MethodSignatureImpl signature4;
+ private int hash1;
+ private int hash4;
@Before
public void setup() {