本文整理汇总了Java中org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails.getDeclaredMethods方法的典型用法代码示例。如果您正苦于以下问题:Java ClassOrInterfaceTypeDetails.getDeclaredMethods方法的具体用法?Java ClassOrInterfaceTypeDetails.getDeclaredMethods怎么用?Java ClassOrInterfaceTypeDetails.getDeclaredMethods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails
的用法示例。
在下文中一共展示了ClassOrInterfaceTypeDetails.getDeclaredMethods方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodByNameInClass
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* Search the method by name in class.
* </p>
*/
public MethodMetadata getMethodByNameInClass(JavaType serviceClass,
JavaSymbolName methodName) {
// Load class details. If class not found an exception will be raised.
ClassOrInterfaceTypeDetails tmpServiceDetails = typeLocationService
.getTypeDetails(serviceClass);
// Checks if it's mutable
Validate.isInstanceOf(ClassOrInterfaceTypeDetails.class,
tmpServiceDetails,
"Can't modify " + tmpServiceDetails.getName());
ClassOrInterfaceTypeDetails serviceDetails = (ClassOrInterfaceTypeDetails) tmpServiceDetails;
List<? extends MethodMetadata> methodList = serviceDetails
.getDeclaredMethods();
for (MethodMetadata methodMetadata : methodList) {
if (methodMetadata.getMethodName().equals(methodName)) {
return methodMetadata;
}
}
return null;
}
示例2: checkExistsDeleteBatchMethod
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* This method check if another delete method exists to the current
* controller
*
* @param governorTypeDetails
* @param parameterTypes
* @return
*/
private MethodMetadata checkExistsDeleteBatchMethod(
ClassOrInterfaceTypeDetails governorTypeDetails,
List<AnnotatedJavaType> parameterTypes) {
// Getting all methods
List<? extends MethodMetadata> methods = governorTypeDetails
.getDeclaredMethods();
Iterator<? extends MethodMetadata> it = methods.iterator();
while (it.hasNext()) {
MethodMetadata method = it.next();
// Getting request
AnnotationMetadata requestAnnotation = method
.getAnnotation(SpringJavaType.REQUEST_MAPPING);
if (requestAnnotation != null) {
// Getting request value
AnnotationAttributeValue<?> request = requestAnnotation
.getAttribute(new JavaSymbolName("value"));
if (request != null) {
String value = request.getValue().toString();
// Getting method parameterTypes
final List<JavaType> methodParameters = AnnotatedJavaType
.convertFromAnnotatedJavaTypes(method
.getParameterTypes());
// If method exists with same params, return method
String methodName = method.getMethodName().getSymbolName();
if ("/delete".equals(value)
&& AnnotatedJavaType.convertFromAnnotatedJavaTypes(
parameterTypes).equals(methodParameters)
&& !"deleteBatch".equals(methodName)) {
return method;
}
}
}
}
return null;
}
示例3: addMethod
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* Add a method to be monitored as a Spring service
*
* @param methodName Set the method name to be monitored
* @param className Set the class name of the method to be monitored
*/
@Override
public void addMethod(JavaSymbolName methodName, JavaType className) {
// Get java type controller
ClassOrInterfaceTypeDetails controller = getControllerDetails(className);
ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(
controller);
List<MethodMetadata> methodList = (List<MethodMetadata>) controller
.getDeclaredMethods();
for (int i = 0; i < methodList.size(); i++) {
MethodMetadata method = methodList.get(i);
if (methodName.equals(method.getMethodName())) {
MethodMetadataBuilder builder = new MethodMetadataBuilder(
method);
// Generating new annotation
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
SPRING_MONITORING_ANNOTATION);
// Add annotation to target type
builder.updateTypeAnnotation(annotationBuilder.build());
// Save changes to disk
getTypeManagementService().createOrUpdateTypeOnDisk(
classBuilder.build());
}
}
LOGGER.log(
Level.INFO,
"[ERROR] This method doesn't exist for this class or maybe it's inside an .aj file. In this case you must to push-in that method and then execute this command again");
}
示例4: searchMethodsInJava
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* Search method in Java.
*
* @param methodName Method name to search
* @param targetId New method destination identifier
* @param mutableTypeDetails Type to search methods in
* @return Methods list
*/
protected List<MethodMetadata> searchMethodsInJava(
JavaSymbolName methodName, String targetId,
ClassOrInterfaceTypeDetails mutableTypeDetails) {
List<MethodMetadata> methods = new ArrayList<MethodMetadata>();
for (MethodMetadata method : mutableTypeDetails.getDeclaredMethods()) {
if (method.getMethodName().toString()
.compareTo(methodName.toString()) != 0) {
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
bodyBuilder.appendFormalLine(method.getBody());
MethodMetadataBuilder methodMetadataBuilder = new MethodMetadataBuilder(
targetId, method.getModifier(), method.getMethodName(),
method.getReturnType(), method.getParameterTypes(),
method.getParameterNames(), bodyBuilder);
for (AnnotationMetadata annotationMetadata : method
.getAnnotations()) {
methodMetadataBuilder.addAnnotation(annotationMetadata);
}
for (JavaType javaType : method.getThrowsTypes()) {
methodMetadataBuilder.addThrowsType(javaType);
}
MethodMetadata operationMetadata = methodMetadataBuilder
.build();
methods.add(operationMetadata);
}
}
return methods;
}
示例5: checkExistsCUBatchMethod
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* This method check if another update method exists to the current
* controller
*
* @param governorTypeDetails
* @param parameterTypes
* @return
*/
private MethodMetadata checkExistsCUBatchMethod(
ClassOrInterfaceTypeDetails governorTypeDetails,
List<AnnotatedJavaType> parameterTypes, String requestMethodType) {
// Getting all methods
List<? extends MethodMetadata> methods = governorTypeDetails
.getDeclaredMethods();
Iterator<? extends MethodMetadata> it = methods.iterator();
while (it.hasNext()) {
MethodMetadata method = it.next();
// Getting request and response body
AnnotationMetadata requestAnnotation = method
.getAnnotation(SpringJavaType.REQUEST_MAPPING);
AnnotationMetadata responseAnnotation = method
.getAnnotation(SpringJavaType.RESPONSE_BODY);
if (requestAnnotation != null && responseAnnotation != null) {
// Getting request value
AnnotationAttributeValue<?> methodParamAnnotation = requestAnnotation
.getAttribute(new JavaSymbolName("method"));
if (methodParamAnnotation != null) {
String value = methodParamAnnotation.getValue().toString();
// Getting method parameterTypes
final List<JavaType> methodParameters = AnnotatedJavaType
.convertFromAnnotatedJavaTypes(method
.getParameterTypes());
// If method exists with same params, return method
String methodName = method.getMethodName().getSymbolName();
String validMethodName = "createBatch";
if (requestMethodType.equals("PUT")) {
validMethodName = "updateBatch";
}
if (value.equals(REQUEST_METHOD_WITHOUT_TYPE
.concat(requestMethodType))
&& AnnotatedJavaType.convertFromAnnotatedJavaTypes(
parameterTypes).equals(methodParameters)
&& !methodName.equals(validMethodName)) {
return method;
}
}
}
}
return null;
}
示例6: getMetadata
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
@Override
protected ItdTypeDetailsProvidingMetadataItem getMetadata(
final String metadataIdentificationString,
final JavaType aspectName,
final PhysicalTypeMetadata governorPhysicalTypeMetadata,
final String itdFilename) {
final JavaBeanAnnotationValues annotationValues = new JavaBeanAnnotationValues(
governorPhysicalTypeMetadata);
if (!annotationValues.isAnnotationFound()) {
return null;
}
ClassOrInterfaceTypeDetails currentClassDetails = governorPhysicalTypeMetadata
.getMemberHoldingTypeDetails();
final Map<FieldMetadata, JavaSymbolName> declaredFields = new LinkedHashMap<FieldMetadata, JavaSymbolName>();
for (final FieldMetadata field : currentClassDetails
.getDeclaredFields()) {
declaredFields.put(
field,
getIdentifierAccessorMethodName(field,
metadataIdentificationString));
}
// In order to handle switching between GAE and JPA produced MIDs need
// to be remembered so they can be regenerated on JPA <-> GAE switch
producedMids.add(metadataIdentificationString);
// Getting implements
List<JavaType> interfaces = currentClassDetails.getImplementsTypes();
List<? extends MethodMetadata> interfaceMethods = null;
if (!interfaces.isEmpty()) {
for (JavaType currentInterface : interfaces) {
ClassOrInterfaceTypeDetails currentInterfaceDetails = getTypeLocationService()
.getTypeDetails(currentInterface);
if(currentInterfaceDetails != null){
interfaceMethods = currentInterfaceDetails.getDeclaredMethods();
}
}
}
return new JavaBeanMetadata(metadataIdentificationString, aspectName,
governorPhysicalTypeMetadata, annotationValues, declaredFields,
interfaceMethods, getMemberDetailsScanner());
}