aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/component/chain/model/ComponentAdaptor.java
blob: 082a5ce5977f38405c19637a4bdb72a0800974d1 (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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.component.chain.model;

import com.yahoo.component.AbstractComponent;
import com.yahoo.component.ComponentId;

/**
 * For using non-component model classes with ComponentRegistry.
 *
 * @author Tony Vaagenes
 */
public final class ComponentAdaptor<T> extends AbstractComponent {

    public final T model;

    @SuppressWarnings("deprecation")
    public ComponentAdaptor(ComponentId globalComponentId, T model) {
        super(globalComponentId);
        this.model = model;
    }

    public static <T> ComponentAdaptor<T> create(ComponentId globalComponentId, T model) {
        return new ComponentAdaptor<>(globalComponentId, model);
    }

    // For testing
    T model() {
        return model;
    }

}