import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import java.util.Objects;
+import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
import org.opendaylight.mdsal.binding.javav2.model.api.Type;
/**
* @param name
* string with the name for this <code>Type</code>
*/
- protected AbstractBaseType(final String pkName, final String name) {
- this.packageName = Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!");
- this.name = Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!");
+ protected AbstractBaseType(final String pkName, final String name, 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.");
+ this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context);
+ }
+
+ /**
+ * Constructs the instance of this class with the concrete package name type
+ * name.
+ *
+ * @param pkName
+ * string with the package name to which this <code>Type</code>
+ * belongs
+ * @param name
+ * string with the name for this <code>Type</code>
+ * @param isNormalized
+ * true if pkName and name are normalized
+ */
+ protected AbstractBaseType(final String pkName, final String name, final boolean isNormalized,
+ 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.packageName = pkName;
+ this.name = name;
+ } else {
+ this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName);
+ 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 ) {
+ Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!");
+ Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!");
+ if (isPkNameNormalized) {
+ this.packageName = pkName;
+ } else {
+ this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName);
+ }
+
+ if (isTypeNormalized) {
+ this.name = name;
+ } else {
+ Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " +
+ "ModuleContext instance must be provided.");
+ this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context);
+ }
}
@Override