aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/derived/FieldResultTransform.java
blob: 99b2925d714ab5769f9dbb22215722c9cf8cd3a9 (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
55
56
57
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;

import com.yahoo.vespa.documentmodel.SummaryTransform;

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

    private final String fieldName;

    private SummaryTransform transform;

    private final 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();
    }

    @Override
    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);
    }

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

}