diff --git a/ReadMe.md b/ReadMe.md index f674fd1b..eb844a10 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -30,7 +30,7 @@ Get the library from Maven Central. Gradle: ``` -api 'org.magicwerk.brownies:brownies-collections:0.9.20' +api 'org.magicwerk.brownies:brownies-collections:0.9.21' ``` Maven: @@ -39,6 +39,6 @@ Maven: org.magicwerk.brownies brownies-collections - 0.9.20 + 0.9.21 ``` diff --git a/build.gradle b/build.gradle index cb8741bf..56995dc9 100644 --- a/build.gradle +++ b/build.gradle @@ -8,34 +8,33 @@ repositories { } dependencies { - testImplementation "org.magicwerk.brownies:brownies-collections:0.9.19" - testImplementation "org.magicwerk.brownies:brownies-core:0.9.9" - testImplementation "org.magicwerk.brownies:brownies-javassist:0.9.9" - testImplementation "org.magicwerk.brownies:brownies-jdom:0.9.9" - testImplementation "org.magicwerk.brownies:brownies-html:0.9.9" - testImplementation "org.magicwerk.brownies:brownies-test:0.9.9" - testImplementation "org.magicwerk.brownies:brownies-tools:0.9.9" - testImplementation "org.magicwerk.magictest:magictest:0.9.9" - testImplementation "org.magicwerk.magictest:magictest-ng:0.9.9" + testImplementation "org.magicwerk.brownies:brownies-core:0.9.11" + testImplementation "org.magicwerk.brownies:brownies-javassist:0.9.11" + testImplementation "org.magicwerk.brownies:brownies-jdom:0.9.11" + testImplementation "org.magicwerk.brownies:brownies-html:0.9.11" + testImplementation "org.magicwerk.brownies:brownies-test:0.9.11" + testImplementation "org.magicwerk.brownies:brownies-tools:0.9.11" + testImplementation "org.magicwerk.magictest:magictest:0.9.11" + testImplementation "org.magicwerk.magictest:magictest-ng:0.9.11" - testImplementation "junit:junit:4.8.2" + testImplementation "junit:junit:4.13.2" testImplementation "com.google.guava:guava-testlib:31.1-jre" - testImplementation "com.github.javaparser:javaparser-core:3.24.0" + testImplementation "com.github.javaparser:javaparser-core:3.25.1" testImplementation 'org.apache.commons:commons-collections4:4.0' testImplementation 'org.javolution:javolution-core-java:6.0.0' testImplementation 'it.unimi.dsi:fastutil:7.0.9' - testImplementation 'org.slf4j:slf4j-api:1.7.4' - testImplementation 'ch.qos.logback:logback-classic:1.0.11' - testImplementation 'ch.qos.logback:logback-core:1.0.11' + testImplementation 'org.slf4j:slf4j-api:1.7.36' + testImplementation 'ch.qos.logback:logback-classic:1.2.11' + testImplementation 'ch.qos.logback:logback-core:1.2.11' testImplementation 'org.apache.commons:commons-lang3:3.12.0' testImplementation 'de.schlichtherle.truezip:truezip-file:7.7.10' testImplementation 'de.schlichtherle.truezip:truezip-path:7.7.10' testImplementation 'de.schlichtherle.truezip:truezip-driver-zip:7.7.10' - testImplementation 'org.javassist:javassist:3.28.0-GA' - testImplementation 'org.jdom:jdom2:2.0.6' - testImplementation 'org.openjdk.jmh:jmh-core:1.33' + testImplementation 'org.javassist:javassist:3.29.2-GA' + testImplementation 'org.jdom:jdom2:2.0.6.1' + testImplementation 'org.openjdk.jmh:jmh-core:1.36' } diff --git a/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.html b/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.html index e1a22ce7..76d394a1 100644 --- a/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.html +++ b/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.html @@ -1,2 +1,2 @@ -Test-Report of Key2ListTest (Package org.magicwerk.brownies.collections)

Test-Report of Key2ListTest (Package org.magicwerk.brownies.collections)

TestRun atDurationStatus
testAsMap20.08.2022 01:23:390.029s
testCloneCopyCrop14.10.2022 14:20:290.024s
testExtends07.12.2017 00:45:140.029s
testInvalidate18.08.2015 01:56:070.076s
testKey2List18.08.2015 01:56:070.022s

Top Next (testCloneCopyCrop) Method testAsMap

Run at: 20.08.2022 01:23:39, Duration: 0.029s

StepOutputStatus
1

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=2, extId=extId2, text=text2], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[1, 2, 3, 4]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[MapEntry [key=1, value=Ticket [id=1, extId=extId1, text=text1]], MapEntry [key=2, value=Ticket [id=2, extId=extId2, text=text2]], MapEntry [key=3, value=Ticket [id=3, extId=extId3, text=text3]], MapEntry [key=4, value=Ticket [id=4, extId=extId4, text=text4]]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=2, extId=extId2, text=text2], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[extId4, extId2, extId3, extId1]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[MapEntry [key=extId4, value=Ticket [id=4, extId=extId4, text=text4]], MapEntry [key=extId2, value=Ticket [id=2, extId=extId2, text=text2]], MapEntry [key=extId3, value=Ticket [id=3, extId=extId3, text=text3]], MapEntry [key=extId1, value=Ticket [id=1, extId=extId1, text=text1]]]

OK

Top Prev (testAsMap) Next (testExtends) Method testCloneCopyCrop

Run at: 14.10.2022 14:20:29, Duration: 0.024s

StepOutputStatus
1

Orig: [1, 2, 3, 4]

-

Clone: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Clone (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Clone (changed): [1, 2, 3, 4, 5]

-

Copy: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Copy (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Copy (changed): [1, 2, 3, 4, 5]

-

Crop: []

Orig (changed): [1, 2, 3, 4, 5]

Crop (unchanged): []

Orig (unchanged): [1, 2, 3, 4]

Crop (changed): [5]

Orig: [1, 2, 3, 4]

-

Clone: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Clone (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Clone (changed): [1, 2, 3, 4, 5]

-

Copy: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Copy (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Copy (changed): [1, 2, 3, 4, 5]

-

Crop: []

Orig (changed): [1, 2, 3, 4, 5]

Crop (unchanged): []

Orig (unchanged): [1, 2, 3, 4]

Crop (changed): [5]

OK

Top Prev (testCloneCopyCrop) Next (testInvalidate) Method testExtends

Trace class: org.magicwerk.brownies.collections.Key2ListTest$TicketList

Trace method: /.*/

Run at: 07.12.2017 00:45:14, Duration: 0.029s

StepDescriptionParametersResultErrorStatus
1

Key2ListTest$TicketList

{ }OK
2

add

This: { }
Params: Ticket [id=1, extId=extId1, text=text1]
This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: true
OK
3

clone

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result:

{

   Ticket [id=1, extId=extId1, text=text1]

}

OK
4

copy

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result:

{

   Ticket [id=1, extId=extId1, text=text1]

}

OK
5

crop

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: { }
OK

Top Prev (testExtends) Next (testKey2List) Method testInvalidate

Trace class: org.magicwerk.brownies.collections.Key2List

Trace method: /.*/

Run at: 18.08.2015 01:56:07, Duration: 0.076s

StepDescriptionParametersResultErrorStatus
1

add

This: { }
Params: Ticket [id=1, extId=extId1, text=text1]
This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: true
OK
2

add

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Params: Ticket [id=3, extId=extId3x, text=text3]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Result: true
OK
3

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Params: Ticket [id=2, extId=extId2, text=text2]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2]

}

Result: true
OK
4

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2]

}

Params: Ticket [id=4, extId=extId3x, text=text4]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: true
OK
5

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
6

invalidate

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: Ticket [id=11, extId=extId1, text=text1]
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
7

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=11, extId=extId1, text=text1]
OK
8

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 22
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
9

invalidateKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 2, 22, null
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
10

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 22
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=22, extId=extId2, text=text2]
OK
11

getByKey2

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: "extId3a"
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
12

invalidateKey2

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: "extId3x", "extId3a", Ticket [id=3, extId=extId3a, text=text3]
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
13

getByKey2

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: "extId3a"
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=3, extId=extId3a, text=text3]
OK
14

add

This: { }
Params: Ticket [id=1, extId=extId1, text=text1]
This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: true
OK
15

add

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Params: Ticket [id=3, extId=extId3x, text=text3]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Result: true
OK
16

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Params: Ticket [id=2, extId=extId2, text=text2]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3]

}

Result: true
OK
17

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3]

}

Params: Ticket [id=4, extId=extId3x, text=text4]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: true
OK
18

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
19

invalidate

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: Ticket [id=11, extId=extId1, text=text1]
This:

{

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
20

getByKey1

This:

{

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=4, extId=extId3x, text=text4]
OK
21

getByKey1

This:

{

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 22
This:

{

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
22

invalidateKey1

This:

{

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 2, 22, null
This:

{

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

OK
23

getByKey1

This:

{

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: 22
This:

{

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Result: Ticket [id=22, extId=extId2, text=text2]
OK
24

getByKey2

This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: "extId3a"
This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Result: null
OK
25

invalidateKey2

This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: "extId3x", "extId3a", Ticket [id=3, extId=extId3a, text=text3]
This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

OK
26

getByKey2

This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: "extId3a"
This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Result: Ticket [id=3, extId=extId3a, text=text3]
OK

Top Prev (testInvalidate) Method testKey2List

Trace class: org.magicwerk.brownies.collections.Key2List

Trace method: /.+/

Run at: 18.08.2015 01:56:07, Duration: 0.022s

StepDescriptionParametersResultErrorStatus
1

add

This: { }
Params: Ticket [id=1, extId=ExtId1, text=Ticket1]
trueOK
2

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1]

}

Params: Ticket [id=2, extId=null, text=Ticket2]
trueOK
3

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2]

}

Params: Ticket [id=3, extId=ExtId3, text=Ticket3]
trueOK
4

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3]

}

Params: Ticket [id=4, extId=null, text=Ticket4]
trueOK
5

getByKey1

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: 1
Ticket [id=1, extId=ExtId1, text=Ticket1]OK
6

getByKey2

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: "ExtId3"
Ticket [id=3, extId=ExtId3, text=Ticket3]OK
7

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=1, extId=ExtId, text=ERROR]
org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: 1OK
8

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=5, extId=ExtId3, text=ERROR]
org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: ExtId3OK
9

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=null, extId=ExtId, text=ERROR]
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: null key not allowedOK
10

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: null
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: null element not allowedOK
11

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=6, extId=EXT, text=ERROR]
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: element not allowedOK
12

removeByKey1

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: 1
Ticket [id=1, extId=ExtId1, text=Ticket1]OK
+Test-Report of Key2ListTest (Package org.magicwerk.brownies.collections)

Test-Report of Key2ListTest (Package org.magicwerk.brownies.collections)

TestRun atDurationStatus
testAsMap20.08.2022 01:23:390.029s
testCloneCopyCrop14.10.2022 14:20:290.024s
testExtends07.12.2017 00:45:140.029s
testInvalidate18.08.2015 01:56:070.076s
testKey2List18.08.2015 01:56:070.022s
testRemoveAllByKey126.05.2023 14:11:170.007s

Top Next (testCloneCopyCrop) Method testAsMap

Run at: 20.08.2022 01:23:39, Duration: 0.029s

StepOutputStatus
1

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=2, extId=extId2, text=text2], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[1, 2, 3, 4]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[MapEntry [key=1, value=Ticket [id=1, extId=extId1, text=text1]], MapEntry [key=2, value=Ticket [id=2, extId=extId2, text=text2]], MapEntry [key=3, value=Ticket [id=3, extId=extId3, text=text3]], MapEntry [key=4, value=Ticket [id=4, extId=extId4, text=text4]]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=2, extId=extId2, text=text2], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[extId4, extId2, extId3, extId1]

[Ticket [id=1, extId=extId1, text=text1], Ticket [id=3, extId=extId3, text=text3], Ticket [id=4, extId=extId4, text=text4], Ticket [id=2, extId=extId2, text=text2]]

[MapEntry [key=extId4, value=Ticket [id=4, extId=extId4, text=text4]], MapEntry [key=extId2, value=Ticket [id=2, extId=extId2, text=text2]], MapEntry [key=extId3, value=Ticket [id=3, extId=extId3, text=text3]], MapEntry [key=extId1, value=Ticket [id=1, extId=extId1, text=text1]]]

OK

Top Prev (testAsMap) Next (testExtends) Method testCloneCopyCrop

Run at: 14.10.2022 14:20:29, Duration: 0.024s

StepOutputStatus
1

Orig: [1, 2, 3, 4]

-

Clone: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Clone (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Clone (changed): [1, 2, 3, 4, 5]

-

Copy: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Copy (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Copy (changed): [1, 2, 3, 4, 5]

-

Crop: []

Orig (changed): [1, 2, 3, 4, 5]

Crop (unchanged): []

Orig (unchanged): [1, 2, 3, 4]

Crop (changed): [5]

Orig: [1, 2, 3, 4]

-

Clone: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Clone (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Clone (changed): [1, 2, 3, 4, 5]

-

Copy: [1, 2, 3, 4]

Orig (changed): [1, 2, 3, 4, 5]

Copy (unchanged): [1, 2, 3, 4]

Orig (unchanged): [1, 2, 3, 4]

Copy (changed): [1, 2, 3, 4, 5]

-

Crop: []

Orig (changed): [1, 2, 3, 4, 5]

Crop (unchanged): []

Orig (unchanged): [1, 2, 3, 4]

Crop (changed): [5]

OK

Top Prev (testCloneCopyCrop) Next (testInvalidate) Method testExtends

Trace class: org.magicwerk.brownies.collections.Key2ListTest$TicketList

Trace method: /.*/

Run at: 07.12.2017 00:45:14, Duration: 0.029s

StepDescriptionParametersResultErrorStatus
1

Key2ListTest$TicketList

{ }OK
2

add

This: { }
Params: Ticket [id=1, extId=extId1, text=text1]
This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: true
OK
3

clone

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result:

{

   Ticket [id=1, extId=extId1, text=text1]

}

OK
4

copy

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result:

{

   Ticket [id=1, extId=extId1, text=text1]

}

OK
5

crop

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: { }
OK

Top Prev (testExtends) Next (testKey2List) Method testInvalidate

Trace class: org.magicwerk.brownies.collections.Key2List

Trace method: /.*/

Run at: 18.08.2015 01:56:07, Duration: 0.076s

StepDescriptionParametersResultErrorStatus
1

add

This: { }
Params: Ticket [id=1, extId=extId1, text=text1]
This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: true
OK
2

add

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Params: Ticket [id=3, extId=extId3x, text=text3]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Result: true
OK
3

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Params: Ticket [id=2, extId=extId2, text=text2]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2]

}

Result: true
OK
4

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2]

}

Params: Ticket [id=4, extId=extId3x, text=text4]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: true
OK
5

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
6

invalidate

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: Ticket [id=11, extId=extId1, text=text1]
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
7

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=11, extId=extId1, text=text1]
OK
8

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 22
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
9

invalidateKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 2, 22, null
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
10

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 22
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=22, extId=extId2, text=text2]
OK
11

getByKey2

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: "extId3a"
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
12

invalidateKey2

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: "extId3x", "extId3a", Ticket [id=3, extId=extId3a, text=text3]
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
13

getByKey2

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: "extId3a"
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=3, extId=extId3a, text=text3]
OK
14

add

This: { }
Params: Ticket [id=1, extId=extId1, text=text1]
This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Result: true
OK
15

add

This:

{

   Ticket [id=1, extId=extId1, text=text1]

}

Params: Ticket [id=3, extId=extId3x, text=text3]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Result: true
OK
16

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=3, extId=extId3x, text=text3]

}

Params: Ticket [id=2, extId=extId2, text=text2]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3]

}

Result: true
OK
17

add

This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3]

}

Params: Ticket [id=4, extId=extId3x, text=text4]
This:

{

   Ticket [id=1, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: true
OK
18

getByKey1

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
19

invalidate

This:

{

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: Ticket [id=11, extId=extId1, text=text1]
This:

{

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

OK
20

getByKey1

This:

{

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 11
This:

{

   Ticket [id=2, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: Ticket [id=4, extId=extId3x, text=text4]
OK
21

getByKey1

This:

{

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 22
This:

{

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Result: null
OK
22

invalidateKey1

This:

{

   Ticket [id=22, extId=extId2, text=text2],

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4]

}

Params: 2, 22, null
This:

{

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

OK
23

getByKey1

This:

{

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: 22
This:

{

   Ticket [id=3, extId=extId3x, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Result: Ticket [id=22, extId=extId2, text=text2]
OK
24

getByKey2

This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: "extId3a"
This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Result: null
OK
25

invalidateKey2

This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: "extId3x", "extId3a", Ticket [id=3, extId=extId3a, text=text3]
This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

OK
26

getByKey2

This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Params: "extId3a"
This:

{

   Ticket [id=3, extId=extId3a, text=text3],

   Ticket [id=11, extId=extId1, text=text1],

   Ticket [id=4, extId=extId3x, text=text4],

   Ticket [id=22, extId=extId2, text=text2]

}

Result: Ticket [id=3, extId=extId3a, text=text3]
OK

Top Prev (testInvalidate) Next (testRemoveAllByKey1) Method testKey2List

Trace class: org.magicwerk.brownies.collections.Key2List

Trace method: /.+/

Run at: 18.08.2015 01:56:07, Duration: 0.022s

StepDescriptionParametersResultErrorStatus
1

add

This: { }
Params: Ticket [id=1, extId=ExtId1, text=Ticket1]
trueOK
2

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1]

}

Params: Ticket [id=2, extId=null, text=Ticket2]
trueOK
3

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2]

}

Params: Ticket [id=3, extId=ExtId3, text=Ticket3]
trueOK
4

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3]

}

Params: Ticket [id=4, extId=null, text=Ticket4]
trueOK
5

getByKey1

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: 1
Ticket [id=1, extId=ExtId1, text=Ticket1]OK
6

getByKey2

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: "ExtId3"
Ticket [id=3, extId=ExtId3, text=Ticket3]OK
7

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=1, extId=ExtId, text=ERROR]
org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: 1OK
8

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=5, extId=ExtId3, text=ERROR]
org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: ExtId3OK
9

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=null, extId=ExtId, text=ERROR]
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: null key not allowedOK
10

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: null
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: null element not allowedOK
11

add

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: Ticket [id=6, extId=EXT, text=ERROR]
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: element not allowedOK
12

removeByKey1

This:

{

   Ticket [id=1, extId=ExtId1, text=Ticket1],

   Ticket [id=2, extId=null, text=Ticket2],

   Ticket [id=3, extId=ExtId3, text=Ticket3],

   Ticket [id=4, extId=null, text=Ticket4]

}

Params: 1
Ticket [id=1, extId=ExtId1, text=Ticket1]OK

Top Prev (testKey2List) Method testRemoveAllByKey1

Trace class: org.magicwerk.brownies.collections.Key2List

Trace method: removeAllByKey1

Run at: 26.05.2023 14:11:17, Duration: 0.007s

StepDescriptionParametersResultErrorStatus
1

removeAllByKey1

"A"

{

   [A, B1],

   [A, B2]

}

OK
diff --git a/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.xml b/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.xml index bc96e905..a274f157 100644 --- a/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.xml +++ b/magictest/org/magicwerk/brownies/collections/Key2ListTest.ref.xml @@ -622,4 +622,23 @@ + + 2023-05-26T14:11:17.469+02:00 + 0.0065287 + + org.magicwerk.brownies.collections.Key2List + removeAllByKey1 + + + "removeAllByKey1" + + + "\"A\"" + + + "{ \r\n [A, B1], \r\n [A, B2] \r\n}" + + + + diff --git a/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.html b/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.html index 1b71009a..e3e1ab90 100644 --- a/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.html +++ b/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.html @@ -1,2 +1,2 @@ -Test-Report of KeyCollectionTest (Package org.magicwerk.brownies.collections)

Test-Report of KeyCollectionTest (Package org.magicwerk.brownies.collections)

TestRun atDurationStatus
testAsPrimaryKey10.01.2015 11:30:190.033s
testAsSet10.01.2015 11:30:200.003s
testAsSetWithNoNulls10.01.2015 11:30:200.002s
testAsSortedCollection08.10.2013 01:32:550.004s
testAsSortedCollectionByComparable08.10.2013 01:32:550.002s
testAsSortedCollectionWithNull08.10.2013 01:32:550.001s
testAsSortedSet05.12.2014 17:44:470.002s
testAsSortedSetWithDuplicates08.10.2013 01:32:560.002s
testAsSortedSetWithNulls08.10.2013 01:32:560.002s
testAsSortedSetWithNullsFirst08.10.2013 01:32:560.002s
testAsUniqueKey10.01.2015 11:30:240.002s
testClone10.01.2015 11:30:250.002s
testCopy10.01.2015 11:30:250.002s
testCrop10.01.2015 11:30:260.002s
testElemCount22.01.2022 01:10:240.062s
testEquals15.12.2022 17:17:170.001s
testIterator05.01.2019 14:21:220.029s
testKey10.01.2015 18:10:570.018s
testNew08.10.2013 01:32:580.000s
testPut11.09.2015 23:58:220.070s
testRemove10.01.2015 11:30:280.001s

Top Next (testAsSet) Method testAsPrimaryKey

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:19, Duration: 0.033s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: b (3)OK
5

add

nullorg.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: null element not allowedOK

Top Prev (testAsPrimaryKey) Next (testAsSetWithNoNulls) Method testAsSet

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:20, Duration: 0.003s

StepDescriptionParametersResultErrorStatus
1

add

a (0)
This:

{

   a (0)

}

OK
2

add

b (1)
This:

{

   a (0),

   b (1)

}

OK
3

add

a (2)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: a (2)OK
4

add

null
This:

{

   a (0),

   null,

   b (1)

}

OK
5

add

nullorg.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: nullOK

Top Prev (testAsSet) Next (testAsSortedCollection) Method testAsSetWithNoNulls

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:20, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

a (0)
This:

{

   a (0)

}

OK
2

add

b (1)
This:

{

   a (0),

   b (1)

}

OK
3

add

a (2)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: a (2)OK
4

add

null
This:

{

   a (0),

   null,

   b (1)

}

OK

Top Prev (testAsSetWithNoNulls) Next (testAsSortedCollectionByComparable) Method testAsSortedCollection

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:55, Duration: 0.004s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK

Top Prev (testAsSortedCollection) Next (testAsSortedCollectionWithNull) Method testAsSortedCollectionByComparable

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:55, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

nulljava.lang.NullPointerExceptionOK

Top Prev (testAsSortedCollectionByComparable) Next (testAsSortedSet) Method testAsSortedCollectionWithNull

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:55, Duration: 0.001s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK

Top Prev (testAsSortedCollectionWithNull) Next (testAsSortedSetWithDuplicates) Method testAsSortedSet

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 05.12.2014 17:44:47, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: b (3)OK
5

add

null
This:

{

   a (1),

   b (2),

   c (0),

   null

}

OK

Top Prev (testAsSortedSet) Next (testAsSortedSetWithNulls) Method testAsSortedSetWithDuplicates

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:56, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK

Top Prev (testAsSortedSetWithDuplicates) Next (testAsSortedSetWithNullsFirst) Method testAsSortedSetWithNulls

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:56, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

null
This:

{

   a (1),

   c (0),

   null

}

OK
4

add

b (2)
This:

{

   a (1),

   b (2),

   c (0),

   null

}

OK
5

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK
6

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null,

   null

}

OK

Top Prev (testAsSortedSetWithNulls) Next (testAsUniqueKey) Method testAsSortedSetWithNullsFirst

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:56, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

null
This:

{

   null,

   a (1),

   c (0)

}

OK
4

add

b (2)
This:

{

   null,

   a (1),

   b (2),

   c (0)

}

OK
5

add

b (3)
This:

{

   null,

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
6

add

null
This:

{

   null,

   null,

   a (1),

   b (2),

   b (3),

   c (0)

}

OK

Top Prev (testAsSortedSetWithNullsFirst) Next (testClone) Method testAsUniqueKey

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:24, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

null
This:

{

   null,

   c (0)

}

OK
3

add

a (1)
This:

{

   null,

   a (1),

   c (0)

}

OK
4

add

b (2)
This:

{

   null,

   a (1),

   b (2),

   c (0)

}

OK
5

add

b (3)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: b (3)OK
6

add

null
This:

{

   null,

   null,

   a (1),

   b (2),

   c (0)

}

OK

Top Prev (testAsUniqueKey) Next (testCopy) Method testClone

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: clone

Run at: 10.01.2015 11:30:25, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

clone

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK
2

clone

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK

Top Prev (testClone) Next (testCrop) Method testCopy

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: copy

Run at: 10.01.2015 11:30:25, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

copy

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK
2

copy

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK

Top Prev (testCopy) Next (testElemCount) Method testCrop

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: crop

Run at: 10.01.2015 11:30:26, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

crop

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result: { }
OK
2

crop

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result: { }
OK

Top Prev (testCrop) Next (testEquals) Method testElemCount

Run at: 22.01.2022 01:10:24, Duration: 0.062s

StepOutputStatus
1

withElemCount(false): [aa (3), b (2), d (0), d (1)]

withElemCount(true): [b (2), d (0), d (0), aa (3)]

countedElems: {aa (3)=1, b (2)=1, d (0)=2}

removed(d): [b (2), d (0), aa (3)]

removed(d): [b (2), aa (3)]

removed(d): [b (2), aa (3)]

OK

Top Prev (testElemCount) Next (testIterator) Method testEquals

Run at: 15.12.2022 17:17:17, Duration: 0.001s

StepOutputStatus
1

equals([a, b], [a, b]): true

equals([a, b], [b, a]): true

equals([a], [a, a]): false

equals([a, a, b], [a, b, b]): false

equals([a, b], [a, b]): true

equals([a, b], [b, a]): true

equals([a], [a, a]): false

equals([a, a, b], [a, b, b]): false

OK

Top Prev (testEquals) Next (testKey) Method testIterator

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: iterator

Run at: 05.01.2019 14:21:22, Duration: 0.029s

StepDescriptionParametersResultErrorStatus
1

iterator

This: { }
This: { }
Result: { }
OK

Top Prev (testIterator) Next (testNew) Method testKey

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: /.+/

Run at: 10.01.2015 18:10:57, Duration: 0.018s

StepDescriptionParametersResultErrorStatus
1

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   d (0),

   d (1)

}

OK
2

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 2
OK
3

getDistinct

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   a (0),

   b (0),

   d (0)

}

OK
4

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
5

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
6

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
7

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
8

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
9

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
10

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
11

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
12

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: a (0)
This:

{

   b (0),

   d (0),

   d (1)

}

Result: true
OK
13

removeAll

This:

{

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   b (0)

}

Result:

{

   d (0),

   d (1)

}

OK
14

remove

This:

{

   b (0)

}

Params: a (0)
This:

{

   b (0)

}

Result: false
OK
15

removeAll

This:

{

   b (0)

}

Params: d (0)
This:

{

   b (0)

}

Result: { }
OK
16

add

This:

{

   b (0)

}

Params: a (0)
This:

{

   a (0),

   b (0)

}

Result: true
OK
17

removeAll

This:

{

   a (0),

   b (0)

}

Params: a (0)
This:

{

   b (0)

}

Result:

{

   a (0)

}

OK
18-- Sort --OK
19

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   d (0),

   d (1)

}

OK
20

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 2
OK
21

getDistinct

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   a (0),

   b (0),

   d (0)

}

OK
22

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
23

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
24

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
25

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
26

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
27

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
28

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
29

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
30

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: a (0)
This:

{

   b (0),

   d (0),

   d (1)

}

Result: true
OK
31

removeAll

This:

{

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   b (0)

}

Result:

{

   d (0),

   d (1)

}

OK
32

add

This:

{

   b (0)

}

Params: a (0)
This:

{

   a (0),

   b (0)

}

Result: true
OK
33

removeAll

This:

{

   a (0),

   b (0)

}

Params: a (0)
This:

{

   b (0)

}

Result:

{

   a (0)

}

OK
34-- Null --OK
35

getAll

This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { null, null }
OK
36

getCount

This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 2
OK
37

remove

This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: true
OK
38

removeAll

This:

{

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { null }
OK
39-- NullSort --OK
40

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Result: { null, null }
OK
41

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Result: 2
OK
42

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null

}

Result: true
OK
43

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0)

}

Result: { null }
OK

Top Prev (testKey) Next (testPut) Method testNew

Trace class: org.magicwerk.brownies.collections.BagCollection$Builder

Trace method: build

Run at: 08.10.2013 01:32:58, Duration: 0.000s

StepDescriptionParametersResultErrorStatus

Top Prev (testNew) Next (testRemove) Method testPut

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: put

Run at: 11.09.2015 23:58:22, Duration: 0.070s

StepDescriptionParametersResultErrorStatus
1

put (sorted, no duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
2

put (sorted, no duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
3

put (sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
4

put (sorted, duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
5

put (not sorted, no duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
6

put (not sorted, no duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
7

put (not sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
8

put (not sorted, duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
9

put (not sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (99)
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: element not allowedOK
10

put (not sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (2),

   c (3),

   d (5)

}

Result: null
OK

Top Prev (testPut) Method testRemove

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: remove

Run at: 10.01.2015 11:30:28, Duration: 0.001s

StepDescriptionParametersResultErrorStatus
1

remove

This:

{

   a (0),

   b (1)

}

Params: a (2)
This:

{

   b (1)

}

Result: true
OK
2

remove

This:

{

   b (1)

}

Params: null
This:

{

   b (1)

}

Result: false
OK
+Test-Report of KeyCollectionTest (Package org.magicwerk.brownies.collections)

Test-Report of KeyCollectionTest (Package org.magicwerk.brownies.collections)

TestRun atDurationStatus
testAsPrimaryKey10.01.2015 11:30:190.033s
testAsSet10.01.2015 11:30:200.003s
testAsSetWithNoNulls10.01.2015 11:30:200.002s
testAsSortedCollection08.10.2013 01:32:550.004s
testAsSortedCollectionByComparable08.10.2013 01:32:550.002s
testAsSortedCollectionWithNull08.10.2013 01:32:550.001s
testAsSortedSet05.12.2014 17:44:470.002s
testAsSortedSetWithDuplicates08.10.2013 01:32:560.002s
testAsSortedSetWithNulls08.10.2013 01:32:560.002s
testAsSortedSetWithNullsFirst08.10.2013 01:32:560.002s
testAsUniqueKey10.01.2015 11:30:240.002s
testClone10.01.2015 11:30:250.002s
testCopy10.01.2015 11:30:250.002s
testCrop10.01.2015 11:30:260.002s
testElemCount22.01.2022 01:10:240.062s
testEquals15.12.2022 17:17:170.001s
testIterator05.01.2019 14:21:220.029s
testKey28.05.2023 23:44:470.059s
testNew08.10.2013 01:32:580.000s
testPut11.09.2015 23:58:220.070s
testRemove10.01.2015 11:30:280.001s

Top Next (testAsSet) Method testAsPrimaryKey

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:19, Duration: 0.033s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: b (3)OK
5

add

nullorg.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: null element not allowedOK

Top Prev (testAsPrimaryKey) Next (testAsSetWithNoNulls) Method testAsSet

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:20, Duration: 0.003s

StepDescriptionParametersResultErrorStatus
1

add

a (0)
This:

{

   a (0)

}

OK
2

add

b (1)
This:

{

   a (0),

   b (1)

}

OK
3

add

a (2)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: a (2)OK
4

add

null
This:

{

   a (0),

   null,

   b (1)

}

OK
5

add

nullorg.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: nullOK

Top Prev (testAsSet) Next (testAsSortedCollection) Method testAsSetWithNoNulls

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:20, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

a (0)
This:

{

   a (0)

}

OK
2

add

b (1)
This:

{

   a (0),

   b (1)

}

OK
3

add

a (2)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: a (2)OK
4

add

null
This:

{

   a (0),

   null,

   b (1)

}

OK

Top Prev (testAsSetWithNoNulls) Next (testAsSortedCollectionByComparable) Method testAsSortedCollection

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:55, Duration: 0.004s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK

Top Prev (testAsSortedCollection) Next (testAsSortedCollectionWithNull) Method testAsSortedCollectionByComparable

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:55, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

nulljava.lang.NullPointerExceptionOK

Top Prev (testAsSortedCollectionByComparable) Next (testAsSortedSet) Method testAsSortedCollectionWithNull

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:55, Duration: 0.001s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK

Top Prev (testAsSortedCollectionWithNull) Next (testAsSortedSetWithDuplicates) Method testAsSortedSet

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 05.12.2014 17:44:47, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: b (3)OK
5

add

null
This:

{

   a (1),

   b (2),

   c (0),

   null

}

OK

Top Prev (testAsSortedSet) Next (testAsSortedSetWithNulls) Method testAsSortedSetWithDuplicates

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:56, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

b (2)
This:

{

   a (1),

   b (2),

   c (0)

}

OK
4

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
5

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK

Top Prev (testAsSortedSetWithDuplicates) Next (testAsSortedSetWithNullsFirst) Method testAsSortedSetWithNulls

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:56, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

null
This:

{

   a (1),

   c (0),

   null

}

OK
4

add

b (2)
This:

{

   a (1),

   b (2),

   c (0),

   null

}

OK
5

add

b (3)
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null

}

OK
6

add

null
This:

{

   a (1),

   b (2),

   b (3),

   c (0),

   null,

   null

}

OK

Top Prev (testAsSortedSetWithNulls) Next (testAsUniqueKey) Method testAsSortedSetWithNullsFirst

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 08.10.2013 01:32:56, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

a (1)
This:

{

   a (1),

   c (0)

}

OK
3

add

null
This:

{

   null,

   a (1),

   c (0)

}

OK
4

add

b (2)
This:

{

   null,

   a (1),

   b (2),

   c (0)

}

OK
5

add

b (3)
This:

{

   null,

   a (1),

   b (2),

   b (3),

   c (0)

}

OK
6

add

null
This:

{

   null,

   null,

   a (1),

   b (2),

   b (3),

   c (0)

}

OK

Top Prev (testAsSortedSetWithNullsFirst) Next (testClone) Method testAsUniqueKey

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: add

Run at: 10.01.2015 11:30:24, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

add

c (0)
This:

{

   c (0)

}

OK
2

add

null
This:

{

   null,

   c (0)

}

OK
3

add

a (1)
This:

{

   null,

   a (1),

   c (0)

}

OK
4

add

b (2)
This:

{

   null,

   a (1),

   b (2),

   c (0)

}

OK
5

add

b (3)org.magicwerk.brownies.collections.exceptions.DuplicateKeyException: Constraint violation: duplicate key not allowed: b (3)OK
6

add

null
This:

{

   null,

   null,

   a (1),

   b (2),

   c (0)

}

OK

Top Prev (testAsUniqueKey) Next (testCopy) Method testClone

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: clone

Run at: 10.01.2015 11:30:25, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

clone

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK
2

clone

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK

Top Prev (testClone) Next (testCrop) Method testCopy

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: copy

Run at: 10.01.2015 11:30:25, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

copy

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK
2

copy

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

OK

Top Prev (testCopy) Next (testElemCount) Method testCrop

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: crop

Run at: 10.01.2015 11:30:26, Duration: 0.002s

StepDescriptionParametersResultErrorStatus
1

crop

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result: { }
OK
2

crop

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

This:

{

   a (3),

   b (2),

   d (0),

   d (1)

}

Result: { }
OK

Top Prev (testCrop) Next (testEquals) Method testElemCount

Run at: 22.01.2022 01:10:24, Duration: 0.062s

StepOutputStatus
1

withElemCount(false): [aa (3), b (2), d (0), d (1)]

withElemCount(true): [b (2), d (0), d (0), aa (3)]

countedElems: {aa (3)=1, b (2)=1, d (0)=2}

removed(d): [b (2), d (0), aa (3)]

removed(d): [b (2), aa (3)]

removed(d): [b (2), aa (3)]

OK

Top Prev (testElemCount) Next (testIterator) Method testEquals

Run at: 15.12.2022 17:17:17, Duration: 0.001s

StepOutputStatus
1

equals([a, b], [a, b]): true

equals([a, b], [b, a]): true

equals([a], [a, a]): false

equals([a, a, b], [a, b, b]): false

equals([a, b], [a, b]): true

equals([a, b], [b, a]): true

equals([a], [a, a]): false

equals([a, a, b], [a, b, b]): false

OK

Top Prev (testEquals) Next (testKey) Method testIterator

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: iterator

Run at: 05.01.2019 14:21:22, Duration: 0.029s

StepDescriptionParametersResultErrorStatus
1

iterator

This: { }
This: { }
Result: { }
OK

Top Prev (testIterator) Next (testNew) Method testKey

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: /.+/

Run at: 28.05.2023 23:44:47, Duration: 0.059s

StepDescriptionParametersResultErrorStatus
1

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   d (0),

   d (1)

}

OK
2

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 2
OK
3

getDistinct

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   a (0),

   b (0),

   d (0)

}

OK
4

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
5

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
6

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
7

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
8

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
9

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
10

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
11

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
12

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: a (0)
This:

{

   b (0),

   d (0),

   d (1)

}

Result: true
OK
13

removeAll

This:

{

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   b (0)

}

Result:

{

   d (0),

   d (1)

}

OK
14

remove

This:

{

   b (0)

}

Params: a (0)
This:

{

   b (0)

}

Result: false
OK
15

removeAll

This:

{

   b (0)

}

Params: d (0)
This:

{

   b (0)

}

Result: { }
OK
16

add

This:

{

   b (0)

}

Params: a (0)
This:

{

   a (0),

   b (0)

}

Result: true
OK
17

removeAll

This:

{

   a (0),

   b (0)

}

Params: a (0)
This:

{

   b (0)

}

Result:

{

   a (0)

}

OK
18

add

This:

{

   b (0)

}

Params: null
This:

{

   null,

   b (0)

}

Result: true
OK
19

getCount

This:

{

   null,

   b (0)

}

Params: null
This:

{

   null,

   b (0)

}

Result: 1
OK
20

add

This:

{

   null,

   b (0)

}

Params: null
This:

{

   null,

   null,

   b (0)

}

Result: true
OK
21

getCount

This:

{

   null,

   null,

   b (0)

}

Params: null
This:

{

   null,

   null,

   b (0)

}

Result: 2
OK
22-- Sort --OK
23

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   d (0),

   d (1)

}

OK
24

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 2
OK
25

getDistinct

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result:

{

   a (0),

   b (0),

   d (0)

}

OK
26

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
27

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
28

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
29

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: x (0)
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
30

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
31

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 0
OK
32

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: false
OK
33

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { }
OK
34

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: a (0)
This:

{

   b (0),

   d (0),

   d (1)

}

Result: true
OK
35

removeAll

This:

{

   b (0),

   d (0),

   d (1)

}

Params: d (0)
This:

{

   b (0)

}

Result:

{

   d (0),

   d (1)

}

OK
36

add

This:

{

   b (0)

}

Params: a (0)
This:

{

   a (0),

   b (0)

}

Result: true
OK
37

removeAll

This:

{

   a (0),

   b (0)

}

Params: a (0)
This:

{

   b (0)

}

Result:

{

   a (0)

}

OK
38-- Null --OK
39

getAll

This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { null, null }
OK
40

getCount

This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: 2
OK
41

remove

This:

{

   null,

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: true
OK
42

removeAll

This:

{

   null,

   a (0),

   b (0),

   d (0),

   d (1)

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (1)

}

Result: { null }
OK
43-- NullSort --OK
44

getAll

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Result: { null, null }
OK
45

getCount

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Result: 2
OK
46

remove

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null,

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null

}

Result: true
OK
47

removeAll

This:

{

   a (0),

   b (0),

   d (0),

   d (0),

   null

}

Params: null
This:

{

   a (0),

   b (0),

   d (0),

   d (0)

}

Result: { null }
OK

Top Prev (testKey) Next (testPut) Method testNew

Trace class: org.magicwerk.brownies.collections.BagCollection$Builder

Trace method: build

Run at: 08.10.2013 01:32:58, Duration: 0.000s

StepDescriptionParametersResultErrorStatus

Top Prev (testNew) Next (testRemove) Method testPut

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: put

Run at: 11.09.2015 23:58:22, Duration: 0.070s

StepDescriptionParametersResultErrorStatus
1

put (sorted, no duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
2

put (sorted, no duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
3

put (sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
4

put (sorted, duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
5

put (not sorted, no duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
6

put (not sorted, no duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
7

put (not sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (4)
This:

{

   a (1),

   b (4),

   c (3)

}

Result: b (2)
OK
8

put (not sorted, duplicates)

This:

{

   a (1),

   b (4),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (4),

   c (3),

   d (5)

}

Result: null
OK
9

put (not sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: b (99)
org.magicwerk.brownies.collections.exceptions.KeyException: Constraint violation: element not allowedOK
10

put (not sorted, duplicates)

This:

{

   a (1),

   b (2),

   c (3)

}

Params: d (5)
This:

{

   a (1),

   b (2),

   c (3),

   d (5)

}

Result: null
OK

Top Prev (testPut) Method testRemove

Trace class: org.magicwerk.brownies.collections.KeyCollection

Trace method: remove

Run at: 10.01.2015 11:30:28, Duration: 0.001s

StepDescriptionParametersResultErrorStatus
1

remove

This:

{

   a (0),

   b (1)

}

Params: a (2)
This:

{

   b (1)

}

Result: true
OK
2

remove

This:

{

   b (1)

}

Params: null
This:

{

   b (1)

}

Result: false
OK
diff --git a/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.xml b/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.xml index dd3bb032..0cb26633 100644 --- a/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.xml +++ b/magictest/org/magicwerk/brownies/collections/KeyCollectionTest.ref.xml @@ -897,8 +897,8 @@ - 2015-01-10T18:10:57.777+01:00 - 0.017870771 + 2023-05-28T23:44:47.337+02:00 + 0.059449499 org.magicwerk.brownies.collections.KeyCollection /.+/ @@ -1139,6 +1139,62 @@ + + + "add" + + + "{ \r\n b (0) \r\n}" + "null" + + + "{ \r\n null, \r\n b (0) \r\n}" + "true" + + + + + + "getCount" + + + "{ \r\n null, \r\n b (0) \r\n}" + "null" + + + "{ \r\n null, \r\n b (0) \r\n}" + "1" + + + + + + "add" + + + "{ \r\n null, \r\n b (0) \r\n}" + "null" + + + "{ \r\n null, \r\n null, \r\n b (0) \r\n}" + "true" + + + + + + "getCount" + + + "{ \r\n null, \r\n null, \r\n b (0) \r\n}" + "null" + + + "{ \r\n null, \r\n null, \r\n b (0) \r\n}" + "2" + + + "-- Sort --" diff --git a/src/main/java/org/magicwerk/brownies/collections/BigList.java b/src/main/java/org/magicwerk/brownies/collections/BigList.java index 5b3c3c01..c690bf75 100644 --- a/src/main/java/org/magicwerk/brownies/collections/BigList.java +++ b/src/main/java/org/magicwerk/brownies/collections/BigList.java @@ -149,6 +149,7 @@ public static BigList create(Collection coll) { * @return created list * @param type of elements stored in the list */ + @SuppressWarnings("unchecked") public static BigList create(E... elems) { BigList list = new BigList(); if (elems != null) { diff --git a/src/main/java/org/magicwerk/brownies/collections/GapList.java b/src/main/java/org/magicwerk/brownies/collections/GapList.java index 00470434..93a720aa 100644 --- a/src/main/java/org/magicwerk/brownies/collections/GapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/GapList.java @@ -143,9 +143,7 @@ public static GapList create(Collection coll) { public static GapList create(E... elems) { GapList list = new GapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -400,12 +398,14 @@ boolean isNormalized() { */ @SuppressWarnings("unchecked") void init(Object[] values, int size) { + assert (size <= values.length); + this.values = (E[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/ICollection.java b/src/main/java/org/magicwerk/brownies/collections/ICollection.java index 5eb711ec..b29f07b7 100644 --- a/src/main/java/org/magicwerk/brownies/collections/ICollection.java +++ b/src/main/java/org/magicwerk/brownies/collections/ICollection.java @@ -143,4 +143,18 @@ default int countIf(Predicate predicate) { */ IList filterMap(Predicate filter, Function func); + /** + * Returns a copy of this collection with all its elements. + * + * @return a copy of this collection + */ + ICollection copy(); + + /** + * Returns an empty copy of this collection. + * + * @return an empty copy of this collection + */ + ICollection crop(); + } diff --git a/src/main/java/org/magicwerk/brownies/collections/ICollectionTools.java b/src/main/java/org/magicwerk/brownies/collections/ICollectionTools.java index a3e30102..f9590b41 100644 --- a/src/main/java/org/magicwerk/brownies/collections/ICollectionTools.java +++ b/src/main/java/org/magicwerk/brownies/collections/ICollectionTools.java @@ -22,6 +22,7 @@ import java.util.NoSuchElementException; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.Supplier; /** * ICollectionTools offers default implementations of Collection functionality. @@ -137,8 +138,8 @@ public static int countIf(Collection coll, Predicate predicate * @param predicate filter predicate * @return created list */ - public static IList filter(Collection coll, Predicate predicate) { - IList list = GapList.create(); + public static > C filter(Collection coll, Predicate predicate, Supplier factory) { + C list = factory.get(); for (E e : coll) { if (predicate.test(e)) { list.add(e); @@ -153,8 +154,8 @@ public static IList filter(Collection coll, Predicate predi * @param func mapping function * @return created list */ - public static IList map(Collection coll, Function func) { - IList list = GapList.create(); + public static > C map(Collection coll, Function func, Supplier factory) { + C list = factory.get(); for (E e : coll) { list.add(func.apply(e)); } @@ -169,7 +170,19 @@ public static IList map(Collection coll, Function func) { * @return created list */ public static IList mapFilter(Collection coll, Function func, Predicate filter) { - IList list = GapList.create(); + return mapFilter(coll, func, filter, GapList::new); + } + + /** + * Create a new collection by applying the specified mapping function to all elements and then filtering it. + * + * @param func mapping function + * @param filter filter predicate + * @param factory factory to create collection + * @return created list + */ + public static > C mapFilter(Collection coll, Function func, Predicate filter, Supplier factory) { + C list = factory.get(); for (E e : coll) { R r = func.apply(e); if (filter.test(r)) { @@ -186,8 +199,20 @@ public static IList mapFilter(Collection coll, Function func, * @param func mapping function * @return created list */ - public static IList filterMap(Collection coll, Predicate filter, Function func) { - IList list = GapList.create(); + public static > IList filterMap(Collection coll, Predicate filter, Function func) { + return filterMap(coll, filter, func, GapList::new); + } + + /** + * Create a new collection by applying the specified filter first and then the mapping function to all elements selected. + * + * @param filter filter predicate + * @param func mapping function + * @param factory factory to create collection + * @return created list + */ + public static > C filterMap(Collection coll, Predicate filter, Function func, Supplier factory) { + C list = factory.get(); for (E e : coll) { if (filter.test(e)) { list.add(func.apply(e)); diff --git a/src/main/java/org/magicwerk/brownies/collections/IList.java b/src/main/java/org/magicwerk/brownies/collections/IList.java index ad110eb4..05070bff 100644 --- a/src/main/java/org/magicwerk/brownies/collections/IList.java +++ b/src/main/java/org/magicwerk/brownies/collections/IList.java @@ -77,6 +77,7 @@ static Object[] toArray(Collection coll) { * * @return a modifiable copy of this list */ + @Override @SuppressWarnings("unchecked") public IList copy() { return (IList) clone(); @@ -110,6 +111,7 @@ public Object clone() { * * @return an empty copy of this list */ + @Override public IList crop() { return doCreate(0); } @@ -417,6 +419,7 @@ static int hashCodeElem(Object elem) { * @param elem element to count * @return count how many times the specified element is contained in the list */ + // See java.util.Collections.frequency(Collection, Object) public int count(E elem) { int count = 0; int size = size(); @@ -1649,6 +1652,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(E... elems) { return doAddAll(-1, new IReadOnlyListFromArray(elems)); } @@ -1673,7 +1677,7 @@ public boolean addArray(int index, E[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, E... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") E... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyListFromArray(elems)); @@ -1746,6 +1750,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, E... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1821,6 +1826,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, E... elems) { putAll(index, new IReadOnlyListFromArray(elems)); } @@ -1876,6 +1882,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(E... elems) { initAll(new IReadOnlyListFromArray(elems)); } @@ -1937,6 +1944,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, E... elems) { replaceAll(index, len, new IReadOnlyListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/Key1Collection.java b/src/main/java/org/magicwerk/brownies/collections/Key1Collection.java index 4b326d07..a64339f7 100644 --- a/src/main/java/org/magicwerk/brownies/collections/Key1Collection.java +++ b/src/main/java/org/magicwerk/brownies/collections/Key1Collection.java @@ -37,7 +37,6 @@ * @param type of elements stored in the collection * @param type of key */ -@SuppressWarnings("serial") public class Key1Collection extends KeyCollectionImpl { /** @@ -76,11 +75,13 @@ public Key1Collection build() { // -- Constraint + @SuppressWarnings("unchecked") @Override public Builder withNull(boolean allowNull) { return (Builder) super.withNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withConstraint(Predicate constraint) { return (Builder) super.withConstraint(constraint); @@ -88,21 +89,25 @@ public Builder withConstraint(Predicate constraint) { // -- Triggers + @SuppressWarnings("unchecked") @Override public Builder withBeforeInsertTrigger(Consumer trigger) { return (Builder) super.withBeforeInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterInsertTrigger(Consumer trigger) { return (Builder) super.withAfterInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withBeforeDeleteTrigger(Consumer trigger) { return (Builder) super.withBeforeDeleteTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterDeleteTrigger(Consumer trigger) { return (Builder) super.withAfterDeleteTrigger(trigger); @@ -110,21 +115,25 @@ public Builder withAfterDeleteTrigger(Consumer trigger) { //-- Content + @SuppressWarnings("unchecked") @Override public Builder withCapacity(int capacity) { return (Builder) super.withCapacity(capacity); } + @SuppressWarnings("unchecked") @Override public Builder withContent(Collection elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withContent(E... elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withMaxSize(int maxSize) { return (Builder) super.withMaxSize(maxSize); @@ -132,56 +141,67 @@ public Builder withMaxSize(int maxSize) { //-- Element key + @SuppressWarnings("unchecked") @Override public Builder withSetBehavior(boolean setBehavior) { return (Builder) super.withSetBehavior(setBehavior); } + @SuppressWarnings("unchecked") @Override public Builder withElemSet() { return (Builder) super.withElemSet(); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByElem(boolean orderBy) { return (Builder) super.withOrderByElem(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withElemNull(boolean allowNull) { return (Builder) super.withElemNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates) { return (Builder) super.withElemDuplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withElemDuplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(boolean sort) { return (Builder) super.withElemSort(sort); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator) { return (Builder) super.withElemSort(comparator); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withElemSort(comparator, sortNullsFirst); } + @SuppressWarnings("unchecked") @Override public Builder withPrimaryElem() { return (Builder) super.withPrimaryElem(); } + @SuppressWarnings("unchecked") @Override public Builder withUniqueElem() { return (Builder) super.withUniqueElem(); @@ -195,52 +215,60 @@ public Builder withUniqueElem() { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Map(Function mapper) { return (Builder) withKeyMap(1, mapper); } /** * Specify this key to be a primary key. - * This is identical to calling withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withPrimaryKey1Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(1, mapper); } /** * Specify this key to be a unique key. - * This is identical to calling withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withUniqueKey1Map(Function mapper) { return (Builder) super.withUniqueKeyMap(1, mapper); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey1(boolean orderBy) { return (Builder) super.withOrderByKey1(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Null(boolean allowNull) { return (Builder) super.withKey1Null(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates) { return (Builder) super.withKey1Duplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withKey1Duplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Sort(boolean sort) { return (Builder) super.withKey1Sort(sort); @@ -253,6 +281,7 @@ public Builder withKey1Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator) { return (Builder) super.withKeySort(1, comparator); } @@ -265,6 +294,7 @@ public Builder withKey1Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(1, comparator, sortNullsFirst); } @@ -284,11 +314,13 @@ protected Builder getBuilder() { return new Builder<>(this); } + @SuppressWarnings("unchecked") @Override public Key1Collection copy() { return (Key1Collection) super.copy(); } + @SuppressWarnings("unchecked") @Override public Key1Collection crop() { return (Key1Collection) super.crop(); @@ -296,11 +328,13 @@ public Key1Collection crop() { //-- Element methods + @SuppressWarnings("unchecked") @Override public Key1Collection getAll(E elem) { return (Key1Collection) super.getAll(elem); } + @SuppressWarnings("unchecked") @Override public Key1Collection removeAll(E elem) { return (Key1Collection) super.removeAll(elem); @@ -323,6 +357,7 @@ public void invalidate(E elem) { * * @return mapper for key map */ + @SuppressWarnings("unchecked") public Function getKey1Mapper() { return (Function) super.getKeyMapper(1); } @@ -366,6 +401,7 @@ public E getByKey1(K key) { * @param key key * @return all elements with specified key (never null) */ + @SuppressWarnings("unchecked") public Key1Collection getAllByKey1(K key) { return (Key1Collection) super.getAllByKey(1, key); } @@ -398,6 +434,7 @@ public E removeByKey1(K key) { * @return removed elements with specified key (never null) * */ + @SuppressWarnings("unchecked") public Key1Collection removeAllByKey1(K key) { return (Key1Collection) super.removeAllByKey(1, key); } diff --git a/src/main/java/org/magicwerk/brownies/collections/Key1List.java b/src/main/java/org/magicwerk/brownies/collections/Key1List.java index 18f043db..dedb543b 100644 --- a/src/main/java/org/magicwerk/brownies/collections/Key1List.java +++ b/src/main/java/org/magicwerk/brownies/collections/Key1List.java @@ -38,7 +38,6 @@ * @param type of elements stored in the list * @param type of key */ -@SuppressWarnings("serial") public class Key1List extends KeyListImpl { /** @@ -64,11 +63,13 @@ public Builder() { // -- Constraint + @SuppressWarnings("unchecked") @Override public Builder withNull(boolean allowNull) { return (Builder) super.withNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withConstraint(Predicate constraint) { return (Builder) super.withConstraint(constraint); @@ -76,21 +77,25 @@ public Builder withConstraint(Predicate constraint) { // -- Triggers + @SuppressWarnings("unchecked") @Override public Builder withBeforeInsertTrigger(Consumer trigger) { return (Builder) super.withBeforeInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterInsertTrigger(Consumer trigger) { return (Builder) super.withAfterInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withBeforeDeleteTrigger(Consumer trigger) { return (Builder) super.withBeforeDeleteTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterDeleteTrigger(Consumer trigger) { return (Builder) super.withAfterDeleteTrigger(trigger); @@ -98,31 +103,37 @@ public Builder withAfterDeleteTrigger(Consumer trigger) { //-- Content + @SuppressWarnings("unchecked") @Override public Builder withCapacity(int capacity) { return (Builder) super.withCapacity(capacity); } + @SuppressWarnings("unchecked") @Override public Builder withContent(Collection elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withContent(E... elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withMaxSize(int maxSize) { return (Builder) super.withMaxSize(maxSize); } + @SuppressWarnings("unchecked") @Override public Builder withWindowSize(int maxSize) { return (Builder) super.withWindowSize(maxSize); } + @SuppressWarnings("unchecked") @Override public Builder withListBig(boolean bigList) { return (Builder) super.withListBig(bigList); @@ -130,51 +141,61 @@ public Builder withListBig(boolean bigList) { //-- Element key + @SuppressWarnings("unchecked") @Override public Builder withElemSet() { return (Builder) super.withElemSet(); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByElem(boolean orderBy) { return (Builder) super.withOrderByElem(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withElemNull(boolean allowNull) { return (Builder) super.withElemNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates) { return (Builder) super.withElemDuplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withElemDuplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(boolean sort) { return (Builder) super.withElemSort(sort); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator) { return (Builder) super.withElemSort(comparator); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withElemSort(comparator, sortNullsFirst); } + @SuppressWarnings("unchecked") @Override public Builder withPrimaryElem() { return (Builder) super.withPrimaryElem(); } + @SuppressWarnings("unchecked") @Override public Builder withUniqueElem() { return (Builder) super.withUniqueElem(); @@ -188,59 +209,66 @@ public Builder withUniqueElem() { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Map(Function mapper) { return (Builder) super.withKeyMap(1, mapper); } /** * Specify this key to be a primary key. - * This is identical to calling - * withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withPrimaryKey1Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(1, mapper); } /** * Specify this key to be a unique key. - * This is identical to calling - * withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withUniqueKey1Map(Function mapper) { return (Builder) super.withUniqueKeyMap(1, mapper); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey1(boolean orderBy) { return (Builder) super.withOrderByKey1(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey1(Class type) { return (Builder) super.withOrderByKey1(type); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Null(boolean allowNull) { return (Builder) super.withKey1Null(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates) { return (Builder) super.withKey1Duplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withKey1Duplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Sort(boolean sort) { return (Builder) super.withKey1Sort(sort); @@ -253,6 +281,7 @@ public Builder withKey1Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator) { return (Builder) super.withKeySort(1, comparator); } @@ -265,6 +294,7 @@ public Builder withKey1Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(1, comparator, sortNullsFirst); } @@ -362,6 +392,7 @@ public E put(E elem) { * * @return mapper for key map */ + @SuppressWarnings("unchecked") public Function getKey1Mapper() { return (Function) getKeyMapper(1); } diff --git a/src/main/java/org/magicwerk/brownies/collections/Key1Set.java b/src/main/java/org/magicwerk/brownies/collections/Key1Set.java index 906ae1d1..4e6c3ee9 100644 --- a/src/main/java/org/magicwerk/brownies/collections/Key1Set.java +++ b/src/main/java/org/magicwerk/brownies/collections/Key1Set.java @@ -225,14 +225,25 @@ public Builder withElemSort(Comparator comparator, boolean sort return (Builder) super.withElemSort(comparator, sortNullsFirst); } + /** + * {@inheritDoc} + *

+ * Note that a {@link Key1Set} always has an element set, so this call is not necessary. + */ @Override public Builder withPrimaryElem() { - return (Builder) super.withPrimaryElem(); + return this; } + /** + * {@inheritDoc} + *

+ * Note that a {@link Key1Set} always has an element set, so an exception is thrown. + */ @Override public Builder withUniqueElem() { - return (Builder) super.withUniqueElem(); + KeyCollectionImpl.errorInvalidSetBehavior(); + return this; } // -- Key1 @@ -251,7 +262,7 @@ public Builder withKey1Map(Function mapper) { /** * Specify this key to be a primary key. - * This is identical to calling withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) @@ -264,7 +275,7 @@ public Builder withPrimaryKey1Map(Function mapper) { /** * Specify this key to be a unique key. - * This is identical to calling withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) diff --git a/src/main/java/org/magicwerk/brownies/collections/Key2Collection.java b/src/main/java/org/magicwerk/brownies/collections/Key2Collection.java index 5540d956..e32590fd 100644 --- a/src/main/java/org/magicwerk/brownies/collections/Key2Collection.java +++ b/src/main/java/org/magicwerk/brownies/collections/Key2Collection.java @@ -38,7 +38,6 @@ * @param type of first key * @param type of second key */ -@SuppressWarnings("serial") public class Key2Collection extends KeyCollectionImpl { /** @@ -77,11 +76,13 @@ public Key2Collection build() { // -- Constraint + @SuppressWarnings("unchecked") @Override public Builder withNull(boolean allowNull) { return (Builder) super.withNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withConstraint(Predicate constraint) { return (Builder) super.withConstraint(constraint); @@ -89,21 +90,25 @@ public Builder withConstraint(Predicate constraint) { // -- Triggers + @SuppressWarnings("unchecked") @Override public Builder withBeforeInsertTrigger(Consumer trigger) { return (Builder) super.withBeforeInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterInsertTrigger(Consumer trigger) { return (Builder) super.withAfterInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withBeforeDeleteTrigger(Consumer trigger) { return (Builder) super.withBeforeDeleteTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterDeleteTrigger(Consumer trigger) { return (Builder) super.withAfterDeleteTrigger(trigger); @@ -111,21 +116,25 @@ public Builder withAfterDeleteTrigger(Consumer trigger) { //-- Content + @SuppressWarnings("unchecked") @Override public Builder withCapacity(int capacity) { return (Builder) super.withCapacity(capacity); } + @SuppressWarnings("unchecked") @Override public Builder withContent(Collection elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withContent(E... elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withMaxSize(int maxSize) { return (Builder) super.withMaxSize(maxSize); @@ -133,56 +142,67 @@ public Builder withMaxSize(int maxSize) { //-- Element key + @SuppressWarnings("unchecked") @Override public Builder withSetBehavior(boolean setBehavior) { return (Builder) super.withSetBehavior(setBehavior); } + @SuppressWarnings("unchecked") @Override public Builder withElemSet() { return (Builder) super.withElemSet(); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByElem(boolean orderBy) { return (Builder) super.withOrderByElem(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withElemNull(boolean allowNull) { return (Builder) super.withElemNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates) { return (Builder) super.withElemDuplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withElemDuplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(boolean sort) { return (Builder) super.withElemSort(sort); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator) { return (Builder) super.withElemSort(comparator); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withElemSort(comparator, sortNullsFirst); } + @SuppressWarnings("unchecked") @Override public Builder withPrimaryElem() { return (Builder) super.withPrimaryElem(); } + @SuppressWarnings("unchecked") @Override public Builder withUniqueElem() { return (Builder) super.withUniqueElem(); @@ -196,52 +216,60 @@ public Builder withUniqueElem() { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Map(Function mapper) { return (Builder) super.withKeyMap(1, mapper); } /** * Specify this key to be a primary key. - * This is identical to calling withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withPrimaryKey1Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(1, mapper); } /** * Specify this key to be a unique key. - * This is identical to calling withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withUniqueKey1Map(Function mapper) { return (Builder) super.withUniqueKeyMap(1, mapper); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey1(boolean orderBy) { return (Builder) super.withOrderByKey1(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Null(boolean allowNull) { return (Builder) super.withKey1Null(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates) { return (Builder) super.withKey1Duplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withKey1Duplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Sort(boolean sort) { return (Builder) super.withKey1Sort(sort); @@ -254,6 +282,7 @@ public Builder withKey1Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator) { return (Builder) super.withKeySort(1, comparator); } @@ -266,6 +295,7 @@ public Builder withKey1Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(1, comparator, sortNullsFirst); } @@ -278,52 +308,60 @@ public Builder withKey1Sort(Comparator comparator, boolea * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey2Map(Function mapper) { return (Builder) super.withKeyMap(2, mapper); } /** * Specify this key to be a primary key. - * This is identical to calling withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false). + * This is identical to calling {@code withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withPrimaryKey2Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(2, mapper); } /** * Specify this key to be a unique key. - * This is identical to calling withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true). + * This is identical to calling {@code withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withUniqueKey2Map(Function mapper) { return (Builder) super.withUniqueKeyMap(2, mapper); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey2(boolean orderBy) { return (Builder) super.withOrderByKey2(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Null(boolean allowNull) { return (Builder) super.withKey2Null(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Duplicates(boolean allowDuplicates) { return (Builder) super.withKey2Duplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withKey2Duplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Sort(boolean sort) { return (Builder) super.withKey2Sort(sort); @@ -336,6 +374,7 @@ public Builder withKey2Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey2Sort(Comparator comparator) { return (Builder) super.withKeySort(2, comparator); } @@ -348,6 +387,7 @@ public Builder withKey2Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey2Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(2, comparator, sortNullsFirst); } @@ -367,11 +407,13 @@ protected Builder getBuilder() { return new Builder<>(this); } + @SuppressWarnings("unchecked") @Override public Key2Collection copy() { return (Key2Collection) super.copy(); } + @SuppressWarnings("unchecked") @Override public Key2Collection crop() { return (Key2Collection) super.crop(); @@ -379,11 +421,13 @@ public Key2Collection crop() { //-- Element methods + @SuppressWarnings("unchecked") @Override public Key2Collection getAll(E elem) { return (Key2Collection) super.getAll(elem); } + @SuppressWarnings("unchecked") @Override public Key2Collection removeAll(E elem) { return (Key2Collection) super.removeAll(elem); @@ -406,6 +450,7 @@ public void invalidate(E elem) { * * @return mapper for key map */ + @SuppressWarnings("unchecked") public Function getKey1Mapper() { return (Function) super.getKeyMapper(1); } @@ -449,6 +494,7 @@ public E getByKey1(K1 key) { * @param key key * @return all elements with specified key (never null) */ + @SuppressWarnings("unchecked") public Key2Collection getAllByKey1(K1 key) { return (Key2Collection) super.getAllByKey(1, key); } @@ -480,6 +526,7 @@ public E removeByKey1(K1 key) { * @param key key * @return removed elements with specified key (never null) */ + @SuppressWarnings("unchecked") public Key2Collection removeAllByKey1(K1 key) { return (Key2Collection) super.removeAllByKey(1, key); } @@ -543,6 +590,7 @@ public void invalidateKey1(K1 oldKey, K1 newKey, E elem) { * * @return mapper for key map */ + @SuppressWarnings("unchecked") public Function getKey2Mapper() { return (Function) super.getKeyMapper(2); } @@ -586,6 +634,7 @@ public E getByKey2(K2 key) { * @param key key * @return all elements with specified key (never null) */ + @SuppressWarnings("unchecked") public Key2Collection getAllByKey2(K2 key) { return (Key2Collection) super.getAllByKey(2, key); } @@ -617,6 +666,7 @@ public E removeByKey2(K2 key) { * @param key key * @return removed elements with specified key (never null) */ + @SuppressWarnings("unchecked") public Key2Collection removeAllByKey2(K2 key) { return (Key2Collection) super.removeAllByKey(2, key); } diff --git a/src/main/java/org/magicwerk/brownies/collections/Key2List.java b/src/main/java/org/magicwerk/brownies/collections/Key2List.java index e8a7ece2..4c28c860 100644 --- a/src/main/java/org/magicwerk/brownies/collections/Key2List.java +++ b/src/main/java/org/magicwerk/brownies/collections/Key2List.java @@ -39,7 +39,6 @@ * @param type of first key * @param type of second key */ -@SuppressWarnings("serial") public class Key2List extends KeyListImpl { /** @@ -65,11 +64,13 @@ public Builder() { // -- Constraint + @SuppressWarnings("unchecked") @Override public Builder withNull(boolean allowNull) { return (Builder) super.withNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withConstraint(Predicate constraint) { return (Builder) super.withConstraint(constraint); @@ -77,21 +78,25 @@ public Builder withConstraint(Predicate constraint) { // -- Triggers + @SuppressWarnings("unchecked") @Override public Builder withBeforeInsertTrigger(Consumer trigger) { return (Builder) super.withBeforeInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterInsertTrigger(Consumer trigger) { return (Builder) super.withAfterInsertTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withBeforeDeleteTrigger(Consumer trigger) { return (Builder) super.withBeforeDeleteTrigger(trigger); } + @SuppressWarnings("unchecked") @Override public Builder withAfterDeleteTrigger(Consumer trigger) { return (Builder) super.withAfterDeleteTrigger(trigger); @@ -99,31 +104,37 @@ public Builder withAfterDeleteTrigger(Consumer trigger) { //-- Content + @SuppressWarnings("unchecked") @Override public Builder withCapacity(int capacity) { return (Builder) super.withCapacity(capacity); } + @SuppressWarnings("unchecked") @Override public Builder withContent(Collection elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withContent(E... elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withMaxSize(int maxSize) { return (Builder) super.withMaxSize(maxSize); } + @SuppressWarnings("unchecked") @Override public Builder withWindowSize(int maxSize) { return (Builder) super.withWindowSize(maxSize); } + @SuppressWarnings("unchecked") @Override public Builder withListBig(boolean bigList) { return (Builder) super.withListBig(bigList); @@ -131,51 +142,61 @@ public Builder withListBig(boolean bigList) { //-- Element key + @SuppressWarnings("unchecked") @Override public Builder withElemSet() { return (Builder) super.withElemSet(); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByElem(boolean orderBy) { return (Builder) super.withOrderByElem(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withElemNull(boolean allowNull) { return (Builder) super.withElemNull(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates) { return (Builder) super.withElemDuplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withElemDuplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(boolean sort) { return (Builder) super.withElemSort(sort); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator) { return (Builder) super.withElemSort(comparator); } + @SuppressWarnings("unchecked") @Override public Builder withElemSort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withElemSort(comparator, sortNullsFirst); } + @SuppressWarnings("unchecked") @Override public Builder withPrimaryElem() { return (Builder) super.withPrimaryElem(); } + @SuppressWarnings("unchecked") @Override public Builder withUniqueElem() { return (Builder) super.withUniqueElem(); @@ -189,6 +210,7 @@ public Builder withUniqueElem() { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Map(Function mapper) { return (Builder) super.withKeyMap(1, mapper); } @@ -201,6 +223,7 @@ public Builder withKey1Map(Function mapper) { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withPrimaryKey1Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(1, mapper); } @@ -213,35 +236,42 @@ public Builder withPrimaryKey1Map(Function mapper) { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withUniqueKey1Map(Function mapper) { return (Builder) super.withUniqueKeyMap(1, mapper); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey1(boolean orderBy) { return (Builder) super.withOrderByKey1(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey1(Class type) { return (Builder) super.withOrderByKey1(type); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Null(boolean allowNull) { return (Builder) super.withKey1Null(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates) { return (Builder) super.withKey1Duplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withKey1Duplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey1Sort(boolean sort) { return (Builder) super.withKey1Sort(sort); @@ -254,6 +284,7 @@ public Builder withKey1Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator) { return (Builder) super.withKeySort(1, comparator); } @@ -266,6 +297,7 @@ public Builder withKey1Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey1Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(1, comparator, sortNullsFirst); } @@ -277,59 +309,66 @@ public Builder withKey1Sort(Comparator comparator, boolea * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey2Map(Function mapper) { return (Builder) super.withKeyMap(2, mapper); } /** * Specify this key to be a primary key. - * This is identical to calling - * withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false). + * This is identical to calling {@code withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withPrimaryKey2Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(2, mapper); } /** * Specify this key to be a unique key. - * This is identical to calling - * withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true). + * This is identical to calling {@code withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withUniqueKey2Map(Function mapper) { return (Builder) super.withUniqueKeyMap(2, mapper); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey2(boolean orderBy) { return (Builder) super.withOrderByKey2(orderBy); } + @SuppressWarnings("unchecked") @Override public Builder withOrderByKey2(Class type) { return (Builder) super.withOrderByKey2(type); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Null(boolean allowNull) { return (Builder) super.withKey2Null(allowNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Duplicates(boolean allowDuplicates) { return (Builder) super.withKey2Duplicates(allowDuplicates); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) { return (Builder) super.withKey2Duplicates(allowDuplicates, allowDuplicatesNull); } + @SuppressWarnings("unchecked") @Override public Builder withKey2Sort(boolean sort) { return (Builder) super.withKey2Sort(sort); @@ -342,6 +381,7 @@ public Builder withKey2Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey2Sort(Comparator comparator) { return (Builder) super.withKeySort(2, comparator); } @@ -354,6 +394,7 @@ public Builder withKey2Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") public Builder withKey2Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(2, comparator, sortNullsFirst); } @@ -370,7 +411,10 @@ public Key2List build() { keyList = new Key2List(); } init(keyColl, keyList); - return (Key2List) keyList; + + @SuppressWarnings("unchecked") + Key2List list = (Key2List) keyList; + return list; } } @@ -450,6 +494,7 @@ public E put(E elem) { * * @return mapper for key map */ + @SuppressWarnings("unchecked") public Function getKey1Mapper() { return (Function) getKeyMapper(1); } @@ -619,6 +664,7 @@ public void invalidateKey1(K1 oldKey, K1 newKey, E elem) { * * @return mapper for key map */ + @SuppressWarnings("unchecked") public Function getKey2Mapper() { return (Function) getKeyMapper(2); } diff --git a/src/main/java/org/magicwerk/brownies/collections/Key2Set.java b/src/main/java/org/magicwerk/brownies/collections/Key2Set.java index e53b679a..97d24a73 100644 --- a/src/main/java/org/magicwerk/brownies/collections/Key2Set.java +++ b/src/main/java/org/magicwerk/brownies/collections/Key2Set.java @@ -33,7 +33,6 @@ * @see Key2Collection * @param type of elements stored in the set */ -@SuppressWarnings("serial") public class Key2Set extends Key2Collection implements Set { /** @@ -163,6 +162,7 @@ public Builder withContent(Collection elements) { return (Builder) super.withContent(elements); } + @SuppressWarnings("unchecked") @Override public Builder withContent(E... elements) { return (Builder) super.withContent(elements); @@ -175,6 +175,7 @@ public Builder withMaxSize(int maxSize) { //-- Element key + @SuppressWarnings("unchecked") /** * {@inheritDoc} *

@@ -223,14 +224,25 @@ public Builder withElemSort(Comparator comparator, boolean return (Builder) super.withElemSort(comparator, sortNullsFirst); } + /** + * {@inheritDoc} + *

+ * Note that a {@link Key2Set} always has an element set, so this call is not necessary. + */ @Override public Builder withPrimaryElem() { - return (Builder) super.withPrimaryElem(); + return this; } + /** + * {@inheritDoc} + *

+ * Note that a {@link Key2Set} always has an element set, so an exception is thrown. + */ @Override public Builder withUniqueElem() { - return (Builder) super.withUniqueElem(); + KeyCollectionImpl.errorInvalidSetBehavior(); + return this; } // -- Key1 @@ -241,6 +253,7 @@ public Builder withUniqueElem() { * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withKey1Map(Function mapper) { return (Builder) super.withKeyMap(1, mapper); @@ -248,11 +261,12 @@ public Builder withKey1Map(Function mapper) { /** * Specify this key to be a primary key. - * This is identical to calling withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withPrimaryKey1Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(1, mapper); @@ -260,11 +274,12 @@ public Builder withPrimaryKey1Map(Function mapper) { /** * Specify this key to be a unique key. - * This is identical to calling withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true). + * This is identical to calling {@code withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withUniqueKey1Map(Function mapper) { return (Builder) super.withUniqueKeyMap(1, mapper); @@ -302,6 +317,7 @@ public Builder withKey1Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withKey1Sort(Comparator comparator) { return (Builder) super.withKeySort(1, comparator); @@ -315,6 +331,7 @@ public Builder withKey1Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withKey1Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(1, comparator, sortNullsFirst); @@ -328,6 +345,7 @@ public Builder withKey1Sort(Comparator comparator, boolea * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withKey2Map(Function mapper) { return (Builder) super.withKeyMap(2, mapper); @@ -335,11 +353,12 @@ public Builder withKey2Map(Function mapper) { /** * Specify this key to be a primary key. - * This is identical to calling withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false). + * This is identical to calling {@code withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withPrimaryKey2Map(Function mapper) { return (Builder) super.withPrimaryKeyMap(2, mapper); @@ -347,11 +366,12 @@ public Builder withPrimaryKey2Map(Function mapper) { /** * Specify this key to be a unique key. - * This is identical to calling withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true). + * This is identical to calling {@code withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true)}. * * @param mapper mapper to use * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withUniqueKey2Map(Function mapper) { return (Builder) super.withUniqueKeyMap(2, mapper); @@ -389,6 +409,7 @@ public Builder withKey2Sort(boolean sort) { * @param comparator comparator to use for sorting * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withKey2Sort(Comparator comparator) { return (Builder) super.withKeySort(2, comparator); @@ -402,6 +423,7 @@ public Builder withKey2Sort(Comparator comparator) { * @param sortNullsFirst true if null will be sorted first, false for last * @return this (fluent interface) */ + @SuppressWarnings("unchecked") @Override public Builder withKey2Sort(Comparator comparator, boolean sortNullsFirst) { return (Builder) super.withKeySort(2, comparator, sortNullsFirst); diff --git a/src/main/java/org/magicwerk/brownies/collections/KeyCollectionImpl.java b/src/main/java/org/magicwerk/brownies/collections/KeyCollectionImpl.java index 7a9a8bd2..206fec1e 100644 --- a/src/main/java/org/magicwerk/brownies/collections/KeyCollectionImpl.java +++ b/src/main/java/org/magicwerk/brownies/collections/KeyCollectionImpl.java @@ -225,6 +225,7 @@ protected BuilderImpl withContent(Collection elements) { * @param elements initial elements * @return this (fluent interface) */ + @SuppressWarnings("unchecked") protected BuilderImpl withContent(E... elements) { this.array = elements; return this; @@ -405,8 +406,7 @@ protected BuilderImpl withElemSort(Comparator comparator, boolean /** * Specify the element to be a primary key. - * This is identical to calling - * withElemNull(false) and withElemDuplicates(false). + * This is identical to calling {@code withElemNull(false) and withElemDuplicates(false)}. * * @return this (fluent interface) */ @@ -416,8 +416,7 @@ protected BuilderImpl withPrimaryElem() { /** * Specify the element to be a unique key. - * This is identical to calling - * withElemNull(true) and withElemDuplicates(false, true). + * This is identical to calling {@code withElemNull(true) and withElemDuplicates(false, true)}. * * @return this (fluent interface) */ @@ -989,7 +988,7 @@ static class KeyMap implements Serializable { * Note that we cannot use TreeMap as K may not be comparable. One of keysMap or keysList is used. */ Map keysMap; - /** Key storage if this is a KeyListImpl sorted by this key map, otherwise null */ + /** Key storage if this is a KeyListImpl sorted by this key map, otherwise null. One of keysMap or keysList is used. */ IList keysList; /** True to count only number of occurrences of equal elements (can only be set on keyMap[0] storing the elements) */ boolean count; @@ -1085,6 +1084,7 @@ boolean containsValue(Object key, Object value) { } if (obj instanceof KeyMapList) { + @SuppressWarnings("unchecked") GapList list = (GapList) obj; if (list.contains(value)) { return true; @@ -1105,6 +1105,7 @@ boolean containsValue(Object value) { assert (count == false); for (Object obj : keysMap.values()) { if (obj instanceof KeyMapList) { + @SuppressWarnings("unchecked") GapList list = (GapList) obj; if (list.contains(value)) { return true; @@ -1544,6 +1545,11 @@ Set getDistinctKeys() { return set; } } + + @Override + public String toString() { + return (keysMap != null) ? keysMap.toString() : keysList.toString(); + } } /** @@ -2287,6 +2293,7 @@ Option doRemove(Object elem, KeyMap ignore) { * * @return a copy of this collection */ + @Override public KeyCollectionImpl copy() { try { KeyCollectionImpl copy = (KeyCollectionImpl) super.clone(); @@ -2306,6 +2313,7 @@ public KeyCollectionImpl copy() { * * @return an empty copy of this collection */ + @Override public KeyCollectionImpl crop() { try { KeyCollectionImpl copy = (KeyCollectionImpl) super.clone(); @@ -2629,7 +2637,7 @@ private void doGetAllByKey(KeyMap keyMap, K key, Collection coll) { * * @param keyIndex key index * @param key key which elements must have - * @return number of elements with key (-1 if key is null) + * @return number of elements with key */ protected int getCountByKey(int keyIndex, Object key) { return getCountByKey(getKeyMap(keyIndex), key); @@ -2655,7 +2663,7 @@ private int getCountByKey(KeyMap keyMap, K key) { } else { Object obj = keyMap.keysMap.get(key); if (obj == null) { - return 0; + return (keyMap.keysMap.containsKey(key)) ? 1 : 0; } else if (obj instanceof KeyMapList) { GapList list = (GapList) obj; return list.size(); @@ -2851,7 +2859,7 @@ protected void removeAllByKey(int keyIndex, Object key, Collection removeds) for (int i = 0; i < keyMaps.length; i++) { if (i != keyIndex && keyMaps[i] != null) { Object k = keyMaps[i].getKey(elem); - keyMaps[i].doRemoveAllByKey(k, this, null); + keyMaps[i].remove(k, true, elem, this); } } afterDelete(elem); diff --git a/src/main/java/org/magicwerk/brownies/collections/KeySet.java b/src/main/java/org/magicwerk/brownies/collections/KeySet.java index 7e52033d..c3ed7521 100644 --- a/src/main/java/org/magicwerk/brownies/collections/KeySet.java +++ b/src/main/java/org/magicwerk/brownies/collections/KeySet.java @@ -222,14 +222,25 @@ public Builder withElemSort(Comparator comparator, boolean sortNul return (Builder) super.withElemSort(comparator, sortNullsFirst); } + /** + * {@inheritDoc} + *

+ * Note that a {@link Key2Set} always has an element set, so this call is not necessary. + */ @Override public Builder withPrimaryElem() { - return (Builder) super.withPrimaryElem(); + return this; } + /** + * {@inheritDoc} + *

+ * Note that a {@link KeySet} always has an element set, so an exception is thrown. + */ @Override public Builder withUniqueElem() { - return (Builder) super.withUniqueElem(); + KeyCollectionImpl.errorInvalidSetBehavior(); + return this; } } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/BooleanGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/BooleanGapList.java index 79f28864..288cc3c9 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/BooleanGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/BooleanGapList.java @@ -176,9 +176,7 @@ public static BooleanGapList create(Collection coll) { public static BooleanGapList create(boolean... elems) { BooleanGapList list = new BooleanGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(boolean[] values, int size) { + assert (size <= values.length); this.values = (boolean[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/ByteGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/ByteGapList.java index 6a3a370d..6466afb6 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/ByteGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/ByteGapList.java @@ -176,9 +176,7 @@ public static ByteGapList create(Collection coll) { public static ByteGapList create(byte... elems) { ByteGapList list = new ByteGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(byte[] values, int size) { + assert (size <= values.length); this.values = (byte[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/CharGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/CharGapList.java index 6705fef3..243a92da 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/CharGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/CharGapList.java @@ -176,9 +176,7 @@ public static CharGapList create(Collection coll) { public static CharGapList create(char... elems) { CharGapList list = new CharGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(char[] values, int size) { + assert (size <= values.length); this.values = (char[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/DoubleGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/DoubleGapList.java index c410173d..8ade79b2 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/DoubleGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/DoubleGapList.java @@ -176,9 +176,7 @@ public static DoubleGapList create(Collection coll) { public static DoubleGapList create(double... elems) { DoubleGapList list = new DoubleGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(double[] values, int size) { + assert (size <= values.length); this.values = (double[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/FloatGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/FloatGapList.java index 006b0130..4fc85994 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/FloatGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/FloatGapList.java @@ -176,9 +176,7 @@ public static FloatGapList create(Collection coll) { public static FloatGapList create(float... elems) { FloatGapList list = new FloatGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(float[] values, int size) { + assert (size <= values.length); this.values = (float[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IBooleanList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IBooleanList.java index 326d5ea0..2c96e5b6 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IBooleanList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IBooleanList.java @@ -371,12 +371,7 @@ static int hashCodeElem(boolean elem) { return (elem ? 1231 : 1237); } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(boolean elem) { int count = 0; int size = size(); @@ -1513,6 +1508,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(boolean... elems) { return doAddAll(-1, new IReadOnlyBooleanListFromArray(elems)); } @@ -1537,7 +1533,7 @@ public boolean addArray(int index, boolean[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, boolean... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") boolean... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyBooleanListFromArray(elems)); } @@ -1604,6 +1600,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, boolean... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1672,6 +1669,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, boolean... elems) { putAll(index, new IReadOnlyBooleanListFromArray(elems)); } @@ -1725,6 +1723,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(boolean... elems) { initAll(new IReadOnlyBooleanListFromArray(elems)); } @@ -1783,6 +1782,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, boolean... elems) { replaceAll(index, len, new IReadOnlyBooleanListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IByteList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IByteList.java index 60373f9b..4e19e424 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IByteList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IByteList.java @@ -370,12 +370,7 @@ static int hashCodeElem(byte elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(byte elem) { int count = 0; int size = size(); @@ -1512,6 +1507,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(byte... elems) { return doAddAll(-1, new IReadOnlyByteListFromArray(elems)); } @@ -1536,7 +1532,7 @@ public boolean addArray(int index, byte[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, byte... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") byte... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyByteListFromArray(elems)); } @@ -1603,6 +1599,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, byte... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1671,6 +1668,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, byte... elems) { putAll(index, new IReadOnlyByteListFromArray(elems)); } @@ -1724,6 +1722,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(byte... elems) { initAll(new IReadOnlyByteListFromArray(elems)); } @@ -1782,6 +1781,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, byte... elems) { replaceAll(index, len, new IReadOnlyByteListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/ICharList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/ICharList.java index 6a71b998..e4a566be 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/ICharList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/ICharList.java @@ -360,12 +360,7 @@ static int hashCodeElem(char elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(char elem) { int count = 0; int size = size(); @@ -1502,6 +1497,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(char... elems) { return doAddAll(-1, new IReadOnlyCharListFromArray(elems)); } @@ -1526,7 +1522,7 @@ public boolean addArray(int index, char[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, char... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") char... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyCharListFromArray(elems)); } @@ -1593,6 +1589,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, char... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1661,6 +1658,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, char... elems) { putAll(index, new IReadOnlyCharListFromArray(elems)); } @@ -1714,6 +1712,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(char... elems) { initAll(new IReadOnlyCharListFromArray(elems)); } @@ -1772,6 +1771,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, char... elems) { replaceAll(index, len, new IReadOnlyCharListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IDoubleList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IDoubleList.java index 0b186770..dfcdb589 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IDoubleList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IDoubleList.java @@ -371,12 +371,7 @@ static int hashCodeElem(double elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(double elem) { int count = 0; int size = size(); @@ -1513,6 +1508,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(double... elems) { return doAddAll(-1, new IReadOnlyDoubleListFromArray(elems)); } @@ -1537,7 +1533,7 @@ public boolean addArray(int index, double[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, double... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") double... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyDoubleListFromArray(elems)); } @@ -1604,6 +1600,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, double... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1672,6 +1669,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, double... elems) { putAll(index, new IReadOnlyDoubleListFromArray(elems)); } @@ -1725,6 +1723,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(double... elems) { initAll(new IReadOnlyDoubleListFromArray(elems)); } @@ -1783,6 +1782,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, double... elems) { replaceAll(index, len, new IReadOnlyDoubleListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IFloatList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IFloatList.java index a96b8fbb..df53da1b 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IFloatList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IFloatList.java @@ -371,12 +371,7 @@ static int hashCodeElem(float elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(float elem) { int count = 0; int size = size(); @@ -1513,6 +1508,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(float... elems) { return doAddAll(-1, new IReadOnlyFloatListFromArray(elems)); } @@ -1537,7 +1533,7 @@ public boolean addArray(int index, float[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, float... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") float... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyFloatListFromArray(elems)); } @@ -1604,6 +1600,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, float... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1672,6 +1669,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, float... elems) { putAll(index, new IReadOnlyFloatListFromArray(elems)); } @@ -1725,6 +1723,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(float... elems) { initAll(new IReadOnlyFloatListFromArray(elems)); } @@ -1783,6 +1782,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, float... elems) { replaceAll(index, len, new IReadOnlyFloatListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IIntList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IIntList.java index b2eb7814..e41adaa1 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IIntList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IIntList.java @@ -370,12 +370,7 @@ static int hashCodeElem(int elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(int elem) { int count = 0; int size = size(); @@ -1512,6 +1507,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(int... elems) { return doAddAll(-1, new IReadOnlyIntListFromArray(elems)); } @@ -1536,7 +1532,7 @@ public boolean addArray(int index, int[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, int... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") int... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyIntListFromArray(elems)); } @@ -1603,6 +1599,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, int... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1671,6 +1668,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, int... elems) { putAll(index, new IReadOnlyIntListFromArray(elems)); } @@ -1724,6 +1722,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(int... elems) { initAll(new IReadOnlyIntListFromArray(elems)); } @@ -1782,6 +1781,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, int... elems) { replaceAll(index, len, new IReadOnlyIntListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/ILongList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/ILongList.java index e08b8db6..d5a874ee 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/ILongList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/ILongList.java @@ -370,12 +370,7 @@ static int hashCodeElem(long elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(long elem) { int count = 0; int size = size(); @@ -1512,6 +1507,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(long... elems) { return doAddAll(-1, new IReadOnlyLongListFromArray(elems)); } @@ -1536,7 +1532,7 @@ public boolean addArray(int index, long[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, long... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") long... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyLongListFromArray(elems)); } @@ -1603,6 +1599,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, long... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1671,6 +1668,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, long... elems) { putAll(index, new IReadOnlyLongListFromArray(elems)); } @@ -1724,6 +1722,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(long... elems) { initAll(new IReadOnlyLongListFromArray(elems)); } @@ -1782,6 +1781,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, long... elems) { replaceAll(index, len, new IReadOnlyLongListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IShortList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IShortList.java index 32dce76f..0e2821cd 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IShortList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IShortList.java @@ -370,12 +370,7 @@ static int hashCodeElem(short elem) { return (int) elem; } - /** - * Counts how many times the specified element is contained in the list. - * - * @param elem element to count - * @return count how many times the specified element is contained in the list - */ + // See java.util.Collections.frequency(Collection, Object) public int count(short elem) { int count = 0; int size = size(); @@ -1512,6 +1507,7 @@ public boolean addAll(int index, Collection coll) { * @param elems elements to be added to this list * @return true if this list changed as a result of the call */ + @SuppressWarnings("unchecked") public boolean addArray(short... elems) { return doAddAll(-1, new IReadOnlyShortListFromArray(elems)); } @@ -1536,7 +1532,7 @@ public boolean addArray(int index, short[] elems, int offset, int length) { * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is invalid */ - public boolean addArray(int index, short... elems) { + public boolean addArray(int index, @SuppressWarnings("unchecked") short... elems) { checkIndexAdd(index); return doAddAll(index, new IReadOnlyShortListFromArray(elems)); } @@ -1603,6 +1599,7 @@ public void setAll(int index, Collection coll) { * @param elems array with elements to set * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void setArray(int index, short... elems) { int arrayLen = elems.length; checkRange(index, arrayLen); @@ -1671,6 +1668,7 @@ public void putAll(int index, Collection coll) { * @param index index of first element to set or add * @param elems array with elements to set or add */ + @SuppressWarnings("unchecked") public void putArray(int index, short... elems) { putAll(index, new IReadOnlyShortListFromArray(elems)); } @@ -1724,6 +1722,7 @@ public void initAll(Collection coll) { * @param elems array with elements * @throws IndexOutOfBoundsException if the length is invalid */ + @SuppressWarnings("unchecked") public void initArray(short... elems) { initAll(new IReadOnlyShortListFromArray(elems)); } @@ -1782,6 +1781,7 @@ public void replaceAll(int index, int len, Collection coll) { * @param elems array with elements which replace the old elements, use null if elements should only be removed * @throws IndexOutOfBoundsException if the range is invalid */ + @SuppressWarnings("unchecked") public void replaceArray(int index, int len, short... elems) { replaceAll(index, len, new IReadOnlyShortListFromArray(elems)); } diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/IntGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/IntGapList.java index f20a563c..41338e42 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/IntGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/IntGapList.java @@ -176,9 +176,7 @@ public static IntGapList create(Collection coll) { public static IntGapList create(int... elems) { IntGapList list = new IntGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(int[] values, int size) { + assert (size <= values.length); this.values = (int[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/LongGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/LongGapList.java index b318effd..76809b42 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/LongGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/LongGapList.java @@ -176,9 +176,7 @@ public static LongGapList create(Collection coll) { public static LongGapList create(long... elems) { LongGapList list = new LongGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(long[] values, int size) { + assert (size <= values.length); this.values = (long[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/java/org/magicwerk/brownies/collections/primitive/ShortGapList.java b/src/main/java/org/magicwerk/brownies/collections/primitive/ShortGapList.java index b557f66b..672898fb 100644 --- a/src/main/java/org/magicwerk/brownies/collections/primitive/ShortGapList.java +++ b/src/main/java/org/magicwerk/brownies/collections/primitive/ShortGapList.java @@ -176,9 +176,7 @@ public static ShortGapList create(Collection coll) { public static ShortGapList create(short... elems) { ShortGapList list = new ShortGapList(); if (elems != null) { - if (elems != null) { - list.init(elems); - } + list.init(elems); } return list; } @@ -419,11 +417,12 @@ boolean isNormalized() { * @param size new size */ void init(short[] values, int size) { + assert (size <= values.length); this.values = (short[]) values; this.size = size; start = 0; end = size; - if (end >= values.length) { + if (end == values.length) { end -= values.length; } gapSize = 0; diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF index de80efaf..1995a554 100644 --- a/src/main/resources/META-INF/MANIFEST.MF +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -4,14 +4,13 @@ Bundle-Description: Brownies Collections contains high-performance col Automatic-Module-Name: org.magicwerk.brownies.collections Bundle-License: https://www.apache.org/licenses/LICENSE-2.0.txt Bundle-SymbolicName: org.magicwerk.brownies.collections -Export-Package: org.magicwerk.brownies.collections;version="0.9.20-SNA - PSHOT",org.magicwerk.brownies.collections.exceptions;version="0.9.20- - SNAPSHOT",org.magicwerk.brownies.collections.helper;version="0.9.20-S - NAPSHOT",org.magicwerk.brownies.collections.helper.primitive;version= - "0.9.20-SNAPSHOT",org.magicwerk.brownies.collections.primitive;versio - n="0.9.20-SNAPSHOT" +Export-Package: org.magicwerk.brownies.collections;version="0.9.21",or + g.magicwerk.brownies.collections.exceptions;version="0.9.21",org.magi + cwerk.brownies.collections.helper;version="0.9.21",org.magicwerk.brow + nies.collections.helper.primitive;version="0.9.21",org.magicwerk.brow + nies.collections.primitive;version="0.9.21" Bundle-Name: Brownies-Collections -Bundle-Version: 0.9.20-SNAPSHOT +Bundle-Version: 0.9.21 Bundle-ManifestVersion: 2 Specification-Title: magicwerk.org Bundle-DocURL: http://www.magicwerk.org/collections diff --git a/src/test/java/org/magicwerk/brownies/collections/GapListTestPerformance.java b/src/test/java/org/magicwerk/brownies/collections/GapListTestPerformance.java index ac2e217e..4bf2f7fe 100644 --- a/src/test/java/org/magicwerk/brownies/collections/GapListTestPerformance.java +++ b/src/test/java/org/magicwerk/brownies/collections/GapListTestPerformance.java @@ -21,9 +21,9 @@ import org.magicwerk.brownies.core.logback.LogbackTools; import org.magicwerk.brownies.core.stat.NumberStat; import org.magicwerk.brownies.core.stat.StatValues.StoreValues; +import org.magicwerk.brownies.test.JavaEnvironment; import org.magicwerk.brownies.test.JmhRunner; import org.magicwerk.brownies.test.JmhRunner.Options; -import org.magicwerk.brownies.tools.dev.tools.JavaTools; import org.magicwerk.brownies.tools.runner.JvmRunner; import org.magicwerk.brownies.tools.runner.Runner; import org.openjdk.jmh.annotations.Benchmark; @@ -491,7 +491,7 @@ static void runJava(String[] args) { //String[] jvmArgs = new String[] { "-Xms512m", "-Xmx512m" }; String[] jvmArgs = new String[] { "-Xms1024m", "-Xmx1024m" }; - JavaTools bh = new JavaTools(); + JavaEnvironment bh = new JavaEnvironment(); runner.addJavaArgsRun(bh.getJava8Exe(), jvmArgs); //runner.addJavaArgsRun(bh.getJava11Exe(), jvmArgs); diff --git a/src/test/java/org/magicwerk/brownies/collections/GeneralPerformanceReport.java b/src/test/java/org/magicwerk/brownies/collections/GeneralPerformanceReport.java deleted file mode 100644 index a867007a..00000000 --- a/src/test/java/org/magicwerk/brownies/collections/GeneralPerformanceReport.java +++ /dev/null @@ -1,225 +0,0 @@ -package org.magicwerk.brownies.collections; - -import java.util.Comparator; -import java.util.List; -import java.util.TreeMap; - -import org.magicwerk.brownies.core.CollectionTools; -import org.magicwerk.brownies.core.MathTools; -import org.magicwerk.brownies.core.ObjectTools; -import org.magicwerk.brownies.core.StringTools; -import org.magicwerk.brownies.core.files.FilePath; -import org.magicwerk.brownies.core.files.FileTools; -import org.magicwerk.brownies.core.logback.LogbackTools; -import org.magicwerk.brownies.core.print.PrintTools; -import org.magicwerk.brownies.core.reflect.ClassTools; -import org.magicwerk.brownies.core.strings.StringPrinter; -import org.magicwerk.brownies.core.types.Type; -import org.magicwerk.brownies.core.values.Table; -import org.magicwerk.brownies.html.HtmlDoclet; -import org.magicwerk.brownies.html.HtmlReport; -import org.magicwerk.brownies.html.HtmlTable; -import org.magicwerk.brownies.html.StyleResource; -import org.magicwerk.brownies.html.content.HtmlChartCreator; -import org.magicwerk.brownies.html.content.HtmlChartCreator.ChartType; -import org.magicwerk.brownies.html.content.HtmlTableFormatter; -import org.magicwerk.brownies.test.JmhRunner.BenchmarkJsonParser; -import org.magicwerk.brownies.test.JmhRunner.BenchmarkJsonResult; -import org.magicwerk.brownies.test.JmhRunner.BenchmarkJsonResult.BenchmarkTrial; -import org.slf4j.Logger; - -public class GeneralPerformanceReport { - - public static class BenchmarkFile { - String classifier; - FilePath file; - - public BenchmarkFile(String classifier, FilePath file) { - this.classifier = classifier; - this.file = file; - } - } - - static final Logger LOG = LogbackTools.getLogger(); - - static final String CLASSIFIER = "classifier"; - - /** Result of benchmark run (representing one line of text in result output) */ - static class Result { - String classifier; - String benchmark; - double score; - - Result(BenchmarkTrial bt) { - classifier = getClassifier(bt); - benchmark = getBenchmark(bt); - score = bt.getScore(); - } - - String getClassifier(BenchmarkTrial bt) { - return bt.getParams().get(CLASSIFIER); - } - - String getBenchmark(BenchmarkTrial bt) { - TreeMap params = new TreeMap<>(bt.getParams()); - params.remove(CLASSIFIER); - StringPrinter buf = new StringPrinter().setElemMarker("-"); - - String title = ClassTools.getLocalNameByDot(bt.getBenchmark()); - title = StringTools.removeHeadIf(title, "test_"); - buf.add(title); - - params.values().forEach(v -> buf.add(v)); - return buf.toString(); - } - - } - - // Configuration - IList files; - Comparator sortClassifiers; - Comparator sortBenchmarks; - - // State - HtmlReport report; - IList rs; - IList classifiers; - IList benchmarks; - - // - - /** Setter for {@link #files} */ - public GeneralPerformanceReport setFiles(IList files) { - this.files = files; - return this; - } - - HtmlReport createHtmlReport() { - HtmlReport report = new HtmlReport(); - report.add(StyleResource.INSTANCE); - report.setHtmlFile("output/benchmarks.html"); - return report; - } - - public void showTables() { - report = createHtmlReport(); - readBenchmarks(); - renderTables(); - report.showHtml(); - } - - public void showCharts() { - report = createHtmlReport(); - readBenchmarks(); - renderCharts(); - report.showHtml(); - } - - void renderTables() { - renderTable(rs, ""); - } - - void renderTable(IList rs, String size) { - Table tab = getTable(rs); - HtmlTable ht = renderTable(tab); - ht.setId("benchmark-performance-" + size); - report.add(ht); - } - - void renderCharts() { - renderChart(rs, ""); - } - - void renderChart(IList rs, String size) { - Table tab = getTable(rs); - LOG.info("{}", tab); - HtmlDoclet doc = getChartDoc(tab); - report.add(doc); - } - - HtmlDoclet getChartDoc(Table tab) { - String title = PrintTools.toString(tab.getColName(0), ""); - - HtmlChartCreator creator = new HtmlChartCreator(); - creator.setTitle(title); - creator.setWidth("960px"); - creator.setHeight("720px"); - creator.setTable(tab); - creator.setChartType(ChartType.COLUMN); - creator.setValueAxisLog(false); - - HtmlDoclet hd = creator.getChart(); - return hd; - } - - HtmlTable renderTable(Table tab) { - HtmlTableFormatter htf = new HtmlTableFormatter(); - HtmlTable ht = htf.format(tab); - return ht; - } - - Table getTable(IList rs) { - Table tab = getTableHeader(rs); - - for (String benchmark : benchmarks) { - IList row = GapList.create(); - row.add(benchmark); - - IList scores = GapList.create(); - for (String classifier : classifiers) { - GeneralPerformanceReport.Result r = rs.getIf( - n -> ObjectTools.equals(n.classifier, classifier) && ObjectTools.equals(n.benchmark, benchmark)); - scores.add(r.score); - } - - row.addAll(scores); - tab.addRowElems(row); - } - return tab; - } - - static void normalizeNumbers(List vals) { - double min = MathTools.min(vals); - for (int i = 0; i < vals.size(); i++) { - vals.set(i, vals.get(i) / min); - } - } - - Table getTableHeader(IList trs) { - Table tab = new Table(); - - tab.addCol("Benchmark", Type.STRING_TYPE); - - for (String classifier : classifiers) { - tab.addCol(classifier, Type.DOUBLE_TYPE); - } - return tab; - } - - /** - * Read benchmark files. - */ - void readBenchmarks() { - rs = doReadBenchmarks(); - - classifiers = CollectionTools.getDistinct(rs.map(r -> r.classifier)); - classifiers.sort(sortClassifiers); - benchmarks = CollectionTools.getDistinct(rs.map(r -> r.benchmark)); - benchmarks.sort(sortBenchmarks); - } - - IList doReadBenchmarks() { - IList rs = GapList.create(); - for (BenchmarkFile file : files) { - String text = FileTools.readFile().setFile(file.file).readText(); - BenchmarkJsonResult br = new BenchmarkJsonParser().parse(text); - for (BenchmarkTrial bt : br.getResults()) { - Result r = new GeneralPerformanceReport.Result(bt); - r.classifier = file.classifier; - rs.add(r); - } - } - return rs; - } - -} diff --git a/src/test/java/org/magicwerk/brownies/collections/Key2ListTest.java b/src/test/java/org/magicwerk/brownies/collections/Key2ListTest.java index 881647b9..38e665c3 100644 --- a/src/test/java/org/magicwerk/brownies/collections/Key2ListTest.java +++ b/src/test/java/org/magicwerk/brownies/collections/Key2ListTest.java @@ -19,12 +19,15 @@ import java.util.List; import java.util.Map; +import java.util.Set; import org.magictest.client.Assert; import org.magictest.client.Capture; import org.magictest.client.Trace; import org.magicwerk.brownies.collections.TestHelper.Ticket; +import org.magicwerk.brownies.core.CheckTools; import org.magicwerk.brownies.core.logback.LogbackTools; +import org.magicwerk.brownies.core.objects.Pair; import org.magicwerk.brownies.core.strings.StringPrinter; import org.slf4j.Logger; @@ -42,7 +45,8 @@ public static void main(String[] args) { } static void test() { - testAsMap(); + testRemoveAllByKey1(); + //testAsMap(); //testInvalidate(); //testKey2List(); } @@ -53,6 +57,36 @@ public TicketList() { } } + @Trace + public static void testRemoveAllByKey1() { + Key2List, String, String> pairs = new Key2List.Builder, String, String>() + .withKey1Map(Pair::getFirst).withKey2Map(Pair::getLast).build(); + pairs.add(Pair.of("A", "B1")); + pairs.add(Pair.of("A", "B2")); + pairs.add(Pair.of("B1", "B2")); + check(pairs); + + pairs.removeAllByKey1("A"); + check(pairs); + } + + static void check(KeyListImpl list) { + IList elems = GapList.create(list); + + int numKeys = list.keyColl.keyMaps.length; + for (int i = 1; i < numKeys; i++) { + IList e1s = GapList.create(); + @SuppressWarnings("unchecked") + Set k1s = (Set) list.getDistinctKeys(i); + for (Object k1 : k1s) { + e1s.addAll(list.getAllByKey(i, k1)); + } + CheckTools.check(e1s.size() == elems.size()); + e1s.removeAll(elems); + CheckTools.check(e1s.isEmpty()); + } + } + @Trace(traceClass = "org.magicwerk.brownies.collections.Key2ListTest$TicketList", traceMethod = "/.*/", parameters = Trace.ALL_PARAMS | Trace.THIS, result = Trace.THIS | Trace.RESULT) public static void testExtends() { diff --git a/src/test/java/org/magicwerk/brownies/collections/KeyCollectionTest.java b/src/test/java/org/magicwerk/brownies/collections/KeyCollectionTest.java index ef95a1d1..2c05011b 100644 --- a/src/test/java/org/magicwerk/brownies/collections/KeyCollectionTest.java +++ b/src/test/java/org/magicwerk/brownies/collections/KeyCollectionTest.java @@ -541,6 +541,12 @@ public static void testKey() { coll.add(a); coll.removeAll(a); + coll.add(n); + coll.getCount(n); + + coll.add(n); + coll.getCount(n); + Report.printStep("-- Sort --"); coll = getCollectionSort(); coll.getAll(d); diff --git a/src/test/java/org/magicwerk/brownies/collections/ListTestPerformance.java b/src/test/java/org/magicwerk/brownies/collections/ListTestPerformance.java index 1d94bd7f..65e6dc28 100644 --- a/src/test/java/org/magicwerk/brownies/collections/ListTestPerformance.java +++ b/src/test/java/org/magicwerk/brownies/collections/ListTestPerformance.java @@ -24,8 +24,8 @@ import org.magicwerk.brownies.core.values.Table; import org.magicwerk.brownies.html.HtmlTable; import org.magicwerk.brownies.test.JmhRunner; +import org.magicwerk.brownies.test.JavaEnvironment.JavaVersion; import org.magicwerk.brownies.test.JmhRunner.Options; -import org.magicwerk.brownies.tools.dev.tools.JavaTools.JavaVersion; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Param; @@ -64,7 +64,7 @@ void runBenchmarks() { /** Run benchmarks, results in ListTestPerformance.json / ListTestPerformance.log */ void runBenchmarkOp(boolean fast) { - Options opts = configure(fast); + Options opts = configure(); opts.includeMethod(ListTest.class, "testGet"); opts.includeMethod(ListTest.class, "testAdd"); opts.includeMethod(ListTest.class, "testRemove"); @@ -77,17 +77,11 @@ void runBenchmarkOp(boolean fast) { runner.runJmh(opts); } - Options configure(boolean fast) { + Options configure() { Options opts = new Options(); - if (fast) { - opts.setWarmupIterations(0); - opts.setMeasurementIterations(1); - opts.setRunTimeMillis(100); - } else { - opts.setWarmupIterations(25); - opts.setMeasurementIterations(25); - opts.setRunTimeMillis(100); - } + opts.setWarmupIterations(25); + opts.setMeasurementIterations(25); + opts.setRunTimeMillis(100); opts.setJvmArgs(jvmArgs); opts.setJavaVersion(JavaVersion.JAVA_8); @@ -101,12 +95,13 @@ Options configure(boolean fast) { /** Run benchmarks, results in ListTestCopyPerformance.json / ListTestCopyPerformance.log */ void runBenchmarkCopy(boolean fast) { - Options opts = configure(fast); + Options opts = configure(); opts.includeMethod(ListTest.class, "testCopy"); opts.setResultFile("output/ListTestCopyPerformance.json"); opts.setLogFile("output/ListTestCopyPerformance.log"); JmhRunner runner = new JmhRunner(); + runner.setFastMode(fast); runner.runJmh(opts); } @@ -114,6 +109,8 @@ void runBenchmarkCopy(boolean fast) { public static class ListTest { + // Benchmarks executed by runBenchmarkOp() (with params "op", "type", "size") + @Benchmark public Object testGet(GetListState state) { List list = state.list(); @@ -141,6 +138,8 @@ public Object testRemove(RemoveListState state) { return state; } + // Benchmarks executed by runBenchmarkCopy() (with params "type", "size") + @Benchmark public Object testCopy(CopyListState state) { List list = state.list(); @@ -450,8 +449,11 @@ static UnaryOperator getCopyOperation(String type) { void showBenchmark() { ListTestPerformanceReport sb = new MyListTestPerformanceReport(); - sb.showCharts(); - //sb.showTables(); + + //sb.showCharts(); + + // Create tables as shown on http://www.magicwerk.org/page-collections-documentation.html + sb.showTables(); } /** diff --git a/src/test/java/org/magicwerk/brownies/collections/ListTestPerformanceReport.java b/src/test/java/org/magicwerk/brownies/collections/ListTestPerformanceReport.java index eaf9746e..9e448173 100644 --- a/src/test/java/org/magicwerk/brownies/collections/ListTestPerformanceReport.java +++ b/src/test/java/org/magicwerk/brownies/collections/ListTestPerformanceReport.java @@ -37,11 +37,15 @@ import org.magicwerk.brownies.html.content.HtmlFormatters; import org.magicwerk.brownies.html.content.HtmlFormatters.ConditionalFormatter; import org.magicwerk.brownies.html.content.HtmlTableFormatter; +import org.magicwerk.brownies.test.JmhRunner.BenchmarkFileResult; import org.magicwerk.brownies.test.JmhRunner.BenchmarkJsonParser; -import org.magicwerk.brownies.test.JmhRunner.BenchmarkJsonResult; -import org.magicwerk.brownies.test.JmhRunner.BenchmarkJsonResult.BenchmarkTrial; +import org.magicwerk.brownies.test.JmhRunner.BenchmarkResult; import org.slf4j.Logger; +/** + * Class {@link ListTestPerformance} provides a report for the benchmark results created by {@link ListTestPerformance.ListTest}. + * It therefore specially supports the params "op", "type", "size". + */ public class ListTestPerformanceReport { static final Logger LOG = LogbackTools.getLogger(); @@ -64,7 +68,7 @@ static class Result { /** Benchmark value {@literal @Param} size */ String size; - Result(BenchmarkTrial bt) { + Result(BenchmarkResult bt) { benchmark = convertBenchmark(bt.getBenchmark()); score = bt.getScore(); Map p = bt.getParams(); @@ -312,10 +316,10 @@ void readBenchmarks() { } IList doReadBenchmarks() { - IList brs = GapList.create(); + IList brs = GapList.create(); for (FilePath file : files) { String text = FileTools.readFile().setFile(file).readText(); - BenchmarkJsonResult br = new BenchmarkJsonParser().parse(text); + BenchmarkFileResult br = new BenchmarkJsonParser().parse(text); brs.addAll(br.getResults()); } IList rs = brs.map(ListTestPerformanceReport.Result::new); diff --git a/src/test/java/org/magicwerk/brownies/collections/RunDebugTest.java b/src/test/java/org/magicwerk/brownies/collections/RunDebugTest.java index 2e81b7ca..a229d476 100644 --- a/src/test/java/org/magicwerk/brownies/collections/RunDebugTest.java +++ b/src/test/java/org/magicwerk/brownies/collections/RunDebugTest.java @@ -20,6 +20,8 @@ /** * Run tests with DEBUG_CHECK enabled. *

+ * Before running, make sure that you executed 'gradle compileJava' as the class files are referenced (e.g. Brownies-Core/build/classes/java/main) + *

* - Copy current sources from "src" into "build/tmp/runDebugTest"
* - Set constant DEBUG_CHECK to true
* - Check that assertions would fail on problems by running RunDebugTestCheck (expected to fail)
@@ -49,7 +51,7 @@ void checkDependencies() { GradleTool gradleTool = new GradleTool(); IList deps = gradleTool.getDependencies("testCompileClasspath"); // TODO check dependencies against text in buildGradle - LOG.info("Check that dependencies are still up-to-date:\n{}", StringPrinter.formatLines(deps)); + LOG.info("Check that class files are built (gradle compileJava) and dependencies are still up-to-date:\n{}", StringPrinter.formatLines(deps)); } void assertDebugTestFails() { diff --git a/src/test/java/org/magicwerk/brownies/collections/dev/BuildManifest.java b/src/test/java/org/magicwerk/brownies/collections/dev/BuildManifest.java index 37b9c31f..34d80b50 100644 --- a/src/test/java/org/magicwerk/brownies/collections/dev/BuildManifest.java +++ b/src/test/java/org/magicwerk/brownies/collections/dev/BuildManifest.java @@ -104,11 +104,14 @@ void run() { static final Pattern MAVEN_REFERENCE_PATTERN = Pattern.compile("(?m)(?<=^mavenReference: )(.*)(?=\\R)"); static final Pattern MAVEN_VERSION_PATTERN = Pattern.compile(".*:(.*)"); + /** Returns current project version, e.g. "0.9.21-SNAPSHOT" */ String getMavenVersion() { String cmd = "gradle printMavenReference"; ExecStatus status = new Exec().setUseShell(true).setPrintOutput(true).setArgLine(cmd).setThrowOnError(true).execute(); String out = status.getMessage(); + // out: several lines, one being "mavenReference: org.magicwerk.brownies:brownies-collections:0.9.21-SNAPSHOT" String ref = RegexTools.get(MAVEN_REFERENCE_PATTERN, out); + // ref: org.magicwerk.brownies:brownies-collections:0.9.21-SNAPSHOT return RegexTools.get(MAVEN_VERSION_PATTERN, ref); } diff --git a/src/test/java/org/magicwerk/brownies/collections/dev/BuildSource.java b/src/test/java/org/magicwerk/brownies/collections/dev/BuildSource.java index 119c3f51..ddc5223e 100644 --- a/src/test/java/org/magicwerk/brownies/collections/dev/BuildSource.java +++ b/src/test/java/org/magicwerk/brownies/collections/dev/BuildSource.java @@ -23,7 +23,7 @@ /** * Create Java source files for brownies-collections. *

- * - Brownies-Collections:
+ * - Brownies-Collections (src/main/java):
* collections\primitive\IBooleanList.java
* collections\primitive\BooleanGapList.java
* collections\primitive\BooleanObjGapList.java
@@ -32,8 +32,11 @@ * collections\helper\primitive\BooleanBinarySearch.java
* collections\primitive\BooleanObjBigList.java
*

- * - Brownies-Collections-Test
+ * - Brownies-Collections-Test (src/test/java):
* collections\BigListGapListTest.java
+ *

+ * - Manifest (src/main/resources):
+ * META-INF/MANIFEST.MF
* * @author Thomas Mauch */ @@ -256,9 +259,9 @@ public static void main(String[] args) { } void run() { - // Generate in src/main/java + // Generate source in in src/main/java, src/test/java buildSource(); - // Generate in src/main/resources + // Generate manifest in src/main/resources new BuildManifest().run(); } @@ -280,7 +283,7 @@ void buildSource() { // buildTest = new BuildSourceTest("IntObjGapList"); // buildTest.build(); - // FileTools.writeFile(buildTest.getFile(), buildTest.getFileContent()); + // writeFile(buildTest.getFile(), buildTest.getFileContent()); buildTest = new BuildSourceTest("BigList"); buildTest.build();