public Object construct()

in bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptor.java [104:134]


    public Object construct(InvocationContext context) throws Exception {
        final Constructor ctor = context.getConstructor();
        if (!isConstructorValidated(ctor)) {
            return context.proceed();
        }
        final ConstructorDescriptor constraints = validator.getConstraintsForClass(ctor.getDeclaringClass())
            .getConstraintsForConstructor(ctor.getParameterTypes());

        if (!DescriptorManager.isConstrained(constraints)) {
            return context.proceed();
        }
        initExecutableValidator();

        if (constraints.hasConstrainedParameters()) {
            final Set<ConstraintViolation<?>> violations =
                executableValidator.validateConstructorParameters(ctor, context.getParameters());
            if (!violations.isEmpty()) {
                throw new ConstraintViolationException(violations);
            }
        }
        final Object result = context.proceed();

        if (constraints.hasConstrainedReturnValue()) {
            final Set<ConstraintViolation<?>> violations =
                executableValidator.validateConstructorReturnValue(ctor, context.getTarget());
            if (!violations.isEmpty()) {
                throw new ConstraintViolationException(violations);
            }
        }
        return result;
    }