Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active July 30, 2025 07:21
Show Gist options
  • Save trikitrok/d4d6890af072cfbf11a4e469284349e5 to your computer and use it in GitHub Desktop.
Save trikitrok/d4d6890af072cfbf11a4e469284349e5 to your computer and use it in GitHub Desktop.
ClaimBuilder using generics initial version abbreviated
// imports elided...
public abstract class ClaimBuilder<T> {
// some fields elided...
protected ClaimBuilder() {
// setting some defaults elided...
}
public T withClaimId(String number) {
this.claimId = claimId(number);
return (T) this;
}
public T describedAs(String description) {
this.description = description;
return (T) this;
}
public T onClaimDate(String date) {
this.claimDate = claimDate(date);
return (T) this;
}
// other common setters elided
protected ClaimData buildData() {
return new ClaimData(
claimId,
companyId,
description,
claimDate,
policyNumber,
status
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment