Skip to content

Commit 4c113b6

Browse files
chuffchad
andauthored
Remove multistate version (#60)
* lazy decoding * java 8 compatible gppmodel tests * rename missed multistate usp* methods to us* * lazier decoding * lazier decoding * tests for null and empty string constructor arguments * validation * fix typo * remove redundant validate call * default validate * remove empty validate method from header core segment * fix usct validator * 3.1.1 * 3.1.2-SNAPSHOT * tcfca publisher restrictions and disclosed vendors * deprecate multi-state usp* methods * substring error handling * remove deprecated usp methods * remove deprecated usp methods * remove deprecated usp methods * cleanup validators * Better decoding exception messaging * remove unused classes * Update README * add support for the old headerless tcfeuv2 strings * encodeSection fix * encodeSection lazy fix * tcfeu pub restrictions fix * pub restrictions getters * tcfeu pub restirctions fix * cleanup * pub restrictions fix * optimize bitstring padding * 3.2.0 * 3.2.1-SNAPSHOT * fl mt or tx * remove version from multistate resources --------- Co-authored-by: chad <[email protected]>
1 parent fcd6061 commit 4c113b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+6728
-3380
lines changed

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/GppModel.java

Lines changed: 128 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
import com.iab.gpp.encoder.section.Sections;
1616
import com.iab.gpp.encoder.section.TcfCaV1;
1717
import com.iab.gpp.encoder.section.TcfEuV2;
18-
import com.iab.gpp.encoder.section.UsCaV1;
19-
import com.iab.gpp.encoder.section.UsCoV1;
20-
import com.iab.gpp.encoder.section.UsCtV1;
21-
import com.iab.gpp.encoder.section.UsNatV1;
22-
import com.iab.gpp.encoder.section.UsUtV1;
23-
import com.iab.gpp.encoder.section.UsVaV1;
18+
import com.iab.gpp.encoder.section.UsCa;
19+
import com.iab.gpp.encoder.section.UsCo;
20+
import com.iab.gpp.encoder.section.UsCt;
21+
import com.iab.gpp.encoder.section.UsFl;
22+
import com.iab.gpp.encoder.section.UsMt;
23+
import com.iab.gpp.encoder.section.UsNat;
24+
import com.iab.gpp.encoder.section.UsOr;
25+
import com.iab.gpp.encoder.section.UsTx;
26+
import com.iab.gpp.encoder.section.UsUt;
27+
import com.iab.gpp.encoder.section.UsVa;
2428
import com.iab.gpp.encoder.section.UspV1;
2529

2630
public class GppModel {
@@ -61,24 +65,36 @@ public void setFieldValue(String sectionName, String fieldName, Object value) {
6165
} else if (sectionName.equals(UspV1.NAME)) {
6266
section = new UspV1();
6367
this.sections.put(UspV1.NAME, section);
64-
} else if (sectionName.equals(UsNatV1.NAME)) {
65-
section = new UsNatV1();
66-
this.sections.put(UsNatV1.NAME, section);
67-
} else if (sectionName.equals(UsCaV1.NAME)) {
68-
section = new UsCaV1();
69-
this.sections.put(UsCaV1.NAME, section);
70-
} else if (sectionName.equals(UsVaV1.NAME)) {
71-
section = new UsVaV1();
72-
this.sections.put(UsVaV1.NAME, section);
73-
} else if (sectionName.equals(UsCoV1.NAME)) {
74-
section = new UsCoV1();
75-
this.sections.put(UsCoV1.NAME, section);
76-
} else if (sectionName.equals(UsUtV1.NAME)) {
77-
section = new UsUtV1();
78-
this.sections.put(UsUtV1.NAME, section);
79-
} else if (sectionName.equals(UsCtV1.NAME)) {
80-
section = new UsCtV1();
81-
this.sections.put(UsCtV1.NAME, section);
68+
} else if (sectionName.equals(UsNat.NAME)) {
69+
section = new UsNat();
70+
this.sections.put(UsNat.NAME, section);
71+
} else if (sectionName.equals(UsCa.NAME)) {
72+
section = new UsCa();
73+
this.sections.put(UsCa.NAME, section);
74+
} else if (sectionName.equals(UsVa.NAME)) {
75+
section = new UsVa();
76+
this.sections.put(UsVa.NAME, section);
77+
} else if (sectionName.equals(UsCo.NAME)) {
78+
section = new UsCo();
79+
this.sections.put(UsCo.NAME, section);
80+
} else if (sectionName.equals(UsUt.NAME)) {
81+
section = new UsUt();
82+
this.sections.put(UsUt.NAME, section);
83+
} else if (sectionName.equals(UsCt.NAME)) {
84+
section = new UsCt();
85+
this.sections.put(UsCt.NAME, section);
86+
} else if (sectionName.equals(UsFl.NAME)) {
87+
section = new UsFl();
88+
this.sections.put(UsFl.NAME, section);
89+
} else if (sectionName.equals(UsMt.NAME)) {
90+
section = new UsMt();
91+
this.sections.put(UsMt.NAME, section);
92+
} else if (sectionName.equals(UsOr.NAME)) {
93+
section = new UsOr();
94+
this.sections.put(UsOr.NAME, section);
95+
} else if (sectionName.equals(UsTx.NAME)) {
96+
section = new UsTx();
97+
this.sections.put(UsTx.NAME, section);
8298
}
8399
} else {
84100
section = this.sections.get(sectionName);
@@ -212,28 +228,44 @@ public UspV1 getUspV1Section() {
212228
return (UspV1) getSection(UspV1.NAME);
213229
}
214230

215-
public UsNatV1 getUsNatV1Section() {
216-
return (UsNatV1) getSection(UsNatV1.NAME);
231+
public UsNat getUsNatSection() {
232+
return (UsNat) getSection(UsNat.NAME);
217233
}
218234

219-
public UsCaV1 getUsCaV1Section() {
220-
return (UsCaV1) getSection(UsCaV1.NAME);
235+
public UsCa getUsCaSection() {
236+
return (UsCa) getSection(UsCa.NAME);
221237
}
222238

223-
public UsVaV1 getUsVaV1Section() {
224-
return (UsVaV1) getSection(UsVaV1.NAME);
239+
public UsVa getUsVaSection() {
240+
return (UsVa) getSection(UsVa.NAME);
225241
}
226242

227-
public UsCoV1 getUsCoV1Section() {
228-
return (UsCoV1) getSection(UsCoV1.NAME);
243+
public UsCo getUsCoSection() {
244+
return (UsCo) getSection(UsCo.NAME);
229245
}
230246

231-
public UsUtV1 getUsUtV1Section() {
232-
return (UsUtV1) getSection(UsUtV1.NAME);
247+
public UsUt getUsUtSection() {
248+
return (UsUt) getSection(UsUt.NAME);
233249
}
234250

235-
public UsCtV1 getUsCtV1Section() {
236-
return (UsCtV1) getSection(UsCtV1.NAME);
251+
public UsCt getUsCtSection() {
252+
return (UsCt) getSection(UsCt.NAME);
253+
}
254+
255+
public UsFl getUsFlSection() {
256+
return (UsFl) getSection(UsFl.NAME);
257+
}
258+
259+
public UsMt getUsMtSection() {
260+
return (UsMt) getSection(UsMt.NAME);
261+
}
262+
263+
public UsOr getUsOrSection() {
264+
return (UsOr) getSection(UsOr.NAME);
265+
}
266+
267+
public UsTx getUsTxSection() {
268+
return (UsTx) getSection(UsTx.NAME);
237269
}
238270

239271
public List<Integer> getSectionIds() {
@@ -299,24 +331,36 @@ protected Map<String, EncodableSection> decodeModel(String str) {
299331
} else if (sectionIds.get(i).equals(UspV1.ID)) {
300332
UspV1 section = new UspV1(encodedSections[i + 1]);
301333
sections.put(UspV1.NAME, section);
302-
} else if (sectionIds.get(i).equals(UsCaV1.ID)) {
303-
UsCaV1 section = new UsCaV1(encodedSections[i + 1]);
304-
sections.put(UsCaV1.NAME, section);
305-
} else if (sectionIds.get(i).equals(UsNatV1.ID)) {
306-
UsNatV1 section = new UsNatV1(encodedSections[i + 1]);
307-
sections.put(UsNatV1.NAME, section);
308-
} else if (sectionIds.get(i).equals(UsVaV1.ID)) {
309-
UsVaV1 section = new UsVaV1(encodedSections[i + 1]);
310-
sections.put(UsVaV1.NAME, section);
311-
} else if (sectionIds.get(i).equals(UsCoV1.ID)) {
312-
UsCoV1 section = new UsCoV1(encodedSections[i + 1]);
313-
sections.put(UsCoV1.NAME, section);
314-
} else if (sectionIds.get(i).equals(UsUtV1.ID)) {
315-
UsUtV1 section = new UsUtV1(encodedSections[i + 1]);
316-
sections.put(UsUtV1.NAME, section);
317-
} else if (sectionIds.get(i).equals(UsCtV1.ID)) {
318-
UsCtV1 section = new UsCtV1(encodedSections[i + 1]);
319-
sections.put(UsCtV1.NAME, section);
334+
} else if (sectionIds.get(i).equals(UsCa.ID)) {
335+
UsCa section = new UsCa(encodedSections[i + 1]);
336+
sections.put(UsCa.NAME, section);
337+
} else if (sectionIds.get(i).equals(UsNat.ID)) {
338+
UsNat section = new UsNat(encodedSections[i + 1]);
339+
sections.put(UsNat.NAME, section);
340+
} else if (sectionIds.get(i).equals(UsVa.ID)) {
341+
UsVa section = new UsVa(encodedSections[i + 1]);
342+
sections.put(UsVa.NAME, section);
343+
} else if (sectionIds.get(i).equals(UsCo.ID)) {
344+
UsCo section = new UsCo(encodedSections[i + 1]);
345+
sections.put(UsCo.NAME, section);
346+
} else if (sectionIds.get(i).equals(UsUt.ID)) {
347+
UsUt section = new UsUt(encodedSections[i + 1]);
348+
sections.put(UsUt.NAME, section);
349+
} else if (sectionIds.get(i).equals(UsCt.ID)) {
350+
UsCt section = new UsCt(encodedSections[i + 1]);
351+
sections.put(UsCt.NAME, section);
352+
} else if (sectionIds.get(i).equals(UsFl.ID)) {
353+
UsFl section = new UsFl(encodedSections[i + 1]);
354+
sections.put(UsFl.NAME, section);
355+
} else if (sectionIds.get(i).equals(UsMt.ID)) {
356+
UsMt section = new UsMt(encodedSections[i + 1]);
357+
sections.put(UsMt.NAME, section);
358+
} else if (sectionIds.get(i).equals(UsOr.ID)) {
359+
UsOr section = new UsOr(encodedSections[i + 1]);
360+
sections.put(UsOr.NAME, section);
361+
} else if (sectionIds.get(i).equals(UsTx.ID)) {
362+
UsTx section = new UsTx(encodedSections[i + 1]);
363+
sections.put(UsTx.NAME, section);
320364
}
321365
}
322366
}
@@ -373,24 +417,36 @@ public void decodeSection(String sectionName, String encodedString) {
373417
} else if (sectionName.equals(UspV1.NAME)) {
374418
section = new UspV1();
375419
this.sections.put(UspV1.NAME, section);
376-
} else if (sectionName.equals(UsNatV1.NAME)) {
377-
section = new UsNatV1();
378-
this.sections.put(UsNatV1.NAME, section);
379-
} else if (sectionName.equals(UsCaV1.NAME)) {
380-
section = new UsCaV1();
381-
this.sections.put(UsCaV1.NAME, section);
382-
} else if (sectionName.equals(UsVaV1.NAME)) {
383-
section = new UsVaV1();
384-
this.sections.put(UsVaV1.NAME, section);
385-
} else if (sectionName.equals(UsCoV1.NAME)) {
386-
section = new UsCoV1();
387-
this.sections.put(UsCoV1.NAME, section);
388-
} else if (sectionName.equals(UsUtV1.NAME)) {
389-
section = new UsUtV1();
390-
this.sections.put(UsUtV1.NAME, section);
391-
} else if (sectionName.equals(UsCtV1.NAME)) {
392-
section = new UsCtV1();
393-
this.sections.put(UsCtV1.NAME, section);
420+
} else if (sectionName.equals(UsNat.NAME)) {
421+
section = new UsNat();
422+
this.sections.put(UsNat.NAME, section);
423+
} else if (sectionName.equals(UsCa.NAME)) {
424+
section = new UsCa();
425+
this.sections.put(UsCa.NAME, section);
426+
} else if (sectionName.equals(UsVa.NAME)) {
427+
section = new UsVa();
428+
this.sections.put(UsVa.NAME, section);
429+
} else if (sectionName.equals(UsCo.NAME)) {
430+
section = new UsCo();
431+
this.sections.put(UsCo.NAME, section);
432+
} else if (sectionName.equals(UsUt.NAME)) {
433+
section = new UsUt();
434+
this.sections.put(UsUt.NAME, section);
435+
} else if (sectionName.equals(UsCt.NAME)) {
436+
section = new UsCt();
437+
this.sections.put(UsCt.NAME, section);
438+
} else if (sectionName.equals(UsFl.NAME)) {
439+
section = new UsFl();
440+
this.sections.put(UsFl.NAME, section);
441+
} else if (sectionName.equals(UsMt.NAME)) {
442+
section = new UsMt();
443+
this.sections.put(UsMt.NAME, section);
444+
} else if (sectionName.equals(UsOr.NAME)) {
445+
section = new UsOr();
446+
this.sections.put(UsOr.NAME, section);
447+
} else if (sectionName.equals(UsTx.NAME)) {
448+
section = new UsTx();
449+
this.sections.put(UsTx.NAME, section);
394450
}
395451
} else {
396452
section = this.sections.get(sectionName);

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCaV1Field.java renamed to iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCaField.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6-
public class UsCaV1Field {
6+
public class UsCaField {
77

88
public static String VERSION = "Version";
99
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
@@ -23,26 +23,26 @@ public class UsCaV1Field {
2323
public static String GPC = "Gpc";
2424

2525
//@formatter:off
26-
public static List<String> USCAV1_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27-
UsCaV1Field.VERSION,
28-
UsCaV1Field.SALE_OPT_OUT_NOTICE,
29-
UsCaV1Field.SHARING_OPT_OUT_NOTICE,
30-
UsCaV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE,
31-
UsCaV1Field.SALE_OPT_OUT,
32-
UsCaV1Field.SHARING_OPT_OUT,
33-
UsCaV1Field.SENSITIVE_DATA_PROCESSING,
34-
UsCaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35-
UsCaV1Field.PERSONAL_DATA_CONSENTS,
36-
UsCaV1Field.MSPA_COVERED_TRANSACTION,
37-
UsCaV1Field.MSPA_OPT_OUT_OPTION_MODE,
38-
UsCaV1Field.MSPA_SERVICE_PROVIDER_MODE
26+
public static List<String> USCA_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27+
UsCaField.VERSION,
28+
UsCaField.SALE_OPT_OUT_NOTICE,
29+
UsCaField.SHARING_OPT_OUT_NOTICE,
30+
UsCaField.SENSITIVE_DATA_LIMIT_USE_NOTICE,
31+
UsCaField.SALE_OPT_OUT,
32+
UsCaField.SHARING_OPT_OUT,
33+
UsCaField.SENSITIVE_DATA_PROCESSING,
34+
UsCaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35+
UsCaField.PERSONAL_DATA_CONSENTS,
36+
UsCaField.MSPA_COVERED_TRANSACTION,
37+
UsCaField.MSPA_OPT_OUT_OPTION_MODE,
38+
UsCaField.MSPA_SERVICE_PROVIDER_MODE
3939
});
4040
//@formatter:on
4141

4242
//@formatter:off
43-
public static List<String> USCAV1_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44-
UsCaV1Field.GPC_SEGMENT_TYPE,
45-
UsCaV1Field.GPC
43+
public static List<String> USCA_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44+
UsCaField.GPC_SEGMENT_TYPE,
45+
UsCaField.GPC
4646
});
4747
//@formatter:on
4848
}

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCoV1Field.java renamed to iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCoField.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6-
public class UsCoV1Field {
6+
public class UsCoField {
77

88
public static String VERSION = "Version";
99
public static String SHARING_NOTICE = "SharingNotice";
@@ -22,25 +22,25 @@ public class UsCoV1Field {
2222
public static String GPC = "Gpc";
2323

2424
//@formatter:off
25-
public static List<String> USCOV1_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
26-
UsCoV1Field.VERSION,
27-
UsCoV1Field.SHARING_NOTICE,
28-
UsCoV1Field.SALE_OPT_OUT_NOTICE,
29-
UsCoV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
30-
UsCoV1Field.SALE_OPT_OUT,
31-
UsCoV1Field.TARGETED_ADVERTISING_OPT_OUT,
32-
UsCoV1Field.SENSITIVE_DATA_PROCESSING,
33-
UsCoV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
34-
UsCoV1Field.MSPA_COVERED_TRANSACTION,
35-
UsCoV1Field.MSPA_OPT_OUT_OPTION_MODE,
36-
UsCoV1Field.MSPA_SERVICE_PROVIDER_MODE
25+
public static List<String> USCO_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
26+
UsCoField.VERSION,
27+
UsCoField.SHARING_NOTICE,
28+
UsCoField.SALE_OPT_OUT_NOTICE,
29+
UsCoField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
30+
UsCoField.SALE_OPT_OUT,
31+
UsCoField.TARGETED_ADVERTISING_OPT_OUT,
32+
UsCoField.SENSITIVE_DATA_PROCESSING,
33+
UsCoField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
34+
UsCoField.MSPA_COVERED_TRANSACTION,
35+
UsCoField.MSPA_OPT_OUT_OPTION_MODE,
36+
UsCoField.MSPA_SERVICE_PROVIDER_MODE
3737
});
3838
//@formatter:on
3939

4040
//@formatter:off
41-
public static List<String> USCOV1_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
42-
UsCoV1Field.GPC_SEGMENT_TYPE,
43-
UsCoV1Field.GPC
41+
public static List<String> USCO_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
42+
UsCoField.GPC_SEGMENT_TYPE,
43+
UsCoField.GPC
4444
});
4545
//@formatter:on
4646
}

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCtV1Field.java renamed to iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCtField.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6-
public class UsCtV1Field {
6+
public class UsCtField {
77

88
public static String VERSION = "Version";
99
public static String SHARING_NOTICE = "SharingNotice";
@@ -22,25 +22,25 @@ public class UsCtV1Field {
2222
public static String GPC = "Gpc";
2323

2424
//@formatter:off
25-
public static List<String> USCTV1_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
26-
UsCtV1Field.VERSION,
27-
UsCtV1Field.SHARING_NOTICE,
28-
UsCtV1Field.SALE_OPT_OUT_NOTICE,
29-
UsCtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
30-
UsCtV1Field.SALE_OPT_OUT,
31-
UsCtV1Field.TARGETED_ADVERTISING_OPT_OUT,
32-
UsCtV1Field.SENSITIVE_DATA_PROCESSING,
33-
UsCtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
34-
UsCtV1Field.MSPA_COVERED_TRANSACTION,
35-
UsCtV1Field.MSPA_OPT_OUT_OPTION_MODE,
36-
UsCtV1Field.MSPA_SERVICE_PROVIDER_MODE
25+
public static List<String> USCT_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
26+
UsCtField.VERSION,
27+
UsCtField.SHARING_NOTICE,
28+
UsCtField.SALE_OPT_OUT_NOTICE,
29+
UsCtField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
30+
UsCtField.SALE_OPT_OUT,
31+
UsCtField.TARGETED_ADVERTISING_OPT_OUT,
32+
UsCtField.SENSITIVE_DATA_PROCESSING,
33+
UsCtField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
34+
UsCtField.MSPA_COVERED_TRANSACTION,
35+
UsCtField.MSPA_OPT_OUT_OPTION_MODE,
36+
UsCtField.MSPA_SERVICE_PROVIDER_MODE
3737
});
3838
//@formatter:on
3939

4040
//@formatter:off
41-
public static List<String> USCTV1_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
42-
UsCtV1Field.GPC_SEGMENT_TYPE,
43-
UsCtV1Field.GPC
41+
public static List<String> USCT_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
42+
UsCtField.GPC_SEGMENT_TYPE,
43+
UsCtField.GPC
4444
});
4545
//@formatter:on
4646
}

0 commit comments

Comments
 (0)