Added code sample for autoservice
This commit is contained in:
parent
0d265d24ec
commit
4633c51b17
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.autoservice;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public interface TranslateService {
|
||||||
|
|
||||||
|
String translate(String message, Locale from, Locale to);
|
||||||
|
}
|
Loading…
Reference in New Issue