Skip to content

Instantly share code, notes, and snippets.

Pedro Veras pedroveras

Block or report user

Report or block pedroveras

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MonthlyExpensesRule
@AllArgsConstructor
public class MonthlyExpensesRule implements Rule {
private Rule nextRule;
@Override
public boolean validate(Client client) {
BigDecimal expensesAmount = client.getExpenses().stream().filter(this::validatePeriod)
.map(Expense::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
View TimeAsClientRule
@AllArgsConstructor
public class TimeAsClientRule implements Rule {
@Override
public boolean validate(Client client) {
return client.getClientSince().plusYears(CashbackParams.TIME_AS_CLIENT)
.isBefore(LocalDateTime.now());
}
}
View SegmentRule.java
@AllArgsConstructor
public class SegmentRule implements Rule {
private Rule nextRule;
@Override
public boolean validate(Client client) {
if (client.getSegment().equals(CashbackParams.SEGMENT)) {
return nextRule.validate(client);
}
View Rule.java
public interface Rule {
void validate(Client client);
}
You can’t perform that action at this time.