All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hp.autonomy.searchcomponents.hod.configuration.QueryManipulationConfig Maven / Gradle / Ivy

/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.searchcomponents.hod.configuration;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.hp.autonomy.frontend.configuration.ConfigException;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

@Data
public class QueryManipulationConfig {
    public static final String SECTION = "queryManipulation";

    private final String profile;
    private final String index;

    public QueryManipulationConfig(
            @JsonProperty("profile") final String profile,
            @JsonProperty("index") final String index
    ) {
        this.profile = profile;
        this.index = index;
    }

    public QueryManipulationConfig merge(final QueryManipulationConfig other) {
        if (other == null) {
            return this;
        }

        return new QueryManipulationConfig(
                profile == null ? other.profile : profile,
                index == null ? other.index : index
        );
    }

    public void basicValidate() throws ConfigException {
        if (StringUtils.isBlank(profile)) {
            throw new ConfigException(SECTION, "Query profile is required");
        }

        if (StringUtils.isBlank(index)) {
            throw new ConfigException(SECTION, "Query manipulation index is required");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy