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

import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.builder.xml.ConfigModelId;
import com.yahoo.vespa.model.clients.Clients;
import org.w3c.dom.Element;

import java.util.Arrays;
import java.util.List;

/**
 * Builds the Clients plugin
 *
 * @author hmusum
 */
public class DomClientsBuilder extends LegacyConfigModelBuilder<Clients> {

    public DomClientsBuilder() {
        super(Clients.class);
    }

    @Override
    public List<ConfigModelId> handlesElements() {
        return Arrays.asList(ConfigModelId.fromNameAndVersion("clients", "2.0"));
    }

    @Override
    public void doBuild(Clients clients, Element clientsE, ConfigModelContext modelContext) {
        String version = clientsE.getAttribute("version");
        if (version.startsWith("2.")) {
            DomV20ClientsBuilder parser = new DomV20ClientsBuilder(clients, version);
            parser.build(clientsE);
        } else {
            throw new IllegalArgumentException("Version '" + version + "' of 'clients' not supported.");
        }
    }

}