Skip to content

Commit

Permalink
Merge pull request #257 from pagox/master
Browse files Browse the repository at this point in the history
added german localization matcher
  • Loading branch information
Exslims authored Jun 12, 2018
2 parents 6d006a3 + 74c9067 commit 6bf29e5
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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 ");
}
}
Original file line number Diff line number Diff line change
@@ -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 ");
}
}

0 comments on commit 6bf29e5

Please sign in to comment.