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


Java FieldMetadata.getFieldType方法代码示例

本文整理汇总了Java中org.springframework.roo.classpath.details.FieldMetadata.getFieldType方法的典型用法代码示例。如果您正苦于以下问题:Java FieldMetadata.getFieldType方法的具体用法?Java FieldMetadata.getFieldType怎么用?Java FieldMetadata.getFieldType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.roo.classpath.details.FieldMetadata的用法示例。


在下文中一共展示了FieldMetadata.getFieldType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getListInner_getter

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * Generate a getter for <code>field</code>
 * 
 * @param field field metadata
 * @return
 */
private MethodMetadataBuilder getListInner_getter(FieldMetadata field) {
    // Gets filed name
    String fieldName = field.getFieldName().getSymbolName();

    // Generate method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine(MessageFormat.format("return {0};",
            new Object[] { fieldName }));

    // Creates Method builder
    MethodMetadataBuilder builder = new MethodMetadataBuilder(getId(),
            Modifier.PUBLIC, new JavaSymbolName("get".concat(StringUtils
                    .capitalize(fieldName))), field.getFieldType(),
            bodyBuilder);

    return builder;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:24,代码来源:EntityBatchMetadata.java

示例2: getEntityFieldNameJavaType

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * Get java type for field.
 * 
 * @param fieldName Field name of entity
 * @param entity Entity
 * @return Java type of field in entity
 */
