Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

How to control indentation of Annotation members #658

Closed
developerworks opened this issue Jul 30, 2018 · 6 comments
Closed

How to control indentation of Annotation members #658

developerworks opened this issue Jul 30, 2018 · 6 comments

Comments

@developerworks
Copy link

developerworks commented Jul 30, 2018

I generate code like this, but i have not find the way to control the indentation of annotation members

import java.lang.Long;
import java.lang.String;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Generated by javapeot
 */
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(
        name = "user"
)
public class User {
    @Id
    @GeneratedValue(
            strategy = GenerationType.IDENTITY
    )
    @Column(
            name = "id"
    )
    private Long id;

    @Column(
            name = "name"
    )
    private String name;

    @Column(
            name = "created_at"
    )
    private Timestamp createdAt;
}

I want this:

@GeneratedValue(
        strategy = GenerationType.IDENTITY
)

to be

@GeneratedValue(strategy = GenerationType.IDENTITY)
@developerworks
Copy link
Author

This is the annotation creation method:

    private AnnotationSpec createJpaColumnAnnotation(String columnName) {
        return AnnotationSpec.builder(ClassName.get("javax.persistence", "Column"))
            .addMember("name", "$S", columnName)
            .build();
    }

@swankjesse
Copy link
Collaborator

We don't have APIs to customize indentation. But if there's a change we should make to the defaults please send a pull request!

@topalavlad
Copy link
Contributor

I think the compact type of annotations is usually preferred. Would you guys be OK with changing the default to that?

@JakeWharton
Copy link
Collaborator

JakeWharton commented Oct 20, 2018 via email

@topalavlad
Copy link
Contributor

Then this issue can be closed or is there a plan to add APIs to customize indentation?

@JakeWharton
Copy link
Collaborator

JakeWharton commented Oct 20, 2018 via email

@Egorand Egorand closed this as completed Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants