private void validate(String serviceSpec, String profile) throws HyscaleException {
        if (StringUtils.isBlank(serviceSpec)) {
            throw new HyscaleException(ServiceSpecErrorCodes.SERVICE_SPEC_REQUIRED);
        }
        if (StringUtils.isBlank(profile)) {
            throw new HyscaleException(ServiceSpecErrorCodes.SERVICE_PROFILE_REQUIRED);
        }
        ObjectMapper mapper;
        if (ServiceInputType.JSON == this.serviceInputType) {
            mapper = ObjectMapperFactory.jsonMapper();
        } else {
            mapper = ObjectMapperFactory.yamlMapper();
        }
        try {
            mapper.readTree(serviceSpec);
        } catch (IOException e) {
            WorkflowLogger.error(ServiceSpecActivity.ERROR, e.getMessage());
            throw new HyscaleException(e,ServiceSpecErrorCodes.SERVICE_SPEC_PARSE_ERROR);
        }
        try {
            mapper.readTree(profile);
        } catch (IOException e) {
            WorkflowLogger.error(ServiceSpecActivity.ERROR, e.getMessage());
            throw new HyscaleException(e,ServiceSpecErrorCodes.SERVICE_PROFILE_PARSE_ERROR);
        }
    }
Builder to create effective service spec by merging service spec and service profile
@author tushar
service-spec/service-spec-commons/src/main/java/io/hyscale/servicespec/commons/builder/EffectiveServiceSpecBuilder.java