aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/UnproperSearch.java
blob: 71d3db6616b6166377fb7e440c4e94de1e51b11d (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;

import com.yahoo.searchdefinition.document.SDDocumentType;

/**
 * A search that was derived from an sd file containing no search element(s), only
 * document specifications.
 *
 * @author vegardh
 *
 */
 // Award for best class name goes to ...
public class UnproperSearch extends Search {
    // This class exists because the parser accepts SD files without search { ... , and
    // there are unit tests using it too, BUT there are many nullpointer bugs if you try to
    // deploy such a file. Using this class to try to catch those.
    // TODO: Throw away this when we properly support doc-only SD files.

    public UnproperSearch() {
        // empty
    }

    @Override
    public void addDocument(SDDocumentType docType) {
        if (getName() == null) {
            setName(docType.getName());
        }
        super.addDocument(docType);
    }
}