99import com .iab .gpp .encoder .datatype .EncodableFixedInteger ;
1010import com .iab .gpp .encoder .datatype .EncodableFixedIntegerList ;
1111import com .iab .gpp .encoder .error .DecodingException ;
12- import com .iab .gpp .encoder .error .ValidationException ;
1312import com .iab .gpp .encoder .field .EncodableBitStringFields ;
1413import com .iab .gpp .encoder .field .UsCaField ;
1514import com .iab .gpp .encoder .section .UsCa ;
@@ -35,16 +34,16 @@ public List<String> getFieldNames() {
3534
3635 @ Override
3736 protected EncodableBitStringFields initializeFields () {
38- Predicate <Integer > nullableBooleanAsTwoBitIntegerValidator = (n -> n >= 0 && n <= 2 );
39- Predicate <Integer > nonNullableBooleanAsTwoBitIntegerValidator = (n -> n >= 1 && n <= 2 );
40- Predicate <List <Integer >> nullableBooleanAsTwoBitIntegerListValidator = (l -> {
41- for (int n : l ) {
42- if (n < 0 || n > 2 ) {
43- return false ;
44- }
37+ Predicate <Integer > nullableBooleanAsTwoBitIntegerValidator = (n -> n >= 0 && n <= 2 );
38+ Predicate <Integer > nonNullableBooleanAsTwoBitIntegerValidator = (n -> n >= 1 && n <= 2 );
39+ Predicate <List <Integer >> nullableBooleanAsTwoBitIntegerListValidator = (l -> {
40+ for (int n : l ) {
41+ if (n < 0 || n > 2 ) {
42+ return false ;
4543 }
46- return true ;
47- });
44+ }
45+ return true ;
46+ });
4847
4948 EncodableBitStringFields fields = new EncodableBitStringFields ();
5049 fields .put (UsCaField .VERSION , new EncodableFixedInteger (6 , UsCa .VERSION ));
@@ -94,97 +93,4 @@ protected void decodeSegment(String encodedString, EncodableBitStringFields fiel
9493 }
9594 }
9695
97- @ Override
98- public void validate () {
99- Integer sharingOptOutNotice = ((EncodableFixedInteger ) fields .get (UsCaField .SHARING_OPT_OUT_NOTICE )).getValue ();
100- Integer sharingOptOut = ((EncodableFixedInteger ) fields .get (UsCaField .SHARING_OPT_OUT )).getValue ();
101- Integer saleOptOutNotice = ((EncodableFixedInteger ) fields .get (UsCaField .SALE_OPT_OUT_NOTICE )).getValue ();
102- Integer saleOptOut = ((EncodableFixedInteger ) fields .get (UsCaField .SALE_OPT_OUT )).getValue ();
103- Integer mspaServiceProviderMode =
104- ((EncodableFixedInteger ) fields .get (UsCaField .MSPA_SERVICE_PROVIDER_MODE )).getValue ();
105- Integer mspaOptOutOptionMode =
106- ((EncodableFixedInteger ) fields .get (UsCaField .MSPA_OPT_OUT_OPTION_MODE )).getValue ();
107- Integer sensitiveDataLimtUserNotice =
108- ((EncodableFixedInteger ) fields .get (UsCaField .SENSITIVE_DATA_LIMIT_USE_NOTICE )).getValue ();
109-
110- if (sharingOptOutNotice == 0 ) {
111- if (sharingOptOut != 0 ) {
112- throw new ValidationException (
113- "Invalid usca sharing notice / opt out combination: {" + sharingOptOutNotice + " / " + sharingOptOut + "}" );
114- }
115- } else if (sharingOptOutNotice == 1 ) {
116- if (sharingOptOut != 1 && sharingOptOut != 2 ) {
117- throw new ValidationException (
118- "Invalid usca sharing notice / opt out combination: {" + sharingOptOutNotice + " / " + sharingOptOut + "}" );
119- }
120- } else if (sharingOptOutNotice == 2 ) {
121- if (sharingOptOut != 1 ) {
122- throw new ValidationException (
123- "Invalid usca sharing notice / opt out combination: {" + sharingOptOutNotice + " / " + sharingOptOut + "}" );
124- }
125- }
126-
127- if (saleOptOutNotice == 0 ) {
128- if (saleOptOut != 0 ) {
129- throw new ValidationException (
130- "Invalid usca sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}" );
131- }
132- } else if (saleOptOutNotice == 1 ) {
133- if (saleOptOut != 1 && saleOptOut != 2 ) {
134- throw new ValidationException (
135- "Invalid usca sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}" );
136- }
137- } else if (saleOptOutNotice == 2 ) {
138- if (saleOptOut != 1 ) {
139- throw new ValidationException (
140- "Invalid usca sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}" );
141- }
142- }
143-
144- if (mspaServiceProviderMode == 0 ) {
145- if (saleOptOutNotice != 0 ) {
146- throw new ValidationException ("Invalid usca mspa service provider mode / sale opt out notice combination: {"
147- + mspaServiceProviderMode + " / " + saleOptOutNotice + "}" );
148- }
149-
150- if (sharingOptOutNotice != 0 ) {
151- throw new ValidationException ("Invalid usca mspa service provider mode / sharing opt out notice combination: {"
152- + mspaServiceProviderMode + " / " + sharingOptOutNotice + "}" );
153- }
154-
155- if (sensitiveDataLimtUserNotice != 0 ) {
156- throw new ValidationException (
157- "Invalid usca mspa service provider mode / sensitive data limit use notice combination: {"
158- + mspaServiceProviderMode + " / " + sensitiveDataLimtUserNotice + "}" );
159- }
160- } else if (mspaServiceProviderMode == 1 ) {
161- if (mspaOptOutOptionMode != 2 ) {
162- throw new ValidationException ("Invalid usca mspa service provider / opt out option modes combination: {"
163- + mspaServiceProviderMode + " / " + mspaServiceProviderMode + "}" );
164- }
165-
166- if (saleOptOutNotice != 0 ) {
167- throw new ValidationException ("Invalid usca mspa service provider mode / sale opt out notice combination: {"
168- + mspaServiceProviderMode + " / " + saleOptOutNotice + "}" );
169- }
170-
171- if (sharingOptOutNotice != 0 ) {
172- throw new ValidationException ("Invalid usca mspa service provider mode / sharing opt out notice combination: {"
173- + mspaServiceProviderMode + " / " + sharingOptOutNotice + "}" );
174- }
175-
176- if (sensitiveDataLimtUserNotice != 0 ) {
177- throw new ValidationException (
178- "Invalid usca mspa service provider mode / sensitive data limit use notice combination: {"
179- + mspaServiceProviderMode + " / " + sensitiveDataLimtUserNotice + "}" );
180- }
181- } else if (mspaServiceProviderMode == 2 ) {
182- if (mspaOptOutOptionMode != 1 ) {
183- throw new ValidationException ("Invalid usca mspa service provider / opt out option modes combination: {"
184- + mspaServiceProviderMode + " / " + mspaOptOutOptionMode + "}" );
185- }
186- }
187- }
188-
189-
19096}
0 commit comments