aboutsummaryrefslogtreecommitdiffstats
path: root/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/Property.java
blob: c52efb6028fa9e7881bed084e88331507e501a74 (plain)
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
40
41
42
43
44
45
46
47
48
package org.openecomp.sdc.toscaparser.api;

import java.util.Objects;

import org.openecomp.sdc.toscaparser.jython.JyProperty;
import org.openecomp.sdc.toscaparser.utils.PythonUtils;

import com.google.common.base.MoreObjects;

public class Property {
    
    private final JyProperty jyProperty;
    
    public Property(JyProperty jyProperty) {
        this.jyProperty = Objects.requireNonNull(jyProperty);
    }
    
    public String getName() {
        return jyProperty.getJyName();
    }
    
    public Object getValue() {
        return PythonUtils.cast(jyProperty.getJyValue(), jyProperty.getJyValueClassName());
    }
    
    public String getType() {
        return jyProperty.getJyType();
    }
    
    public boolean isRequired() {
        return jyProperty.isJyRequired();
    }
    
    public String getDescription() {
        return jyProperty.getJyDescription();
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("name", getName())
                .add("type", getType())
                .add("required", isRequired())
                .add("description", getDescription())
                .add("value", getValue())
                .toString();
    }
}