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
027public class SeamComponentInfoImpl extends BaseNuxeoArtifact implements SeamComponentInfo {
028
029    protected String name;
030
031    protected String scope;
032
033    protected String precedence;
034
035    protected String className;
036
037    protected final List<String> interfaceNames = new ArrayList<String>();
038
039    protected String version;
040
041    @Override
042    public String getName() {
043        return name;
044    }
045
046    @Override
047    public String getScope() {
048        return scope;
049    }
050
051    @Override
052    public String getPrecedence() {
053        return precedence;
054    }
055
056    @Override
057    public String getClassName() {
058        return className;
059    }
060
061    public void addInterfaceName(String name) {
062        if (!interfaceNames.contains(name)) {
063            interfaceNames.add(name);
064        }
065    }
066
067    @Override
068    public List<String> getInterfaceNames() {
069        return interfaceNames;
070    }
071
072    @Override
073    public String getArtifactType() {
074        return SeamComponentInfo.TYPE_NAME;
075    }
076
077    @Override
078    public String getId() {
079        return "seam:" + getName();
080    }
081
082    @Override
083    public String getHierarchyPath() {
084        return "/";
085    }
086
087    @Override
088    public String getVersion() {
089        return version;
090    }
091
092    public void setVersion(String version) {
093        this.version = version;
094    }
095
096    @Override
097    public int compareTo(SeamComponentInfo o) {
098        int c = getName().compareToIgnoreCase(o.getName());
099        if (c != 0) {
100            return c;
101        }
102        return getClassName().compareTo(o.getClassName());
103    }
104
105    public void setName(String name) {
106        this.name = name;
107    }
108
109    public void setScope(String scope) {
110        this.scope = scope;
111    }
112
113    public void setPrecedence(String precedence) {
114        this.precedence = precedence;
115    }
116
117    public void setClassName(String className) {
118        this.className = className;
119    }
120
121}