private Set<TypeToken<?>> getTypeTokens(Permazen jdb, Class<?> context, int storageId, int parentStorageId) { final HashSet<TypeToken<?>> contextFieldTypes = new HashSet<>(); for (JClass<?> jclass : jdb.jclasses.values()) { // Check if jclass is under consideration if (!context.isAssignableFrom(jclass.type)) continue; // Find the simple field field in jclass, if it exists JSimpleField simpleField = null; if (parentStorageId != 0) { final JComplexField parentField = (JComplexField)jclass.jfields.get(parentStorageId); if (parentField != null) simpleField = parentField.getSubField(storageId); } else simpleField = (JSimpleField)jclass.jfields.get(storageId); if (simpleField == null) continue; // Add field's type in jclass contextFieldTypes.add(simpleField.typeToken); } if (contextFieldTypes.isEmpty()) { throw new IllegalArgumentException("no sub-type of " + context + " contains and indexed simple field with storage ID " + storageId); } return Util.findLowestCommonAncestors(contextFieldTypes); }
description = "sub-field `" + subFieldName + "' of complex " + description; try { matchingField = superField.getSubField(subFieldName); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("invalid " + description + ": " + e.getMessage(), e);