55
66import java .util .ArrayList ;
77import java .util .Arrays ;
8- import java .util .Collections ;
98import java .util .List ;
109
1110public class UrlStrategy {
@@ -14,6 +13,9 @@ public class UrlStrategy {
1413 private static final String SUBSCRIPTION_URL_WORLD = "https://subscription.adjust.world" ;
1514 private static final String PURCHASE_VERIFICATION_URL_WORLD = "https://ssrv.adjust.world" ;
1615
16+ private final List <String > adjustUrlStrategy ;
17+ private final boolean useSubdomains ;
18+
1719 private final String baseUrlOverwrite ;
1820 private final String gdprUrlOverwrite ;
1921 private final String subscriptionUrlOverwrite ;
@@ -33,17 +35,20 @@ public UrlStrategy(final String baseUrlOverwrite,
3335 final String subscriptionUrlOverwrite ,
3436 final String purchaseVerificationUrlOverwrite ,
3537 final List <String > adjustUrlStrategy ,
36- final Boolean useSubdomains )
38+ final boolean useSubdomains )
3739 {
40+ this .adjustUrlStrategy = adjustUrlStrategy ;
41+ this .useSubdomains = useSubdomains ;
42+
3843 this .baseUrlOverwrite = baseUrlOverwrite ;
3944 this .gdprUrlOverwrite = gdprUrlOverwrite ;
4045 this .subscriptionUrlOverwrite = subscriptionUrlOverwrite ;
4146 this .purchaseVerificationUrlOverwrite = purchaseVerificationUrlOverwrite ;
4247
43- baseUrlChoicesList = baseUrlChoices (adjustUrlStrategy , useSubdomains );
44- gdprUrlChoicesList = gdprUrlChoices (adjustUrlStrategy , useSubdomains );
45- subscriptionUrlChoicesList = subscriptionUrlChoices (adjustUrlStrategy , useSubdomains );
46- purchaseVerificationUrlChoicesList = purchaseVerificationUrlChoices (adjustUrlStrategy , useSubdomains );
48+ baseUrlChoicesList = baseUrlChoices ();
49+ gdprUrlChoicesList = gdprUrlChoices ();
50+ subscriptionUrlChoicesList = subscriptionUrlChoices ();
51+ purchaseVerificationUrlChoicesList = purchaseVerificationUrlChoices ();
4752
4853 wasLastAttemptSuccess = false ;
4954 choiceIndex = 0 ;
@@ -123,77 +128,71 @@ public String targetUrlByActivityKind(final ActivityKind activityKind) {
123128 }
124129 }
125130
126- private static List <String > baseUrlChoices (final List < String > urlStrategy , final Boolean useSubdomains ) {
131+ private List <String > baseUrlChoices () {
127132
128- if (urlStrategy == null || urlStrategy .isEmpty ()) {
133+ if (adjustUrlStrategy == null || adjustUrlStrategy .isEmpty ()) {
129134 return Arrays .asList (Constants .BASE_URL , BASE_URL_WORLD );
130135 }
131- if (useSubdomains != null && useSubdomains ) {
136+ if (useSubdomains ) {
132137 List <String > baseUrls = new ArrayList <>();
133- for (String url : urlStrategy ) {
138+ for (String url : adjustUrlStrategy ) {
134139 baseUrls .add (String .format (Constants .BASE_URL_FORMAT , url ));
135140 }
136141 return baseUrls ;
137142 }else {
138143 List <String > baseUrls = new ArrayList <>();
139- for (String url : urlStrategy ) {
144+ for (String url : adjustUrlStrategy ) {
140145 baseUrls .add (String .format ("https://%s" , url ));
141146 }
142147 return baseUrls ;
143148 }
144149 }
145- private static List <String > gdprUrlChoices (final List < String > urlStrategy , final Boolean useSubdomains ) {
146- if (urlStrategy == null || urlStrategy .isEmpty ()) {
150+ private List <String > gdprUrlChoices () {
151+ if (adjustUrlStrategy == null || adjustUrlStrategy .isEmpty ()) {
147152 return Arrays .asList (Constants .GDPR_URL , GDPR_URL_WORLD );
148153 }
149- if ( useSubdomains != null && useSubdomains ){
150- List < String > baseUrls = new ArrayList <>();
151- for (String url : urlStrategy ) {
154+ List < String > baseUrls = new ArrayList <>();
155+ if ( useSubdomains ) {
156+ for (String url : adjustUrlStrategy ) {
152157 baseUrls .add (String .format (Constants .GDPR_URL_FORMAT , url ));
153158 }
154- return baseUrls ;
155159 }else {
156- List <String > baseUrls = new ArrayList <>();
157- for (String url : urlStrategy ) {
160+ for (String url : adjustUrlStrategy ) {
158161 baseUrls .add (String .format ("https://%s" , url ));
159162 }
160- return baseUrls ;
161163 }
164+ return baseUrls ;
162165 }
163- private static List <String > subscriptionUrlChoices (final List < String > urlStrategy , final Boolean useSubdomains ) {
164- if (urlStrategy == null || urlStrategy .isEmpty ()) {
166+ private List <String > subscriptionUrlChoices () {
167+ if (adjustUrlStrategy == null || adjustUrlStrategy .isEmpty ()) {
165168 return Arrays .asList (Constants .SUBSCRIPTION_URL , SUBSCRIPTION_URL_WORLD );
166169 }
167- if ( useSubdomains != null && useSubdomains ){
168- List < String > baseUrls = new ArrayList <>();
169- for (String url : urlStrategy ) {
170+ List < String > baseUrls = new ArrayList <>();
171+ if ( useSubdomains ) {
172+ for (String url : adjustUrlStrategy ) {
170173 baseUrls .add (String .format (Constants .SUBSCRIPTION_URL_FORMAT , url ));
171174 }
172- return baseUrls ;
173175 }else {
174- List <String > baseUrls = new ArrayList <>();
175- for (String url : urlStrategy ) {
176+ for (String url : adjustUrlStrategy ) {
176177 baseUrls .add (String .format ("https://%s" , url ));
177178 }
178- return baseUrls ;
179179 }
180+ return baseUrls ;
180181 }
181- private static List <String > purchaseVerificationUrlChoices (final List < String > urlStrategy , final Boolean useSubdomains ) {
182- if (urlStrategy == null || urlStrategy .isEmpty ()) {
182+ private List <String > purchaseVerificationUrlChoices () {
183+ if (adjustUrlStrategy == null || adjustUrlStrategy .isEmpty ()) {
183184 return Arrays .asList (Constants .PURCHASE_VERIFICATION_URL , PURCHASE_VERIFICATION_URL_WORLD );
184185 }
185- if ( useSubdomains != null && useSubdomains ){
186- List < String > baseUrls = new ArrayList <>();
187- for (String url : urlStrategy ) {
186+ List < String > baseUrls = new ArrayList <>();
187+ if ( useSubdomains ){
188+ for (String url : adjustUrlStrategy ) {
188189 baseUrls .add (String .format (Constants .PURCHASE_VERIFICATION_URL_FORMAT , url ));
189190 }
190- return baseUrls ;
191191 }else {
192- List <String > baseUrls = new ArrayList <>();
193- for (String url : urlStrategy ) {
192+ for (String url : adjustUrlStrategy ) {
194193 baseUrls .add (String .format ("https://%s" , url ));
195194 }
196- return baseUrls ;
197195 }
196+ return baseUrls ;
198197 }
199198}
0 commit comments