aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/container/component/UserBindingPattern.java
blob: 182eca835c1e185c0c38cf8c427945ed0f1fa3d5 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.component;

/**
 * A {@link BindingPattern} which is constructed directly from a user provided 'binding' element from services.xml.
 *
 * @author bjorncs
 */
public class UserBindingPattern extends BindingPattern {

    private UserBindingPattern(String scheme, String host, String port, String path) { super(scheme, host, port, path); }
    private UserBindingPattern(String binding) { super(binding); }

    public static UserBindingPattern fromHttpPath(String path) { return new UserBindingPattern("http", "*", null, path); }
    public static UserBindingPattern fromPattern(String binding) { return new UserBindingPattern(binding); }
    public UserBindingPattern withPort(int port) { return new UserBindingPattern(scheme(), host(), Integer.toString(port), path()); }

    @Override
    public String toString() {
        return "UserBindingPattern{" +
                "scheme='" + scheme() + '\'' +
                ", host='" + host() + '\'' +
                ", port='" + port().orElse(null) + '\'' +
                ", path='" + path() + '\'' +
                '}';
    }
}