use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class MetadataCommands method metadataForType.
@CliCommand(value = METADATA_FOR_TYPE_COMMAND, help = "Shows detailed metadata for the indicated type.")
public String metadataForType(@CliOption(key = { "", "type" }, mandatory = true, help = "The Java type for which to display metadata. When working on a single module " + "project, simply specify the name of the class. If you consider it necessary, you can " + "also specify the package. Ex.: `--type ~.domain.MyClass` (where `~` is the base package). " + "When working with multiple modules, you should specify the name of the class and the " + "module where it is. Ex.: `--type model:~.domain.MyClass`. If the module is not " + "specified, it is assumed that the class is in the module which has the focus.") final JavaType javaType) {
final String id = typeLocationService.getPhysicalTypeIdentifier(javaType);
if (id == null) {
return "Cannot locate source for " + javaType.getFullyQualifiedTypeName();
}
final StringBuilder sb = new StringBuilder();
sb.append("Java Type : ").append(javaType.getFullyQualifiedTypeName()).append(System.getProperty("line.separator"));
final ClassOrInterfaceTypeDetails javaTypeDetails = typeLocationService.getTypeDetails(javaType);
if (javaTypeDetails == null) {
sb.append("Java type details unavailable").append(System.getProperty("line.separator"));
} else {
for (final MemberHoldingTypeDetails holder : memberDetailsScanner.getMemberDetails(getClass().getName(), javaTypeDetails).getDetails()) {
sb.append("Member scan: ").append(holder.getDeclaredByMetadataId()).append(System.getProperty("line.separator"));
}
}
sb.append(metadataForId(id));
return sb.toString();
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class TypeCacheImpl method removeType.
public void removeType(final String typeIdentifier) {
Validate.notBlank(typeIdentifier, "Physical type identifier required");
final ClassOrInterfaceTypeDetails cid = midToTypeDetailsMap.get(typeIdentifier);
if (cid != null) {
typeNameToMidMap.remove(cid.getName().getFullyQualifiedTypeName());
typeNameToModuleFilePathMap.remove(cid.getName().getFullyQualifiedTypeName());
typeNameToModuleNameMap.remove(cid.getName().getFullyQualifiedTypeName());
}
final String filePath = typeIdentifierToFilePathMap.get(typeIdentifier);
if (filePath != null) {
typeFilePathToMidMap.remove(filePath);
typeIdentifierToFilePathMap.remove(typeIdentifier);
}
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class TypeLocationServiceImpl method getTypeDetails.
public ClassOrInterfaceTypeDetails getTypeDetails(final String physicalTypeId) {
if (StringUtils.isBlank(physicalTypeId)) {
return null;
}
Validate.isTrue(PhysicalTypeIdentifier.isValid(physicalTypeId), "Metadata id '%s' is not a valid physical type id", physicalTypeId);
updateTypeCache();
final ClassOrInterfaceTypeDetails cachedDetails = getTypeCache().getTypeDetails(physicalTypeId);
if (cachedDetails != null) {
return cachedDetails;
}
final PhysicalTypeMetadata physicalTypeMetadata = (PhysicalTypeMetadata) getMetadataService().get(physicalTypeId);
if (physicalTypeMetadata == null) {
return null;
}
return physicalTypeMetadata.getMemberHoldingTypeDetails();
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class TypeLocationServiceImpl method processTypesWithAnnotation.
public void processTypesWithAnnotation(final List<JavaType> annotationsToDetect, final LocatedTypeCallback callback) {
Validate.notNull(annotationsToDetect, "Annotations to detect required");
Validate.notNull(callback, "Callback required");
// be added
for (final JavaType annotationType : annotationsToDetect) {
if (!annotationToMidMap.containsKey(annotationType)) {
annotationToMidMap.put(annotationType, new HashSet<String>());
}
}
// Before processing the call any changes to the project should be
// processed and the cache updated accordingly
updateTypeCache();
for (final JavaType annotationType : annotationsToDetect) {
for (final String locatedMid : annotationToMidMap.get(annotationType)) {
final ClassOrInterfaceTypeDetails located = getTypeCache().getTypeDetails(locatedMid);
callback.process(located);
}
}
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class TypeLocationServiceImpl method processTypesWithTag.
private void processTypesWithTag(final Object tag, final LocatedTypeCallback callback) {
Validate.notNull(tag, "Tag required");
Validate.notNull(callback, "Callback required");
// If the cache doesn't yet contain the tag it should be added
if (!tagToMidMap.containsKey(tag)) {
tagToMidMap.put(tag, new HashSet<String>());
}
// Before processing the call any changes to the project should be
// processed and the cache updated accordingly
updateTypeCache();
for (final String locatedMid : tagToMidMap.get(tag)) {
final ClassOrInterfaceTypeDetails located = getTypeCache().getTypeDetails(locatedMid);
callback.process(located);
}
}
Aggregations