loggingService.incrementNum(LoggingService.DEF_DESCRIPTOR_COUNT);
}
private DefDescriptorImpl(String qualifiedName, Class<T> defClass, DefDescriptor<?> bundle) {
this.bundle = bundle;
LoggingService loggingService = Aura.getLoggingService();
loggingService.startTimer(LoggingService.TIMER_DEF_DESCRIPTOR_CREATION);
try {
this.defType = DefType.getDefType(defClass);
if (AuraTextUtil.isNullEmptyOrWhitespace(qualifiedName)) {
throw new AuraRuntimeException("QualifiedName is required for descriptors");
}
String prefix = null;
String namespace = null;
String name = null;
String nameParameters = null;
switch (defType) {
case CONTROLLER:
case TESTSUITE:
case MODEL:
case RENDERER:
case HELPER:
case STYLE:
case RESOURCE:
case TYPE:
case PROVIDER:
case THEME_PROVIDER:
case THEME_MAP_PROVIDER:
case INCLUDE:
Matcher matcher = CLASS_PATTERN.matcher(qualifiedName);
if (matcher.matches()) {
prefix = matcher.group(1);
namespace = matcher.group(2);
if (namespace.isEmpty()) {
namespace = null;
}
name = matcher.group(3);
if (matcher.group(4) != null) {
// combine name with <generic params> if available
name += matcher.group(4);
if (defType == org.auraframework.def.DefDescriptor.DefType.TYPE) {
nameParameters = matcher.group(4);
}
}
} else {
throw new AuraRuntimeException(String.format("Invalid Descriptor Format: %s[%s]", qualifiedName, defType.toString()));
}
break;
// subtypes
case ACTION:
case DESCRIPTION:
throw new AuraRuntimeException(
String.format("%s descriptor must be a subdef: %s", defType.name(), qualifiedName));
case ATTRIBUTE:
case LAYOUT:
case LAYOUT_ITEM:
case TESTCASE:
case VAR:
case THEME_DEF_REF:
case ATTRIBUTE_DESIGN:
case DESIGN_TEMPLATE:
case DESIGN_TEMPLATE_REGION:
case INCLUDE_REF:
name = qualifiedName;
break;
case APPLICATION:
case COMPONENT:
case INTERFACE:
case EVENT:
case LIBRARY:
case DOCUMENTATION:
case EXAMPLE:
case LAYOUTS:
case NAMESPACE:
case THEME:
case DESIGN:
Matcher tagMatcher = TAG_PATTERN.matcher(qualifiedName);
if (tagMatcher.matches()) {
prefix = tagMatcher.group(1);
if (prefix == null) {
prefix = MARKUP_PREFIX;
}
namespace = tagMatcher.group(2);
name = tagMatcher.group(3);
if (AuraTextUtil.isNullEmptyOrWhitespace(name)) {
name = namespace;
namespace = null;
}
qualifiedName = buildQualifiedName(prefix, namespace, name);
} else {
throw new AuraRuntimeException(String.format("Invalid Descriptor Format: %s[%s]", qualifiedName, defType.toString()));
}
break;
}
if (AuraTextUtil.isNullEmptyOrWhitespace(prefix)) {
prefix = Aura.getContextService().getCurrentContext().getDefaultPrefix(defType);
if (prefix != null) {
qualifiedName = buildQualifiedName(prefix, namespace, name);
}
}
this.qualifiedName = qualifiedName;
this.descriptorName = buildDescriptorName(prefix, namespace, name);
this.prefix = prefix;
if (defType == DefType.NAMESPACE) {
this.namespace = name;
this.name = name;
} else {
this.namespace = namespace;
this.name = name;
}
this.hashCode = createHashCode();
this.nameParameters = nameParameters;
} finally {
loggingService.stopTimer(LoggingService.TIMER_DEF_DESCRIPTOR_CREATION);
}
loggingService.incrementNum(LoggingService.DEF_DESCRIPTOR_COUNT);
}