use of com.github.havardh.javaflow.model.CanonicalName in project javaflow by havardh.
the class MemberFieldsPresentVerifier method verify.
/**
* Verifies that there are no missing types referenced
* in the list of {@code Type}.
*
* A missing type is found when a type is referenced which is not
* in the given set of types of in the {@code TypeMap} of the verifier
* If a any missing types are discovered a {@code MissingTypeException}
* is thrown containing the complete list of missing types.
*
* @param types list of {@code Type} to verify
* @throws MissingTypeException when a missing type is found
*/
@Override
public void verify(List<Type> types) {
Set<CanonicalName> nameSet = types.stream().map(Type::getCanonicalName).collect(toSet());
Map<Type, List<Field>> missingTypes = new HashMap<>();
for (Type type : types.stream().filter(t -> t instanceof Class).collect(toList())) {
((Class) type).getFields().stream().filter(field -> !nameSet.contains(field.getType().getCanonicalName())).filter(field -> !isObject(field.getType().toString())).filter(field -> !isPrimitive(field.getType().toString())).filter(field -> !customTypes.containsKey(field.getType().toString())).forEach(field -> missingTypes.compute(type, (ignored, fields) -> fields == null ? singletonList(field) : concat(fields, singletonList(field))));
}
if (!missingTypes.isEmpty()) {
throw new MissingTypeException(missingTypes);
}
}
Aggregations