Added code sample for autoservice

This commit is contained in:
Erhan KARAKAYA 2019-06-05 01:44:57 +03:00
parent 0d265d24ec
commit 4633c51b17
4 changed files with 37 additions and 0 deletions

View File

@ -29,6 +29,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>${auto-service.version}</version>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>com.google.inject</groupId> <groupId>com.google.inject</groupId>
@ -40,6 +46,7 @@
<properties> <properties>
<auto-value.version>1.3</auto-value.version> <auto-value.version>1.3</auto-value.version>
<auto-factory.version>1.0-beta5</auto-factory.version> <auto-factory.version>1.0-beta5</auto-factory.version>
<auto-service.version>1.0-rc5</auto-service.version>
<guice.version>4.2.0</guice.version> <guice.version>4.2.0</guice.version>
</properties> </properties>

View File

@ -0,0 +1,11 @@
package com.baeldung.autoservice;
import java.util.Locale;
@AutoService(TranslateService.class)
public class BingTranslateServiceProvider implements TranslateService {
public String translate(String message, Locale from, Locale to) {
return "translated by Bing";
}
}

View File

@ -0,0 +1,11 @@
package com.baeldung.autoservice;
import java.util.Locale;
@AutoService(TranslateService.class)
public class GoogleTranslateServiceProvider implements TranslateService {
public String translate(String message, Locale from, Locale to) {
return "translated by Google";
}
}

View File

@ -0,0 +1,8 @@
package com.baeldung.autoservice;
import java.util.Locale;
public interface TranslateService {
String translate(String message, Locale from, Locale to);
}