add generic type (#32)

This commit is contained in:
Anatoly Karlov 2022-03-16 15:30:06 +07:00 committed by GitHub
parent 749ec26da1
commit 7051360868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 30 deletions

View File

@ -41,10 +41,11 @@ public class PaymentMethodHandler extends AbstractDominantHandler<PaymentMethodO
.or(() -> PaymentMethodUtils.getPaymentMethodRefIdByPaymentTerminal(paymentMethod))
.or(() -> PaymentMethodUtils.getPaymentMethodRefIdByDigitalWallet(paymentMethod))
.or(() -> PaymentMethodUtils.getPaymentMethodRefIdByCryptoCurrency(paymentMethod))
.or(() -> PaymentMethodUtils.getPaymentMethodRefIdByMobile(paymentMethod));
.or(() -> PaymentMethodUtils.getPaymentMethodRefIdByMobile(paymentMethod))
.or(() -> PaymentMethodUtils.getPaymentMethodRefIdByGeneric(paymentMethod));
if (paymentMethodRefId.isEmpty()) {
throw new IllegalArgumentException("Unknown payment method: " + paymentMethod);
throw new IllegalArgumentException("Unknown payment method: " + paymentMethod.get().get().getSetField());
}
return getPaymentType(getTargetObject()) + SEPARATOR + paymentMethodRefId.get();

View File

@ -15,22 +15,22 @@ public class PaymentMethodUtils {
public static Optional<String> getPaymentMethodRefIdByBankCard(
Supplier<Optional<PaymentMethod>> paymentMethod) {
return paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetBankCard)
.map(dev.vality.damsel.domain.PaymentMethod::getBankCard)
.filter(PaymentMethod::isSetBankCard)
.map(PaymentMethod::getBankCard)
.flatMap(bankCard -> PaymentSystemUtil.getPaymentSystemNameIfPresent(
bankCard.getPaymentSystem(),
bankCard.getPaymentSystemDeprecated()))
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetBankCardDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getBankCardDeprecated)
.filter(PaymentMethod::isSetBankCardDeprecated)
.map(PaymentMethod::getBankCardDeprecated)
.map(Enum::name))
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetEmptyCvvBankCardDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getEmptyCvvBankCardDeprecated)
.filter(PaymentMethod::isSetEmptyCvvBankCardDeprecated)
.map(PaymentMethod::getEmptyCvvBankCardDeprecated)
.map(legacyBankCardPaymentSystem -> EMPTY_CVV + legacyBankCardPaymentSystem.name()))
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetTokenizedBankCardDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getTokenizedBankCardDeprecated)
.filter(PaymentMethod::isSetTokenizedBankCardDeprecated)
.map(PaymentMethod::getTokenizedBankCardDeprecated)
.flatMap(PaymentMethodUtils::getTokenizedBankCardId));
}
@ -50,50 +50,59 @@ public class PaymentMethodUtils {
}
public static Optional<String> getPaymentMethodRefIdByPaymentTerminal(
Supplier<Optional<dev.vality.damsel.domain.PaymentMethod>> paymentMethod) {
Supplier<Optional<PaymentMethod>> paymentMethod) {
return paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetPaymentTerminal)
.map(dev.vality.damsel.domain.PaymentMethod::getPaymentTerminal)
.filter(PaymentMethod::isSetPaymentTerminal)
.map(PaymentMethod::getPaymentTerminal)
.map(PaymentServiceRef::getId)
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetPaymentTerminalDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getPaymentTerminalDeprecated)
.filter(PaymentMethod::isSetPaymentTerminalDeprecated)
.map(PaymentMethod::getPaymentTerminalDeprecated)
.map(Enum::name));
}
public static Optional<String> getPaymentMethodRefIdByDigitalWallet(
Supplier<Optional<dev.vality.damsel.domain.PaymentMethod>> paymentMethod) {
Supplier<Optional<PaymentMethod>> paymentMethod) {
return paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetDigitalWallet)
.map(dev.vality.damsel.domain.PaymentMethod::getDigitalWallet)
.filter(PaymentMethod::isSetDigitalWallet)
.map(PaymentMethod::getDigitalWallet)
.map(PaymentServiceRef::getId)
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetDigitalWalletDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getDigitalWalletDeprecated)
.filter(PaymentMethod::isSetDigitalWalletDeprecated)
.map(PaymentMethod::getDigitalWalletDeprecated)
.map(Enum::name));
}
public static Optional<String> getPaymentMethodRefIdByCryptoCurrency(
Supplier<Optional<dev.vality.damsel.domain.PaymentMethod>> paymentMethod) {
Supplier<Optional<PaymentMethod>> paymentMethod) {
return paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetCryptoCurrency)
.map(dev.vality.damsel.domain.PaymentMethod::getCryptoCurrency)
.filter(PaymentMethod::isSetCryptoCurrency)
.map(PaymentMethod::getCryptoCurrency)
.map(CryptoCurrencyRef::getId)
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetCryptoCurrencyDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getCryptoCurrencyDeprecated)
.filter(PaymentMethod::isSetCryptoCurrencyDeprecated)
.map(PaymentMethod::getCryptoCurrencyDeprecated)
.map(Enum::name));
}
public static Optional<String> getPaymentMethodRefIdByMobile(
Supplier<Optional<dev.vality.damsel.domain.PaymentMethod>> paymentMethod) {
Supplier<Optional<PaymentMethod>> paymentMethod) {
return paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetMobile)
.map(dev.vality.damsel.domain.PaymentMethod::getMobile)
.filter(PaymentMethod::isSetMobile)
.map(PaymentMethod::getMobile)
.map(MobileOperatorRef::getId)
.or(() -> paymentMethod.get()
.filter(dev.vality.damsel.domain.PaymentMethod::isSetMobileDeprecated)
.map(dev.vality.damsel.domain.PaymentMethod::getMobileDeprecated)
.filter(PaymentMethod::isSetMobileDeprecated)
.map(PaymentMethod::getMobileDeprecated)
.map(Enum::name));
}
public static Optional<String> getPaymentMethodRefIdByGeneric(
Supplier<Optional<PaymentMethod>> paymentMethod) {
return paymentMethod.get()
.filter(PaymentMethod::isSetGeneric)
.map(PaymentMethod::getGeneric)
.map(GenericPaymentMethod::getPaymentService)
.map(PaymentServiceRef::getId);
}
}

View File

@ -0,0 +1,2 @@
ALTER TYPE nw.payment_method_type ADD VALUE 'generic';
ALTER TYPE nw.destination_resource_type ADD VALUE 'generic';