class ServiceClassParser {

    public ServiceModel parseServiceClass(Class<?> mainServiceClass, TypescriptServiceGeneratorConfiguration settings, Class<?>... serviceClassesToMerge) {
        List<Class<?>> serviceClazzes = Lists.newArrayList(mainServiceClass);
        serviceClazzes.addAll(Lists.newArrayList(serviceClassesToMerge));
        ImmutableServiceModel.Builder serviceModel = ImmutableServiceModel.builder();
        serviceModel.name(mainServiceClass.getSimpleName());
        for (Class<?> serviceClass : serviceClazzes) {
            ImmutableInnerServiceModel.Builder innerServiceModel = ImmutableInnerServiceModel.builder();
            Path servicePathAnnotation = serviceClass.getAnnotation(Path.class);
            innerServiceModel.servicePath(servicePathAnnotation == null ? "" : PathUtils.trimSlashes(servicePathAnnotation.value()));
            innerServiceModel.name(serviceClass.getSimpleName());

            Set<Method> serviceMethods = getAllServiceMethods(serviceClass, settings.methodFilter());
            // find and stores all types that are referenced by this service
            Set<Type> referencedTypes = Sets.newHashSet();
            for (Method method : serviceMethods) {
                referencedTypes.addAll(getTypesFromEndpoint(method, settings));
            }
            serviceModel.addAllReferencedTypes(referencedTypes);

            ModelCompiler compiler = new TypeScriptGenerator(settings.getSettings()).getModelCompiler();

            List<ServiceEndpointModel> endpointModels = Lists.newArrayList();
            endpointModels = computeEndpointModels(serviceMethods, compiler, settings);

            Collections.sort(endpointModels);
            innerServiceModel.endpointModels(endpointModels);
            serviceModel.addInnerServiceModels(innerServiceModel.build());
        }
        return serviceModel.build();
    }

}