- if (keyDefinition != null) {
- for (final QName keyDef : keyDefinition) {
- listKeys.add(keyDef.getLocalName());
- }
- }
- return listKeys;
- }
-
- /**
- * Generates for the <code>list</code> which contains any list keys special generated TO builder.
- *
- * @param packageName string with package name to which the list belongs
- * @param list list schema node which is source of data about the list name
- * @return generated TO builder which represents the keys of the <code>list</code> or null if <code>list</code> is
- * null or list of key definitions is null or empty.
- */
- private GeneratedTOBuilder resolveListKeyTOBuilder(final ModuleContext context, final ListSchemaNode list) {
- if (list.getKeyDefinition() != null && !list.getKeyDefinition().isEmpty()) {
- return typeProvider.newGeneratedTOBuilder(JavaTypeName.create(
- packageNameForGeneratedType(context.modulePackageName(), list.getPath()),
- BindingMapping.getClassName(list.getQName().getLocalName() + "Key")));
+ switch (keyDefinition.size()) {
+ case 0:
+ return Collections.emptyList();
+ case 1:
+ return Collections.singletonList(keyDefinition.get(0).getLocalName());
+ default:
+ final List<String> listKeys = new ArrayList<>(keyDefinition.size());
+ for (final QName keyDef : keyDefinition) {
+ listKeys.add(keyDef.getLocalName());
+ }
+ return listKeys;