Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proposal] generate increment methods for numeric fields #171

Open
eshepelyuk opened this issue Mar 21, 2024 · 0 comments
Open

[proposal] generate increment methods for numeric fields #171

eshepelyuk opened this issue Mar 21, 2024 · 0 comments

Comments

@eshepelyuk
Copy link

eshepelyuk commented Mar 21, 2024

Hello

it could be useful to have methods that return a copy of record with particular numeric field (including BigDecimal) increased by a value.

I.e. instead of this

import io.soabase.recordbuilder.core.RecordBuilder;

@RecordBuilder
public record MyRec(Long cnt) implements MyRecBuilder.With {}

var r1 = new MyRec(10L);
var r2 = r1.withCnt(r1.cnt() + 5);

One could write smth like this

var r2 = r1.incrCnt(5);

Basically all java operaators like += , -= etc could be generated, so one could write

r1.plusCnt(5); // += 5
r1.divCnt(5); // %= 5

etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants