77import com .sap .ai .sdk .orchestration .model .SAPDocumentTranslationOutputTargetLanguage ;
88import javax .annotation .Nonnull ;
99import lombok .AccessLevel ;
10- import lombok .Getter ;
1110import lombok .RequiredArgsConstructor ;
1211import lombok .Value ;
1312import lombok .With ;
2120 * AI Core: Orchestration - SAP Document Translation</a>
2221 * @since 1.14.0
2322 */
24- @ Value
25- @ With
26- @ Getter (AccessLevel .PACKAGE )
27- @ RequiredArgsConstructor (access = AccessLevel .PRIVATE )
28- public class TranslationConfig {
29- SAPDocumentTranslationInput inputConfig ;
30- SAPDocumentTranslationOutput outputConfig ;
31- String sourceLanguage ;
23+ public interface TranslationConfig {
24+ /** Input configuration for translation. */
25+ @ Value
26+ @ With
27+ @ RequiredArgsConstructor (access = AccessLevel .PRIVATE )
28+ class Input implements TranslationConfig {
29+ @ With (AccessLevel .NONE )
30+ String targetLanguage ;
31+
32+ String sourceLanguage ;
33+
34+ @ With (AccessLevel .NONE )
35+ Object ApplyTo ; // Can be null
36+
37+ @ Nonnull
38+ SAPDocumentTranslationInput createSAPDocumentTranslationInput () {
39+ val translationType = SAPDocumentTranslationInput .TypeEnum .SAP_DOCUMENT_TRANSLATION ;
40+ val conf =
41+ SAPDocumentTranslationInputConfig .create ().targetLanguage (targetLanguage ).applyTo (null );
42+ return SAPDocumentTranslationInput .create ().type (translationType ).config (conf );
43+ }
44+ }
45+
46+ /** Output configuration for translation. */
47+ @ Value
48+ @ With
49+ @ RequiredArgsConstructor (access = AccessLevel .PRIVATE )
50+ class Output implements TranslationConfig {
51+ @ With (AccessLevel .NONE )
52+ String targetLanguage ;
53+
54+ String sourceLanguage ;
55+
56+ @ Nonnull
57+ SAPDocumentTranslationOutput createSAPDocumentTranslationOutput () {
58+ val translationType = SAPDocumentTranslationOutput .TypeEnum .SAP_DOCUMENT_TRANSLATION ;
59+ val tLang = SAPDocumentTranslationOutputTargetLanguage .create (targetLanguage );
60+ val conf =
61+ SAPDocumentTranslationOutputConfig .create ()
62+ .targetLanguage (tLang )
63+ .sourceLanguage (sourceLanguage );
64+ return SAPDocumentTranslationOutput .create ().type (translationType ).config (conf );
65+ }
66+ }
3267
3368 /**
3469 * Create a new input translation configuration.
@@ -37,16 +72,9 @@ public class TranslationConfig {
3772 * @return A TranslationConfig configured for input translation
3873 */
3974 @ Nonnull
40- public static TranslationConfig createInput (@ Nonnull final String targetLanguage ) {
41- val translationType = SAPDocumentTranslationInput .TypeEnum .SAP_DOCUMENT_TRANSLATION ;
42- val inputConfig =
43- SAPDocumentTranslationInput .create ()
44- .type (translationType )
45- .config (
46- SAPDocumentTranslationInputConfig .create ()
47- .targetLanguage (targetLanguage )
48- .applyTo (null ));
49- return new TranslationConfig (inputConfig , null , null );
75+ static TranslationConfig .Input createInput (@ Nonnull final String targetLanguage ) {
76+
77+ return new TranslationConfig .Input (targetLanguage , null , null );
5078 }
5179
5280 /**
@@ -56,26 +84,8 @@ public static TranslationConfig createInput(@Nonnull final String targetLanguage
5684 * @return A TranslationConfig configured for output translation
5785 */
5886 @ Nonnull
59- public static TranslationConfig createOutput (@ Nonnull final String targetLanguage ) {
60- val translationType = SAPDocumentTranslationOutput .TypeEnum .SAP_DOCUMENT_TRANSLATION ;
61- val outputConfig =
62- SAPDocumentTranslationOutput .create ()
63- .type (translationType )
64- .config (
65- SAPDocumentTranslationOutputConfig .create ()
66- .targetLanguage (
67- SAPDocumentTranslationOutputTargetLanguage .create (targetLanguage )));
68- return new TranslationConfig (null , outputConfig , null );
69- }
87+ static TranslationConfig .Output createOutput (@ Nonnull final String targetLanguage ) {
7088
71- /**
72- * Set the source language for translation
73- *
74- * @param language The source language code
75- * @return A new TranslationConfig with the specified source language
76- */
77- @ Nonnull
78- public TranslationConfig sourceLanguage (@ Nonnull final String language ) {
79- return this .withSourceLanguage (language );
89+ return new TranslationConfig .Output (targetLanguage , null );
8090 }
8191}
0 commit comments