1+
12package com .commercetools .sdk ;
23
4+ import java .time .LocalDate ;
5+ import java .time .LocalTime ;
6+ import java .time .ZonedDateTime ;
7+ import java .util .List ;
8+ import java .util .Map ;
9+ import java .util .stream .Collectors ;
10+
311import com .commercetools .api .models .common .LocalizedString ;
412import com .commercetools .api .models .type .CustomFields ;
513import com .commercetools .api .models .type .FieldContainer ;
614import com .commercetools .api .models .type .TypeReference ;
715import com .commercetools .importapi .models .common .*;
816import com .commercetools .importapi .models .customfields .CustomField ;
9- import io .vrap .rmf .base .client .Builder ;
1017
11- import java .time .LocalDate ;
12- import java .time .LocalTime ;
13- import java .time .ZonedDateTime ;
14- import java .util .List ;
15- import java .util .Map ;
16- import java .util .stream .Collectors ;
18+ import io .vrap .rmf .base .client .Builder ;
1719
1820public class CommonImportUtil {
1921
2022 public static LocalizedStringBuilder getLocalizedStringBuilder (LocalizedString s ) {
2123 return com .commercetools .importapi .models .common .LocalizedString .builder ().values (s .values ());
2224 }
2325
24- public static List <Asset > importAssets (
25- List <com .commercetools .api .models .common .Asset > assets ) {
26+ public static List <Asset > importAssets (List <com .commercetools .api .models .common .Asset > assets ) {
2627 if (assets == null ) {
2728 return null ;
2829 }
@@ -38,13 +39,13 @@ public static Builder<? extends TypedMoney> importApiTypedMoney(com.commercetool
3839 TypedMoneyBuilder v ) {
3940 return (p instanceof HighPrecisionMoney )
4041 ? v .highPrecisionBuilder ()
41- .centAmount (p .getCentAmount ())
42- .currencyCode (p .getCurrencyCode ())
43- .preciseAmount (((com .commercetools .api .models .common .HighPrecisionMoney ) p ).getPreciseAmount ())
42+ .centAmount (p .getCentAmount ())
43+ .currencyCode (p .getCurrencyCode ())
44+ .preciseAmount (((com .commercetools .api .models .common .HighPrecisionMoney ) p ).getPreciseAmount ())
4445 : v .centPrecisionBuilder ()
45- .centAmount (p .getCentAmount ())
46- .currencyCode (p .getCurrencyCode ())
47- .fractionDigits (p .getFractionDigits ());
46+ .centAmount (p .getCentAmount ())
47+ .currencyCode (p .getCurrencyCode ())
48+ .fractionDigits (p .getFractionDigits ());
4849 }
4950
5051 public static com .commercetools .importapi .models .customfields .Custom getImportApiCustom (CustomFields customFields ) {
@@ -61,15 +62,12 @@ private static com.commercetools.importapi.models.customfields.FieldContainer ge
6162 .build ();
6263 }
6364
64- static Map <String , CustomField > mapCustomField (
65- Map < String , Object > customFieldsValues ) {
66- if ( customFieldsValues == null ) return null ;
65+ static Map <String , CustomField > mapCustomField (Map < String , Object > customFieldsValues ) {
66+ if ( customFieldsValues == null )
67+ return null ;
6768 return customFieldsValues .entrySet ()
6869 .stream ()
69- .collect (Collectors .toMap (
70- Map .Entry ::getKey ,
71- e -> mapCustomField (e .getValue ())
72- ));
70+ .collect (Collectors .toMap (Map .Entry ::getKey , e -> mapCustomField (e .getValue ())));
7371 }
7472
7573 static CustomField mapCustomField (Object value ) {
@@ -104,16 +102,13 @@ static CustomField mapCustomField(Object value) {
104102 }
105103 if (value instanceof Money ) {
106104 return CustomField .moneyBuilder ()
107- .value (v -> importApiTypedMoney (
108- (com .commercetools .api .models .common .TypedMoney ) value , v ))
105+ .value (v -> importApiTypedMoney ((com .commercetools .api .models .common .TypedMoney ) value , v ))
109106 .build ();
110107 }
111108 throw new IllegalArgumentException ("Unsupported custom field type: " + value .getClass ());
112109 }
113110
114111 private static com .commercetools .importapi .models .common .TypeKeyReference getTypeReference (TypeReference typeRef ) {
115- return TypeKeyReference .builder ()
116- .key (typeRef .getId ())
117- .build ();
112+ return TypeKeyReference .builder ().key (typeRef .getId ()).build ();
118113 }
119114}
0 commit comments