class EntityUtils {

    public static Class<?> getEntityClassFromNodeLabels(final List<String> labels, final List<Class<?>> classes)
            throws NoSuchClassException {
        for (final String label : labels) {
            final Optional<Class<?>> classHit = classes.stream().filter(c -> {
                // try to find the class based on its name
                if (c.getName().endsWith(label)) {
                    return true;
                } else {
                    // try to find the class based on the @Table(name) settings
                    final Table annotation = c.getAnnotation(Table.class);
                    return annotation != null && annotation.name().equals(label);
                }
            }).findFirst();

            if (classHit.isPresent()) {
                return classHit.get();
            }
        }

        throw new NoSuchClassException("could not find class for a node with " + labels + " labels.");
    }

    private  EntityUtils();

}