| 174 | |
| 175 | public static class List9 implements Job { |
| 176 | @Override |
| 177 | public void run(BValue value) { |
| 178 | /// logger.info("List9: {}", value.objectId()); |
| 179 | var list = value.getList9(); |
| 180 | var forceRemove = list.size() >= 3; |
| 181 | if (forceRemove) { |
| 182 | list.remove(getRandom().nextInt(list.size())); |
| 183 | } else { |
| 184 | switch (getRandom().nextInt(3)) { |
| 185 | case 0: // insert |
| 186 | if (list.isEmpty()) |
| 187 | list.add(new Bean1()); |
| 188 | else |
| 189 | list.add(getRandom().nextInt(list.size()), new Bean1()); |
| 190 | break; |
| 191 | |
| 192 | case 1: // remove |
| 193 | if (!list.isEmpty()) |
| 194 | list.remove(getRandom().nextInt(list.size())); |
| 195 | break; |
| 196 | |
| 197 | case 2: // modify. |
| 198 | if (list.isEmpty()) |
| 199 | list.add(new Bean1()); // ensure modify |
| 200 | var randItem = list.get(getRandom().nextInt(list.size())); |
| 201 | randItem.setV1(getRandom().nextInt()); |
| 202 | break; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | public static class Set10 implements Job { |