@@ -0,0 +1,2724 @@
+package uworkers.core.config;%0A%0Aimport java.util.List;%0A%0Aimport lombok.val;%0Aimport trip.spi.helpers.filter.Filter;%0Aimport uworkers.api.Consumer;%0Aimport uworkers.api.Subscriber;%0Aimport uworkers.api.Worker;%0Aimport uworkers.utils.EndpointNamed;%0A%0Apublic class Endpoints %7B%0A%0A%09public static String extractNameFromConsumer(final Class%3C?%3E targetConsumer) %7B%0A%09%09val worker = targetConsumer.getAnnotation(Worker.class);%0A%09%09if ( worker != null && !worker.name().isEmpty() )%0A%09%09%09return worker.name();%0A%09%09val subscriber = targetConsumer.getAnnotation(Subscriber.class);%0A%09%09if ( subscriber != null && !subscriber.name().isEmpty() )%0A%09%09%09return subscriber.name();%0A%09%09throw new IllegalStateException(%22Missing @Worker or @Subscriber annotation on consumer class.%22);%0A%09%7D%0A%09%0A%09//TODO: testar isso aqui%0A%09public static String extractQueueOrTopicNameFromConsumer(final Class%3C?%3E targetConsumer) %7B%0A%09%09val worker = targetConsumer.getAnnotation(Worker.class);%0A%09%09if ( worker != null && !worker.queue().isEmpty() )%0A%09%09%09return worker.queue();%0A%09%09val subscriber = targetConsumer.getAnnotation(Subscriber.class);%0A%09%09if ( subscriber != null && !subscriber.topic().isEmpty() )%0A%09%09%09return subscriber.topic();%0A%09%09return null;%0A%09%7D%0A%09%0A%09@SuppressWarnings(%22rawtypes%22) %0A%09public static EndpointConsumerConfiguration retrieveConfigForConsumer(%0A%09%09%09final Class%3CConsumer%3E consumerClass, final List%3CEndpointConsumerConfiguration%3E consumerConfigs )%0A%09%7B%0A%09%09final EndpointConsumerConfiguration configuration = FixedEndpointConsumerConfiguration.from(consumerClass);%0A%09%09return retrieveConfigForConsumer(consumerConfigs, configuration);%0A%09%7D%0A%0A%09public static EndpointConsumerConfiguration retrieveConfigForConsumer(Worker worker,%0A%09%09%09List%3CEndpointConsumerConfiguration%3E endpointConsumers) %7B%0A%09%09val name = worker.name();%0A%09%09final EndpointConsumerConfiguration configuration = new FixedEndpointConsumerConfiguration( name, name );%0A%09%09return retrieveConfigForConsumer( endpointConsumers, configuration);%0A%09%7D%0A%09%0A%09public static EndpointConsumerConfiguration retrieveConfigForConsumer(Subscriber subscriber,%0A%09%09%09List%3CEndpointConsumerConfiguration%3E endpointConsumers) %7B%0A%09%09val name = subscriber.name();%0A%09%09final EndpointConsumerConfiguration configuration = new FixedEndpointConsumerConfiguration( name, name );%0A%09%09return retrieveConfigForConsumer( endpointConsumers, configuration);%0A%09%7D%0A%09%0A%09public static EndpointConsumerConfiguration retrieveConfigForConsumer(%0A%09%09%09final List%3CEndpointConsumerConfiguration%3E consumerConfigs,%0A%09%09%09final EndpointConsumerConfiguration configuration) %7B%0A%09%09EndpointConsumerConfiguration configForConsumer = %0A%09%09%09%09Filter.first( consumerConfigs, EndpointNamed.with( configuration.getName() ) );%0A%09%09if ( configForConsumer == null )%0A%09%09%09configForConsumer = configuration;%0A%09%09return configForConsumer;%0A%09%7D%0A%7D

create helper class to get endpoint configuration.