当前位置: 首页>>代码示例>>Java>>正文


Java ClassOrInterfaceTypeDetails.getDeclaredFields方法代码示例

本文整理汇总了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;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:23,代码来源:WebScaffoldMetadata.java

示例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;

}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:44,代码来源:GvNIXMapViewerMetadata.java

示例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;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:41,代码来源:GeoUtils.java

示例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());
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:46,代码来源:JavaBeanMetadataProvider.java

示例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;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:72,代码来源:ConversionServiceMetadata.java

示例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);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:61,代码来源:GvNIXEntityMapLayerMetadataProvider.java


注:本文中的org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails.getDeclaredFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。