|
13 | 13 | import com.google.common.base.Strings;
|
14 | 14 |
|
15 | 15 | public class NameUtil {
|
16 |
| - private static final String DEFAULT_TYPE = "default_type"; |
| 16 | + private static final String DEFAULT_TYPE = "default_namespace"; |
17 | 17 | /**
|
18 | 18 | * Extracts the name from the fully qualified type name. Name represents the last token after ".".
|
19 | 19 | * If the qualified name does not contain "." then the name is same as qualified name.
|
@@ -63,15 +63,17 @@ public static String qualifiedName(String qualifier, String name) {
|
63 | 63 |
|
64 | 64 | /**
|
65 | 65 | * Type value if the 'type' is not null of empty.
|
66 |
| - * If type is null or empty then the created name is simply 'namespace.groupName'. |
| 66 | + * If type is null or empty and the namespace is null or empty created name is 'default_namespace.groupName'. |
| 67 | + * If type is null or empty and namespace is not null or empty then created name is 'namespace.groupName'. |
67 | 68 | *
|
68 | 69 | * @param type the value provided with API call (schemaInfo.getType()).
|
69 | 70 | * @param groupName the name of the group for schema
|
70 | 71 | * @param namespace the namespace for the schema
|
71 | 72 | * @return Provided name or Created name for type in SchemaInfo
|
72 | 73 | */
|
73 | 74 | public static String createTypeIfAbsent(String type, String groupName, String namespace) {
|
74 |
| - String nameSpace = Strings.isNullOrEmpty(namespace) ? DEFAULT_TYPE : namespace; |
75 |
| - return Strings.isNullOrEmpty(type) ? String.format("%s.%s", nameSpace, groupName) : type; |
| 75 | + Preconditions.checkNotNull(groupName, "Group can not be null"); |
| 76 | + String typeName = Strings.isNullOrEmpty(namespace) ? DEFAULT_TYPE : namespace; |
| 77 | + return Strings.isNullOrEmpty(type) ? String.format("%s.%s", typeName, groupName) : type; |
76 | 78 | }
|
77 | 79 | }
|
0 commit comments