本文整理汇总了Java中org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails.getDeclaredFields方法的典型用法代码示例。如果您正苦于以下问题:Java ClassOrInterfaceTypeDetails.getDeclaredFields方法的具体用法?Java ClassOrInterfaceTypeDetails.getDeclaredFields怎么用?Java ClassOrInterfaceTypeDetails.getDeclaredFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails
的用法示例。
在下文中一共展示了ClassOrInterfaceTypeDetails.getDeclaredFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntityFields
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* This method returns all fields in entity that match with dependentTypes
*
* @param dependentTypes
* @param cid
*/
private List<FieldMetadata> getEntityFields(
final List<JavaTypeMetadataDetails> dependentTypes,
ClassOrInterfaceTypeDetails cid) {
List<FieldMetadata> fieldsNamesList = new ArrayList<FieldMetadata>();
// Getting all declared fields in entity
List<? extends FieldMetadata> fieldList = cid.getDeclaredFields();
Iterator<? extends FieldMetadata> it = fieldList.iterator();
while (it.hasNext()) {
FieldMetadata currentField = it.next();
if (typeLocationService.isInProject(currentField.getFieldType())) {
fieldsNamesList.add(currentField);
}
}
return fieldsNamesList;
}
示例2: getEntityGeoFields
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* This method obtains all GEO fields to represent on map from entity
*
* @param controller
* @param typeLocationService
* @return
*/
private List<FieldMetadata> getEntityGeoFields(JavaType controller,
TypeLocationService typeLocationService) {
ClassOrInterfaceTypeDetails controllerDetails = typeLocationService
.getTypeDetails(controller);
AnnotationMetadata scaffoldAnnotation = controllerDetails
.getAnnotation(RooJavaType.ROO_WEB_SCAFFOLD);
JavaType entity = (JavaType) scaffoldAnnotation.getAttribute(
"formBackingObject").getValue();
// Getting entity details
ClassOrInterfaceTypeDetails entityDetails = typeLocationService
.getTypeDetails(entity);
// Getting entity fields
List<? extends FieldMetadata> entityFields = entityDetails
.getDeclaredFields();
// Generating empty field list
List<FieldMetadata> geoFields = new ArrayList<FieldMetadata>();
for (FieldMetadata field : entityFields) {
JavaType fieldType = field.getFieldType();
JavaPackage fieldPackage = fieldType.getPackage();
// If is jts field, return as geo field
if (fieldPackage.toString().equals("com.vividsolutions.jts.geom")) {
geoFields.add(field);
}
}
return geoFields;
}
示例3: isGeoEntity
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* This method checks if the current entity is a GEO entity or not
*
* @param scaffoldAnnotation
* @param typeLocationService
* @return
*/
public static boolean isGeoEntity(AnnotationMetadata scaffoldAnnotation,
TypeLocationService typeLocationService) {
// Checking that entity has GEO fields
Object entity = scaffoldAnnotation.getAttribute("formBackingObject")
.getValue();
ClassOrInterfaceTypeDetails entityDetails = typeLocationService
.getTypeDetails((JavaType) entity);
List<? extends FieldMetadata> entityFields = entityDetails
.getDeclaredFields();
Iterator<? extends FieldMetadata> fieldsIterator = entityFields
.iterator();
boolean isValidEntity = false;
while (fieldsIterator.hasNext()) {
// Getting field
FieldMetadata field = fieldsIterator.next();
// Getting field type to get package
JavaType fieldType = field.getFieldType();
JavaPackage fieldPackage = fieldType.getPackage();
// If is jts field, annotate controller with maps
if (fieldPackage.toString().equals("com.vividsolutions.jts.geom")) {
isValidEntity = true;
break;
}
}
return isValidEntity;
}
示例4: 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());
}
示例5: generateEmbeddableTypeToStringMethods
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* Method to generate embeddable to string method
*
* @param embeddableTypeDetails
* @return
*/
private List<MethodMetadataBuilder> generateEmbeddableTypeToStringMethods() {
final List<MethodMetadataBuilder> embeddableToStringMethods = new ArrayList<MethodMetadataBuilder>();
for (JavaType embeddableType : this.embeddableTypes) {
ClassOrInterfaceTypeDetails embeddableTypeDetails = typeLocationService
.getTypeDetails(embeddableType);
// Generating method
final JavaSymbolName methodName = new JavaSymbolName(String.format(
"get%sToStringConverter",
embeddableType.getSimpleTypeName()));
if (governorHasMethod(methodName)) {
continue;
}
final JavaType converterJavaType = SpringJavaType.getConverterType(
embeddableType, JavaType.STRING);
final String targetTypeName = StringUtils
.uncapitalize(embeddableType.getSimpleTypeName());
final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
bodyBuilder.appendFormalLine("return new "
+ converterJavaType.getNameIncludingTypeParameters()
+ "() {");
bodyBuilder.indent();
bodyBuilder.appendFormalLine("public String convert("
+ embeddableType.getSimpleTypeName() + " " + targetTypeName
+ ") {");
bodyBuilder.indent();
// Getting embedded class fields
List<? extends FieldMetadata> embeddableFields = embeddableTypeDetails
.getDeclaredFields();
if (embeddableFields.isEmpty()) {
bodyBuilder.appendFormalLine("return \"\";");
} else {
StringBuilder sb = new StringBuilder();
for (FieldMetadata field : embeddableFields) {
sb.append(String.format(
".append(%s.get%s()).append(\" \")",
targetTypeName, field.getFieldName()
.getSymbolNameCapitalisedFirstLetter()));
}
bodyBuilder.appendFormalLine(String.format(
"return new StringBuilder()%s.toString();",
sb.toString()));
}
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine("}");
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine("};");
embeddableToStringMethods
.add(new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
methodName, converterJavaType, bodyBuilder));
}
return embeddableToStringMethods;
}
示例6: getMetadata
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
* Return an instance of the Metadata offered by this add-on
*/
protected ItdTypeDetailsProvidingMetadataItem getMetadata(
String metadataIdentificationString, JavaType aspectName,
PhysicalTypeMetadata governorPhysicalTypeMetadata,
String itdFilename) {
JavaType javaType = GvNIXEntityMapLayerMetadata
.getJavaType(metadataIdentificationString);
// Getting entity details
ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService()
.getTypeDetails(javaType);
LogicalPath entityPath = PhysicalTypeUtils.getPath(javaType,
getTypeLocationService());
String jpaMetadataId = JpaActiveRecordMetadata.createIdentifier(
javaType, entityPath);
JpaActiveRecordMetadata jpaMetadata = (JpaActiveRecordMetadata) getMetadataService()
.get(jpaMetadataId);
if (jpaMetadata == null) {
// Unsupported type (by now)
return null;
}
GvNIXEntityMapLayerValues annotationValues = new GvNIXEntityMapLayerValues(
entityDetails);
// Getting entity plural
String plural = jpaMetadata.getPlural();
// Getting declared fields
// List<JavaSymbolName> geoFieldNames = new ArrayList<JavaSymbolName>();
Map<JavaSymbolName, AnnotationAttributeValue<Integer>> geoFields = new HashMap<JavaSymbolName, AnnotationAttributeValue<Integer>>();
List<? extends FieldMetadata> fields = entityDetails
.getDeclaredFields();
for (FieldMetadata field : fields) {
// Getting field type to get package
JavaType fieldType = field.getFieldType();
JavaPackage fieldPackage = fieldType.getPackage();
// If has jts field, annotate entity
if (fieldPackage.toString().equals("com.vividsolutions.jts.geom")) {
AnnotationMetadata srsAnnotation = field
.getAnnotation(new JavaType(
"org.gvnix.jpa.geo.hibernatespatial.util.SRS"));
AnnotationAttributeValue<Integer> srsAnnotationValue = null;
if (srsAnnotation != null) {
srsAnnotationValue = srsAnnotation.getAttribute("value");
}
geoFields.put(field.getFieldName(), srsAnnotationValue);
}
}
return new GvNIXEntityMapLayerMetadata(metadataIdentificationString,
aspectName, governorPhysicalTypeMetadata,
getTypeLocationService(), getTypeManagementService(), javaType,
plural, geoFields, annotationValues);
}