From 74c9067b384346bd099b1c161c0d7f938b244315 Mon Sep 17 00:00:00 2001 From: Pagox Date: Thu, 15 Mar 2018 11:41:01 +0100 Subject: [PATCH] added german localization matcher --- .../interceptor/PlainMessageInterceptor.java | 2 ++ .../TradeIncMessagesInterceptor.java | 12 ++++++++++ .../TradeOutMessagesInterceptor.java | 24 +++++++++++++++++++ .../plain/GermanIncLocalizationMatcher.java | 20 ++++++++++++++++ .../plain/GermanOutLocalizationMatcher.java | 20 ++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanIncLocalizationMatcher.java create mode 100644 app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanOutLocalizationMatcher.java diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java index 3b38d70b..5eb5f15a 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java @@ -23,6 +23,8 @@ public PlainMessageInterceptor() { this.clients.add(new BZOutLocalizationMatcher()); this.clients.add(new FrenchIncLocalizationMatcher()); this.clients.add(new FrenchOutLocalizationMatcher()); + this.clients.add(new GermanIncLocalizationMatcher()); + this.clients.add(new GermanOutLocalizationMatcher()); } @Override diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java index 431196e5..3757376c 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java @@ -24,6 +24,7 @@ public TradeIncMessagesInterceptor() { this.clients.add(new ArabicInLocalizationMatcher()); this.clients.add(new BZIncLocalizationMatcher()); this.clients.add(new FrenchIncLocalizationMatcher()); + this.clients.add(new GermanIncLocalizationMatcher(); } @Override @@ -126,4 +127,15 @@ public String trimString(String src) { return StringUtils.substringAfter(src, "@De"); } } +private class GermanIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Von") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Von"); + } + } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java index 1f85b33c..9f191ac8 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java @@ -26,6 +26,7 @@ public TradeOutMessagesInterceptor() { this.clients.add(new ArabicOutLocalizationMatcher()); this.clients.add(new BZOutLocalizationMatcher()); this.clients.add(new FrenchOutLocalizationMatcher()); + this.clients.add(new GermanOutLocalizationMatcher()); } @Override @@ -183,4 +184,27 @@ public NotificationDescriptor getDescriptor(String message) { return descriptor; } } + + private class GermanOutLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@An") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@An"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if (descriptor instanceof ItemTradeNotificationDescriptor) { + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + } else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanIncLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanIncLocalizationMatcher.java new file mode 100644 index 00000000..ab357a98 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanIncLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class GermanIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Von"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message, "@Von "); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanOutLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanOutLocalizationMatcher.java new file mode 100644 index 00000000..e519d276 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/GermanOutLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class GermanOutLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@An"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message, "@An "); + } +}