aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/RankingExpressionBody.java
blob: da1255aaa7a7118370ff0b2f0bcaf6a673ba053a (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema;

import com.yahoo.config.application.api.FileRegistry;

import java.nio.ByteBuffer;

import static java.util.Objects.requireNonNull;

public class RankingExpressionBody extends DistributableResource {

    private final ByteBuffer blob;

    public RankingExpressionBody(String name, ByteBuffer blob) {
        super(name, name + ".lz4", PathType.BLOB);
        this.blob = requireNonNull(blob, "Blob cannot be null");
    }

    public ByteBuffer getBlob() { return blob; }

    public void validate() {
        // Remove once pathType is final
        if (getPathType() != PathType.BLOB) {
            throw new IllegalArgumentException("PathType must be BLOB.");
        }
    }

    public void register(FileRegistry fileRegistry) {
        register(fileRegistry, blob);
    }

}