Please tell me how to use code style formatting in IDEA?
I used the google-java-format plugin and it works very well for me.
An example of my code using the google-java-format plugin:
public Single<MonetaryAmount> calculateInterest(Status status, Account account) {
var accountId = account.getKey().getRootId();
return signIn
.resolve(param1, param2, param3, param4, param5)
.flatMap(
loginPeriod ->
findBalances(
lowestPeriodStartDate(loginPeriod, accountId),
highestPeriodEndDate(loginPeriod, accountId),
status.getStatusDetails().getLoginConfiguration(),
accountId)
.map(balances -> getInterestAccountBalance(balances, status.getSource()))
.flatMap(
accountBalance ->
moneyCalculator.calculateBalanceMoney(accountBalance, loginPeriod)));
}
I also decided to try intellij-java-google-style.xml, which I found on github.
I went to Preferences -> Editor -> Code Style -> Java and imported this scheme there.
In the end, I ended up like this (not very pretty):
public Single<MonetaryAmount> calculateInterest(
Status status,
Account account) {
var accountId = account.getKey().getRootId();
return signIn.resolve(param1, param2, param3,
param4, param5)
.flatMap(loginPeriod -> findBalances(lowestPeriodStartDate(loginPeriod, accountId),
highestPeriodEndDate(loginPeriod, accountId),
status.getStatusDetails().getLoginConfiguration(),
accountId)
.map(balances -> getInterestAccountBalance(balances,
status.getSource()))
.flatMap(accountBalance -> moneyCalculator
.calculateBalanceMoney(
accountBalance,
loginPeriod))
);
}
I tried to set my own settings for tab size, indent, continuation indent - but it didn't help.
Tell me how, using your settings in IDEE, to achieve the same beautiful formatting as it happens using the google-java-format plugin?
I don't want to use a plugin.
Thank you!