Add method to get dbevent service-queue-name given service-enum
@@ -9,7 +9,7 @@ public class DBEventManagerConstants {
private final static String QUEUE_SUFFIX = ".queue";
public final static String DB_EVENT_EXCHANGE_NAME = "db.event.exchange";
- enum DBEventService{
+ public enum DBEventService{
USER_PROFILE("user.profile"),
SHARING("sharing"),
@@ -24,8 +24,35 @@ public class DBEventManagerConstants {
}
}
+ /**
+ * Get the queue-name of the service, given service-name as enum
+ * @param dBEventService
+ * @return
+ */
public static String getQueueName(DBEventService dBEventService) {
return dBEventService.toString() + QUEUE_SUFFIX;
}
+ /**
+ * Get the queue-name of the service, given service-name as string
+ * @param dbEventService
+ * @return
+ */
+ public static String getQueueName(String dbEventService) {
+ return getQueueName(getDBEventService(dbEventService));
+ }
+
+ /**
+ * Get the service as enum, given the service-name as string
+ * @param dbEventService
+ * @return
+ */
+ private static DBEventService getDBEventService(String dbEventService) {
+ for (DBEventService service : DBEventService.values()) {
+ if (service.toString().equals(dbEventService)) {
+ return service;
+ }
+ }
+ return null;
+ }
}
