001/*
002 * (C) Copyright 2012 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 *     Antoine Taillefer
018 */
019package org.nuxeo.ecm.diff.model;
020
021/**
022 * Property type constants: string, boolean, integer, scalarList, complex, complexList, ...
023 *
024 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a>
025 */
026public final class PropertyType {
027
028    public static final String UNDEFINED = "undefined";
029
030    public static final String STRING = "string";
031
032    public static final String BOOLEAN = "boolean";
033
034    public static final String DATE = "date";
035
036    public static final String INTEGER = "integer";
037
038    public static final String LONG = "long";
039
040    public static final String DOUBLE = "double";
041
042    public static final String CONTENT = "content";
043
044    public static final String SCALAR_LIST = "scalarList";
045
046    public static final String COMPLEX = "complex";
047
048    public static final String COMPLEX_LIST = "complexList";
049
050    public static final String CONTENT_LIST = "contentList";
051
052    /**
053     * Avoid instantiating a new property type.
054     */
055    private PropertyType() {
056    }
057
058    /**
059     * Checks if is simple type.
060     *
061     * @param propertyType the property type
062     * @return true, if is simple type
063     */
064    public static boolean isSimpleType(String propertyType) {
065
066        return !isListType(propertyType) && !isComplexType(propertyType) && !isContentType(propertyType);
067    }
068
069    /**
070     * Checks if is list type.
071     *
072     * @param propertyType the property type
073     * @return true, if is list type
074     */
075    public static boolean isListType(String propertyType) {
076
077        return SCALAR_LIST.equals(propertyType) || COMPLEX_LIST.equals(propertyType)
078                || CONTENT_LIST.equals(propertyType);
079    }
080
081    /**
082     * Checks if is scalar list type.
083     *
084     * @param propertyType the property type
085     * @return true, if is scalar list type
086     */
087    public static boolean isScalarListType(String propertyType) {
088
089        return SCALAR_LIST.equals(propertyType);
090    }
091
092    /**
093     * Checks if is complex list type.
094     *
095     * @param propertyType the property type
096     * @return true, if is complex list type
097     */
098    public static boolean isComplexListType(String propertyType) {
099
100        return COMPLEX_LIST.equals(propertyType);
101    }
102
103    /**
104     * Checks if is content list type.
105     *
106     * @param propertyType the property type
107     * @return true, if is content list type
108     */
109    public static boolean isContentListType(String propertyType) {
110
111        return CONTENT_LIST.equals(propertyType);
112    }
113
114    /**
115     * Checks if is complex type.
116     *
117     * @param propertyType the property type
118     * @return true, if is complex type
119     */
120    public static boolean isComplexType(String propertyType) {
121
122        return COMPLEX.equals(propertyType);
123    }
124
125    /**
126     * Checks if is content type.
127     *
128     * @param propertyType the property type
129     * @return true, if is content type
130     */
131    public static boolean isContentType(String propertyType) {
132
133        return CONTENT.equals(propertyType);
134    }
135
136}