001/*
002 * (C) Copyright 2006-2007 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 *     Jean-Marc Orliaguet, Chalmers
018 *
019 * $Id$
020 */
021
022package org.nuxeo.theme.formats;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026import org.nuxeo.theme.relations.DefaultPredicate;
027import org.nuxeo.theme.relations.Predicate;
028import org.nuxeo.theme.types.Type;
029import org.nuxeo.theme.types.TypeFamily;
030
031@XObject("format")
032public final class FormatType implements Type {
033
034    @XNode("@name")
035    public String name;
036
037    @XNode("class")
038    public String className;
039
040    @XNode("predicate")
041    public String predicateName;
042
043    private Predicate predicate;
044
045    public FormatType() {
046    }
047
048    public FormatType(String name, String predicateName, String className) {
049        this.name = name;
050        this.predicateName = predicateName;
051        this.className = className;
052    }
053
054    public TypeFamily getTypeFamily() {
055        return TypeFamily.FORMAT;
056    }
057
058    public String getTypeName() {
059        return name;
060    }
061
062    public String getFormatClass() {
063        return className;
064    }
065
066    public Predicate getPredicate() {
067        if (predicate == null) {
068            predicate = new DefaultPredicate(predicateName);
069        }
070        return predicate;
071    }
072
073}