001/*
002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Thierry Delprat
018 */
019package org.nuxeo.apidoc.introspection;
020
021import java.util.ArrayList;
022import java.util.List;
023
024import org.nuxeo.apidoc.api.BaseNuxeoArtifact;
025import org.nuxeo.apidoc.api.SeamComponentInfo;
026
027import com.fasterxml.jackson.annotation.JsonIgnoreType;
028
029@JsonIgnoreType
030public class SeamComponentInfoImpl extends BaseNuxeoArtifact implements SeamComponentInfo {
031
032    protected String name;
033
034    protected String scope;
035
036    protected String precedence;
037
038    protected String className;
039
040    protected final List<String> interfaceNames = new ArrayList<>();
041
042    protected String version;
043
044    @Override
045    public String getName() {
046        return name;
047    }
048
049    @Override
050    public String getScope() {
051        return scope;
052    }
053
054    @Override
055    public String getPrecedence() {
056        return precedence;
057    }
058
059    @Override
060    public String getClassName() {
061        return className;
062    }
063
064    public void addInterfaceName(String name) {
065        if (!interfaceNames.contains(name)) {
066            interfaceNames.add(name);
067        }
068    }
069
070    @Override
071    public List<String> getInterfaceNames() {
072        return interfaceNames;
073    }
074
075    @Override
076    public String getArtifactType() {
077        return SeamComponentInfo.TYPE_NAME;
078    }
079
080    @Override
081    public String getId() {
082        return "seam:" + getName();
083    }
084
085    @Override
086    public String getHierarchyPath() {
087        return "/";
088    }
089
090    @Override
091    public String getVersion() {
092        return version;
093    }
094
095    public void setVersion(String version) {
096        this.version = version;
097    }
098
099    @Override
100    public int compareTo(SeamComponentInfo o) {
101        int c = getName().compareToIgnoreCase(o.getName());
102        if (c != 0) {
103            return c;
104        }
105        return getClassName().compareTo(o.getClassName());
106    }
107
108    public void setName(String name) {
109        this.name = name;
110    }
111
112    public void setScope(String scope) {
113        this.scope = scope;
114    }
115
116    public void setPrecedence(String precedence) {
117        this.precedence = precedence;
118    }
119
120    public void setClassName(String className) {
121        this.className = className;
122    }
123
124}