/** * Convenience method for returning a simple private field based on the * field name, type, and initializer. * * @param fieldName the field name * @param fieldType the field type * @param fieldInitializer the string to initialize the field with * @return null if the field exists on the governor, otherwise a new field * with the given field name and type */ protected FieldMetadataBuilder getField(final int modifier, final JavaSymbolName fieldName, final JavaType fieldType, final String fieldInitializer) { if (governorTypeDetails.getField(fieldName) != null) { return null; } addToImports(Arrays.asList(fieldType)); return new FieldMetadataBuilder(getId(), modifier, fieldName, fieldType, fieldInitializer); }
private boolean hasField(final JavaSymbolName fieldName, final List<AnnotationMetadata> annotations) { if (governorTypeDetails.getField(fieldName) != null) { return true;
/** * This method returns field to included on service for a Service or * Repository * * @param service * @return */ private FieldMetadata getFieldFor(JavaType type) { // Generating service field name final JavaSymbolName fieldName = new JavaSymbolName(StringUtils.uncapitalize(type.getSimpleTypeName())); FieldMetadata currentField = governorTypeDetails.getField(fieldName); if (currentField != null) { Validate.isTrue(currentField.getFieldType().equals(type), "Field %s already in %s but type not match: expected %s", currentField.getFieldName(), governorTypeDetails.getType(), type); return currentField; } return new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new ArrayList<AnnotationMetadataBuilder>(), fieldName, type).build(); }
final FieldMetadata candidate = governorTypeDetails.getField(fieldSymbolName); if (candidate != null) {
final FieldMetadata candidate = governorTypeDetails.getField(fieldName); if (candidate != null) {
/** * Validates that all dto fields matches with parameters on finder of a repository * * @param formBeanDetails * @param finder * @param repository */ private void checkDtoFieldsForFinder(ClassOrInterfaceTypeDetails formBeanDetails, PartTree finder, JavaType repository) { final JavaType dtoType = formBeanDetails.getName(); final String finderName = finder.getOriginalQuery(); FieldMetadata paramField, dtoField; JavaType paramType, dtoFieldType; for (FinderParameter param : finder.getParameters()) { paramField = param.getPath().peek(); dtoField = formBeanDetails.getField(paramField.getFieldName()); Validate.notNull(dtoField, "Field '%s' not found on DTO %s for finder '%s' of %s", paramField.getFieldName(), dtoType, finderName, repository); paramType = paramField.getFieldType().getBaseType(); dtoFieldType = dtoField.getFieldType().getBaseType(); Validate.isTrue(paramType.equals(dtoFieldType), "Type missmatch for field '%s' on DTO %s for finder '%s' of %s: excepted %s and got %s", dtoField.getFieldName(), dtoType, finderName, repository, paramType, dtoFieldType); } }
/** * Validates that all dto fields matches with parameters on finder of a repository * * @param formBeanDetails * @param finder * @param repository */ private void checkDtoFieldsForFinder(ClassOrInterfaceTypeDetails formBeanDetails, PartTree finder, JavaType repository) { final JavaType dtoType = formBeanDetails.getName(); final String finderName = finder.getOriginalQuery(); FieldMetadata paramField, dtoField; JavaType paramType, dtoFieldType; for (FinderParameter param : finder.getParameters()) { paramField = param.getPath().peek(); dtoField = formBeanDetails.getField(paramField.getFieldName()); Validate.notNull(dtoField, "Field '%s' not found on DTO %s for finder '%s' of %s", paramField.getFieldName(), dtoType, finderName, repository); paramType = paramField.getFieldType().getBaseType(); dtoFieldType = dtoField.getFieldType().getBaseType(); Validate.isTrue(paramType.equals(dtoFieldType), "Type missmatch for field '%s' on DTO %s for finder '%s' of %s: excepted %s and got %s", dtoField.getFieldName(), dtoType, finderName, repository, paramType, dtoFieldType); } }
final JavaSymbolName fieldName = new JavaSymbolName("rnd" + StringUtils.repeat("_", index)); this.rndFieldName = fieldName; final FieldMetadata candidate = governorTypeDetails.getField(fieldName); if (candidate != null) {
/** * Ensures that the governor has provided field. You could indicates if * is necessary to generate the accessor and the mutator methods for this new field manually. * * @param FieldMetadataBuilder the field to include(required) * @since 2.0 */ protected final void ensureGovernorHasField(final FieldMetadataBuilder fieldMetadata, boolean includeAccessor, boolean includeMutator) { if (governorTypeDetails.getField(fieldMetadata.getFieldName()) == null) { builder.addField(fieldMetadata); } if (includeAccessor) { MethodMetadata accessorMethod = getAccessorMethod(fieldMetadata.build()); if (accessorMethod != null && governorTypeDetails.getMethod(accessorMethod.getMethodName()) == null) { builder.addMethod(accessorMethod); } } if (includeMutator) { MethodMetadata mutatorMethod = getMutatorMethod(fieldMetadata.build()); if (mutatorMethod != null && governorTypeDetails.getMethod(mutatorMethod.getMethodName()) == null) { builder.addMethod(mutatorMethod); } } }
/** * Convenience method for returning a simple private field based on the * field name, type, and initializer. * * @param fieldName the field name * @param fieldType the field type * @param fieldInitializer the string to initialize the field with * @return null if the field exists on the governor, otherwise a new field * with the given field name and type */ protected FieldMetadataBuilder getField(final int modifier, final JavaSymbolName fieldName, final JavaType fieldType, final String fieldInitializer) { if (governorTypeDetails.getField(fieldName) != null) { return null; } addToImports(Arrays.asList(fieldType)); return new FieldMetadataBuilder(getId(), modifier, fieldName, fieldType, fieldInitializer); }
final FieldMetadata candidate = governorTypeDetails.getField(fieldSymbolName); if (candidate != null) {
/** * Validates that all dto fields matches with parameters on finder of a repository * * @param formBeanDetails * @param finder * @param repository */ private void checkDtoFieldsForFinder(ClassOrInterfaceTypeDetails formBeanDetails, PartTree finder, JavaType repository) { final JavaType dtoType = formBeanDetails.getName(); final String finderName = finder.getOriginalQuery(); FieldMetadata paramField, dtoField; JavaType paramType, dtoFieldType; for (FinderParameter param : finder.getParameters()) { paramField = param.getPath().peek(); dtoField = formBeanDetails.getField(paramField.getFieldName()); Validate.notNull(dtoField, "Field '%s' not found on DTO %s for finder '%s' of %s", paramField.getFieldName(), dtoType, finderName, repository); paramType = paramField.getFieldType().getBaseType(); dtoFieldType = dtoField.getFieldType().getBaseType(); Validate.isTrue(paramType.equals(dtoFieldType), "Type missmatch for field '%s' on DTO %s for finder '%s' of %s: excepted %s and got %s", dtoField.getFieldName(), dtoType, finderName, repository, paramType, dtoFieldType); } }
/** * Validates that all dto fields matches with parameters on finder of a repository * * @param formBeanDetails * @param finder * @param repository */ private void checkDtoFieldsForFinder(ClassOrInterfaceTypeDetails formBeanDetails, PartTree finder, JavaType repository) { final JavaType dtoType = formBeanDetails.getName(); final String finderName = finder.getOriginalQuery(); FieldMetadata paramField, dtoField; JavaType paramType, dtoFieldType; for (FinderParameter param : finder.getParameters()) { paramField = param.getPath().peek(); dtoField = formBeanDetails.getField(paramField.getFieldName()); Validate.notNull(dtoField, "Field '%s' not found on DTO %s for finder '%s' of %s", paramField.getFieldName(), dtoType, finderName, repository); paramType = paramField.getFieldType().getBaseType(); dtoFieldType = dtoField.getFieldType().getBaseType(); Validate.isTrue(paramType.equals(dtoFieldType), "Type missmatch for field '%s' on DTO %s for finder '%s' of %s: excepted %s and got %s", dtoField.getFieldName(), dtoType, finderName, repository, paramType, dtoFieldType); } }
final FieldMetadata candidate = governorTypeDetails.getField(fieldName); if (candidate != null) {
final JavaSymbolName fieldName = new JavaSymbolName("rnd" + StringUtils.repeat("_", index)); this.rndFieldName = fieldName; final FieldMetadata candidate = governorTypeDetails.getField(fieldName); if (candidate != null) {
/** * Ensures that the governor has provided field. You could indicates if * is necessary to generate the accessor and the mutator methods for this new field manually. * * @param FieldMetadataBuilder the field to include(required) * @since 2.0 */ protected final void ensureGovernorHasField(final FieldMetadataBuilder fieldMetadata, boolean includeAccessor, boolean includeMutator) { if (governorTypeDetails.getField(fieldMetadata.getFieldName()) == null) { builder.addField(fieldMetadata); } if (includeAccessor) { MethodMetadata accessorMethod = getAccessorMethod(fieldMetadata.build()); if (accessorMethod != null && governorTypeDetails.getMethod(accessorMethod.getMethodName()) == null) { builder.addMethod(accessorMethod); } } if (includeMutator) { MethodMetadata mutatorMethod = getMutatorMethod(fieldMetadata.build()); if (mutatorMethod != null && governorTypeDetails.getMethod(mutatorMethod.getMethodName()) == null) { builder.addMethod(mutatorMethod); } } }
final FieldMetadata field = governorTypeDetails.getField(new JavaSymbolName("dod")); if (field != null) { Validate.isTrue(field.getFieldType().equals(dataOnDemandType), governorTypeDetails.getField(new JavaSymbolName(repositoryParamName)); if (fieldRepo != null) { Validate.isTrue(fieldRepo.getFieldType().equals(repository),