protected JavaType getEntityFieldNameJavaType(JavaSymbolName fieldName,
        JavaType entity) {

    JavaType fieldType = null;
    MemberDetails memberDetails = getMemberDetails(entity);
    Iterator<FieldMetadata> fieldsMetadata = webMetadataService
            .getScaffoldEligibleFieldMetadata(entity, memberDetails, null)
            .iterator();
    while (fieldsMetadata.hasNext() && fieldType == null) {
        FieldMetadata fieldMetadata = fieldsMetadata.next();
        if (fieldMetadata.getFieldName().equals(fieldName)) {
            fieldType = fieldMetadata.getFieldType();
        }
    }

    return fieldType;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:25,代码来源:SeleniumServicesImpl.java

示例3: getFieldEntityPlural

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * Given a FieldMetadata it returns the pluralized name of its Class in
 * plural.
 * <p>
 * If the FieldMetadata type is a Collection will return the plural of the
 * parameter in the Collection definition. That is:<br/>
 * <code>java.util.Set&lt;Foo&gt;</code> will return <code>Foos</code>
 * 
 * @param fieldMetadata
 * @return
 */
private String getFieldEntityPlural(FieldMetadata fieldMetadata) {
    JavaType fieldEntity = fieldMetadata.getFieldType();
    if (fieldEntity.isCommonCollectionType()
            && !fieldEntity.getParameters().isEmpty()) {
        fieldEntity = fieldEntity.getParameters().get(0);
    }
    ClassOrInterfaceTypeDetails cid = getTypeLocationService()
            .getTypeDetails(fieldEntity);
    JavaType javaType = cid.getName();
    LogicalPath path = PhysicalTypeIdentifier.getPath(cid
            .getDeclaredByMetadataId());

    PluralMetadata pluralMetadata = (PluralMetadata) getMetadataService()
            .get(PluralMetadata.createIdentifier(javaType, path));

    return pluralMetadata.getPlural().toLowerCase();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:29,代码来源:AbstractPatternJspMetadataListener.java

示例4: getJavaTypeForField

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * {@link org.springframework.roo.addon.web.mvc.jsp.JspViewManager#getJavaTypeForField(FieldMetadata)}
 */
private JavaType getJavaTypeForField(FieldMetadata field) {
    if (field.getFieldType().isCommonCollectionType()) {
        // Currently there is no scaffolding available for Maps (see
        // ROO-194)
        if (field.getFieldType().equals(new JavaType(Map.class.getName()))) {
            return null;
        }
        List<JavaType> parameters = field.getFieldType().getParameters();
        if (parameters.size() == 0) {
            throw new IllegalStateException(
                    "Unable to determine the parameter type for the "
                            + field.getFieldName().getSymbolName()
                            + " field in "
                            + formbackingType.getSimpleTypeName());
        }
        return parameters.get(0);
    }
    return field.getFieldType();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:23,代码来源:AbstractPatternJspMetadataListener.java

示例5: getFieldTypeOfFinder

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
public JavaType getFieldTypeOfFinder(String fieldName) {
    String paramName;
    for (FieldMetadata field : finderMethod.getFinderMethodParamFields()) {
        paramName = field.getFieldName().getSymbolName();
        if (paramName.equalsIgnoreCase(fieldName)) {
            return field.getFieldType();
        }
        else if (paramName.startsWith("min") || paramName.startsWith("max")) {
            // for params used on between comparations
            if (paramName.substring(3).equalsIgnoreCase(fieldName)) {
                return field.getFieldType();
            }
        }
    }
    return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:17,代码来源:FinderToDslHelper.java

示例6: getJavaTypeForField

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private JavaType getJavaTypeForField(final FieldMetadata field) {
    if (field.getFieldType().isCommonCollectionType()) {
        // Currently there is no scaffolding available for Maps (see
        // ROO-194)
        if (field.getFieldType().equals(new JavaType(Map.class.getName()))) {
            return null;
        }
        final List<JavaType> parameters = field.getFieldType()
                .getParameters();
        if (parameters.isEmpty()) {
            throw new IllegalStateException(
                    "Unable to determine the parameter type for the "
                            + field.getFieldName().getSymbolName()
                            + " field in "
                            + formBackingType.getSimpleTypeName());
        }
        return parameters.get(0);
    }
    return field.getFieldType();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:21,代码来源:JspViewManager.java

示例7: getRelationFields

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * Read the values of GvNIXRelationsPattern and for each field defined as
 * relation retrieve its java type.
 * 
 * @param mid Metadata identification string
 * @param controller Controller physical type metadata
 * @param entity Entity java type
 * @param webMetadataService Web metadata service
 * @return Map with java types and java type details
 */
private List<JavaType> getRelationFields(String mid,
        PhysicalTypeMetadata controller, JavaType entity,
        WebMetadataService webMetadataService) {

    // Fields name defined into relations pattern annotation
    List<String> relations = _patternService
            .getControllerRelationsPatternsFields(controller);

    // Get each relation java type from eligible scaffolding fields
    List<FieldMetadata> scaffoldFields = getScaffoldEligibleFields(entity,
            mid, webMetadataService);

    // We're interested only in those types defined in GvNIXRelationsPattern
    // values
    List<JavaType> validFields = new ArrayList<JavaType>();
    for (FieldMetadata scaffoldEligibleField : scaffoldFields) {

        // This scaffold eligible field is defined into relations pattern
        // annotation: is a valid field
        if (relations.contains(scaffoldEligibleField.getFieldName()
                .getSymbolName())) {

            // Get valid field type (simple or collection)
            JavaType validField = scaffoldEligibleField.getFieldType();
            if (validField.isCommonCollectionType()
                    && !validField.getParameters().isEmpty()) {

                validField = validField.getParameters().get(0);
            }

            validFields.add(validField);
        }
    }

    return validFields;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:47,代码来源:AbstractPatternMetadataProvider.java

示例8: getEntityGeoFields

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的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

示例9: isGeoEntity

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的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

示例10: getDigitsBody

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private String getDigitsBody(final FieldMetadata field,
        final AnnotationMetadata digitsAnnotation, final String suffix) {
    final String fieldName = field.getFieldName().getSymbolName();
    final JavaType fieldType = field.getFieldType();

    final Integer integerValue = (Integer) digitsAnnotation.getAttribute(
            new JavaSymbolName("integer")).getValue();
    final Integer fractionValue = (Integer) digitsAnnotation.getAttribute(
            new JavaSymbolName("fraction")).getValue();
    final BigDecimal maxValue = new BigDecimal(StringUtils.rightPad("9",
            integerValue, '9')
            + "."
            + StringUtils.rightPad("9", fractionValue, '9'));

    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    if (fieldType.equals(BIG_DECIMAL)) {
        bodyBuilder.appendFormalLine("if (" + fieldName + ".compareTo(new "
                + BIG_DECIMAL.getSimpleTypeName() + "(\"" + maxValue
                + "\")) == 1) {");
        bodyBuilder.indent();
        bodyBuilder.appendFormalLine(fieldName + " = new "
                + BIG_DECIMAL.getSimpleTypeName() + "(\"" + maxValue
                + "\");");
    }
    else {
        bodyBuilder.appendFormalLine("if (" + fieldName + " > "
                + maxValue.doubleValue() + suffix + ") {");
        bodyBuilder.indent();
        bodyBuilder.appendFormalLine(fieldName + " = "
                + maxValue.doubleValue() + suffix + ";");
    }

    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");

    return bodyBuilder.getOutput();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:38,代码来源:DataOnDemandMetadata.java

示例11: getDeclaredGetter

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * Obtains the specific accessor method that is either contained within the
 * normal Java compilation unit or will be introduced by this add-on via an
 * ITD.
 * 
 * @param field
 *            that already exists on the type either directly or via
 *            introduction (required; must be declared by this type to be
 *            located)
 * @return the method corresponding to an accessor, or null if not found
 */
private MethodMetadataBuilder getDeclaredGetter(final FieldMetadata field) {
	Validate.notNull(field, "Field required");

	// Compute the mutator method name
	final JavaSymbolName methodName = BeanInfoUtils
			.getAccessorMethodName(field);

	// See if the type itself declared the accessor
	if (governorHasMethod(methodName)) {
		return null;
	}

	// Decide whether we need to produce the accessor method (see ROO-619
	// for reason we allow a getter for a final field)
	if (annotationValues.isGettersByDefault()
			&& !Modifier.isTransient(field.getModifier())
			&& !Modifier.isStatic(field.getModifier())) {
		final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
		bodyBuilder.appendFormalLine("return this."
				+ field.getFieldName().getSymbolName() + ";");

		return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
				methodName, field.getFieldType(), bodyBuilder);
	}

	return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:39,代码来源:JavaBeanMetadata.java

示例12: getDeclaredSetter

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * Obtains the specific mutator method that is either contained within the
 * normal Java compilation unit or will be introduced by this add-on via an
 * ITD.
 * 
 * @param field
 *            that already exists on the type either directly or via
 *            introduction (required; must be declared by this type to be
 *            located)
 * @return the method corresponding to a mutator, or null if not found
 */
private MethodMetadataBuilder getDeclaredSetter(final FieldMetadata field) {
	Validate.notNull(field, "Field required");

	// Compute the mutator method name
	final JavaSymbolName methodName = BeanInfoUtils
			.getMutatorMethodName(field);

	// Compute the mutator method parameters
	final JavaType parameterType = field.getFieldType();

	// See if the type itself declared the mutator
	if (governorHasMethod(methodName, parameterType)) {
		return null;
	}

	// Compute the mutator method parameter names
	final List<JavaSymbolName> parameterNames = Arrays.asList(field
			.getFieldName());

	// Decide whether we need to produce the mutator method (disallowed for
	// final fields as per ROO-36)
	if (annotationValues.isSettersByDefault()
			&& !Modifier.isTransient(field.getModifier())
			&& !Modifier.isStatic(field.getModifier())
			&& !Modifier.isFinal(field.getModifier())) {
		final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
		bodyBuilder.appendFormalLine("this."
				+ field.getFieldName().getSymbolName() + " = "
				+ field.getFieldName().getSymbolName() + ";");

		return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
				methodName, JavaType.VOID_PRIMITIVE,
				AnnotatedJavaType.convertFromJavaTypes(parameterType),
				parameterNames, bodyBuilder);
	}

	return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:50,代码来源:JavaBeanMetadata.java

示例13: isFieldOfInterest

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private boolean isFieldOfInterest(final FieldMetadata field) {
    final JavaType fieldType = field.getFieldType();
    return !fieldType.isCommonCollectionType()
            && !fieldType.isArray() // Exclude collections and arrays
            && !fieldType.equals(BOOLEAN_PRIMITIVE)
            // Boolean values would not be meaningful in this presentation
            && !fieldType.equals(BOOLEAN_OBJECT)
            && !fieldType.equals(BYTE_ARRAY_PRIMITIVE)
            // Not interested in embedded types
            && !field.getCustomData().keySet().contains(EMBEDDED_FIELD);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:12,代码来源:JsfManagedBeanMetadataProviderImpl.java

示例14: existsField

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
 * This method checks if field exists in the Controller related entity
 * 
 * @param controller
 * @return
 */
private JavaType existsField(WebScaffoldAnnotationValues annotationValues,
        JavaSymbolName field) {
    JavaType entity = annotationValues.getFormBackingObject();

    final ClassOrInterfaceTypeDetails cid = getTypeLocationService()
            .getTypeDetails(entity);

    MemberDetails memberDetails = getMemberDetailsScanner()
            .getMemberDetails(getClass().getName(), cid);

    if (cid == null) {
        LOGGER.log(Level.INFO,
                "Controller Entity cannnot be resolved to a type in your project");
        return null;
    }

    List<? extends FieldMetadata> fieldList = memberDetails.getFields();
    Iterator<? extends FieldMetadata> it = fieldList.iterator();

    JavaType fieldType = null;

    boolean exists = false;

    while (it.hasNext()) {
        FieldMetadata currentField = it.next();
        if (field.getReadableSymbolName().equals(
                currentField.getFieldName().getReadableSymbolName())) {
            fieldType = currentField.getFieldType();
            exists = true;
        }
    }
    if (!exists) {
        LOGGER.log(Level.INFO, "The field '" + field.getSymbolName()
                + "' can not be resolved as field of your entity.");
        return null;
    }

    return fieldType;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:46,代码来源:LoupefieldOperationsImpl.java

示例15: getColumnPrecisionAndScaleBody

import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private String getColumnPrecisionAndScaleBody(final FieldMetadata field,
        final Map<String, Object> values, final String suffix) {
    if (values == null || !values.containsKey("precision")) {
        return InvocableMemberBodyBuilder.getInstance().getOutput();
    }

    final String fieldName = field.getFieldName().getSymbolName();
    final JavaType fieldType = field.getFieldType();

    Integer precision = (Integer) values.get("precision");
    Integer scale = (Integer) values.get("scale");
    if (precision != null && scale != null && precision < scale) {
        scale = 0;
    }

    final BigDecimal maxValue;
    if (scale == null || scale == 0) {
        maxValue = new BigDecimal(StringUtils.rightPad("9", precision, '9'));
    } else {
        maxValue = new BigDecimal(StringUtils.rightPad("9",
                precision - scale, '9')
                + "."
                + StringUtils.rightPad("9", scale, '9'));
    }

    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    if (fieldType.equals(BIG_DECIMAL)) {
        bodyBuilder.appendFormalLine("if (" + fieldName + ".compareTo(new "
                + BIG_DECIMAL.getSimpleTypeName() + "(\"" + maxValue
                + "\")) == 1) {");
        bodyBuilder.indent();
        bodyBuilder.appendFormalLine(fieldName + " = new "
                + BIG_DECIMAL.getSimpleTypeName() + "(\"" + maxValue
                + "\");");
    }
    else {
        bodyBuilder.appendFormalLine("if (" + fieldName + " > "
                + maxValue.doubleValue() + suffix + ") {");
        bodyBuilder.indent();
        bodyBuilder.appendFormalLine(fieldName + " = "
                + maxValue.doubleValue() + suffix + ";");
    }

    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");

    return bodyBuilder.getOutput();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:49,代码来源:DataOnDemandMetadata.java


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