aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/derived/FieldResultTransform.java
blob: 232d80d59b45aad3cc2134168805b10c90c9a494 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;

import com.yahoo.vespa.documentmodel.SummaryTransform;

/**
 * The result transformation of a named field
 *
 * @author  bratseth
 */
public class FieldResultTransform {

    private String fieldName;

    private SummaryTransform transform;

    private String argument;

    public FieldResultTransform(String fieldName,SummaryTransform transform,String argument) {
        this.fieldName=fieldName;
        this.transform=transform;
        this.argument = argument;
    }

    public String getFieldName() { return fieldName; }

    public SummaryTransform getTransform() { return transform; }

    public void setTransform(SummaryTransform transform) { this.transform=transform; }

    /** Returns the argument of this (used as input to the backend docsum rewriter) */
    public String getArgument() { return argument; }

    public int hashCode() {
        return fieldName.hashCode() + 11*transform.hashCode() + 17* argument.hashCode();
    }

    public boolean equals(Object o) {
        if (! (o instanceof FieldResultTransform)) return false;
        FieldResultTransform other=(FieldResultTransform)o;

        return
            this.fieldName.equals(other.fieldName) &&
            this.transform.equals(other.transform) &&
            this.argument.equals(other.argument);
    }

    public String toString() {
        String sourceString="";
        if ( ! argument.equals(fieldName))
            sourceString=" (argument: " + argument + ")";
        return "field " + fieldName + ": " + transform + sourceString;
    }
}