protected MethodMetadataBuilder getAccessorMethod(final JavaSymbolName fieldName, final JavaType fieldType) { return getAccessorMethod(fieldName, fieldType, InvocableMemberBodyBuilder.getInstance() .appendFormalLine("return " + fieldName + ";")); }
public String getBody() { if (bodyBuilder != null) { return bodyBuilder.getOutput(); } return null; }
/** * Indicates whether the governor has a method with the given signature. * * @param methodName the name of the method for which to search * @param parameterTypes the method's parameter types * @return see above * @since 1.2.0 */ protected boolean governorHasMethod(final JavaSymbolName methodName, final JavaType... parameterTypes) { return getGovernorMethod(methodName, parameterTypes) != null; }
private InvocableMemberBodyBuilder getInterfaceMethodBody(JavaType returnType) { final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine("// Interface Implementation"); bodyBuilder.appendFormalLine(RETURN_0); return bodyBuilder; }
protected MethodMetadataBuilder getMutatorMethod(final JavaSymbolName fieldName, final JavaType parameterType) { return getMutatorMethod( fieldName, parameterType, InvocableMemberBodyBuilder.getInstance().appendFormalLine( "this." + fieldName.getSymbolName() + " = " + fieldName.getSymbolName() + ";")); }
public InvocableMemberBodyBuilder getBodyBuilder() { if (bodyBuilder == null) { bodyBuilder = new InvocableMemberBodyBuilder(); } return bodyBuilder; }
/** * Generate the method body for "createForm" method when entity hasn't a valid constructor * * @param bodyBuilder */ protected void generateNoConstructorCreateFormMethodBody(InvocableMemberBodyBuilder bodyBuilder) { // throw new IllegalStateException("No no-argument constructor found for the entity "+ Pet.class.getName() +". This is required by the JPA especification. Please provide a default constructor for the related class and the open Spring Roo console again."); bodyBuilder .appendFormalLine( "throw new IllegalStateException(\"No no-argument constructor found for the entity \"+ %s.class.getName() +\". This is required by the JPA especification. Please provide a default constructor for the related class and open the Spring Roo console again.\");", getNameOfJavaType(this.entity)); }
public InvocableMemberBodyBuilder newLine() { newLine(true); return this; }
public InitializerMetadataBuilder(final InitializerMetadata existing) { super(existing); isStatic = existing.getModifier() == Modifier.STATIC || existing.isStatic(); bodyBuilder.append(existing.getBody()); }
private void appendTerminator() { Validate.isTrue(indentLevel == 1, "Indent level must be 1 (not %d) to conclude", indentLevel); indentRemove(); // Ensure we present the content flag, as it will be set true during the // formal line append final boolean contentBefore = content; appendFormalLine("}"); content = contentBefore; }
/** * The {@link ItdTriggerBasedMetadataProvider} service has been removed, so * unregister the trigger of the {@link #javaType}. */ @Override public void removedService(ServiceReference<ItdTriggerBasedMetadataProvider> ref, ItdTriggerBasedMetadataProvider metadataProvider) { metadataProvider.removeMetadataTrigger(this.javaType); super.removedService(ref, metadataProvider); } }
/** * Returns String which represents type inside ITD * * Delegates on {@link JavaType#getNameIncludingTypeParameters(boolean, org.springframework.roo.model.ImportRegistrationResolver)} * (asStatic = false) * * @param type * @return */ protected String getNameOfJavaType(JavaType type) { return getNameOfJavaType(type, false); }
/** * Removes the given {@link JavaType}s as triggering metadata registration. * * @param triggerTypes the type-level annotations to remove as triggers * @since 1.2.0 */ public void removeMetadataTriggers(final JavaType... triggerTypes) { for (final JavaType triggerType : triggerTypes) { removeMetadataTrigger(triggerType); } }
/** * Prints a blank line, ensuring any indent is included before doing so. */ private ItdSourceFileComposer newLine() { return newLine(true); }
/** * Registers the given {@link JavaType}s as triggering metadata * registration. * * @param triggerTypes the type-level annotations to detect that will cause * metadata creation * @since 1.2.0 */ public void addMetadataTriggers(final JavaType... triggerTypes) { for (final JavaType triggerType : triggerTypes) { addMetadataTrigger(triggerType); } }
protected FieldMetadataBuilder getField(final JavaSymbolName fieldName, final JavaType fieldType) { return getField(PRIVATE, fieldName, fieldType, null); }
public static InvocableMemberBodyBuilder getInstance() { return new InvocableMemberBodyBuilder(); }
/** * Generate body for create method when entity has not default constructor available * * @param bodyBuilder */ private void generateNoConstructorCreateMethodBody(InvocableMemberBodyBuilder bodyBuilder) { // throw new IllegalStateException("No no-argument constructor found for the entity "+ Pet.class.getName() +". This is required by the JPA especification. Please provide a default constructor for the related class and open the Spring Roo console again."); bodyBuilder .appendFormalLine( "throw new IllegalStateException(\"No no-argument constructor found for the entity \"+ %s.class.getName() +\". This is required by the JPA especification. Please provide a default constructor for the related class and open the Spring Roo console again.\");", getNameOfJavaType(this.entity)); }
public String getBody() { if (bodyBuilder != null) { return bodyBuilder.getOutput(); } return null; }
/** * Indicates whether the governor has a method with the given signature. * * @param methodName the name of the method for which to search * @param parameterTypes the method's parameter types * @return see above * @since 1.2.1 */ protected boolean governorHasMethod(final JavaSymbolName methodName, final List<JavaType> parameterTypes) { return getGovernorMethod(methodName, parameterTypes) != null; }