001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Antoine Taillefer 016 */ 017package org.nuxeo.ecm.diff.model; 018 019/** 020 * Property type constants: string, boolean, integer, scalarList, complex, complexList, ... 021 * 022 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a> 023 */ 024public final class PropertyType { 025 026 public static final String UNDEFINED = "undefined"; 027 028 public static final String STRING = "string"; 029 030 public static final String BOOLEAN = "boolean"; 031 032 public static final String DATE = "date"; 033 034 public static final String INTEGER = "integer"; 035 036 public static final String LONG = "long"; 037 038 public static final String DOUBLE = "double"; 039 040 public static final String CONTENT = "content"; 041 042 public static final String SCALAR_LIST = "scalarList"; 043 044 public static final String COMPLEX = "complex"; 045 046 public static final String COMPLEX_LIST = "complexList"; 047 048 public static final String CONTENT_LIST = "contentList"; 049 050 /** 051 * Avoid instantiating a new property type. 052 */ 053 private PropertyType() { 054 } 055 056 /** 057 * Checks if is simple type. 058 * 059 * @param propertyType the property type 060 * @return true, if is simple type 061 */ 062 public static boolean isSimpleType(String propertyType) { 063 064 return !isListType(propertyType) && !isComplexType(propertyType) && !isContentType(propertyType); 065 } 066 067 /** 068 * Checks if is list type. 069 * 070 * @param propertyType the property type 071 * @return true, if is list type 072 */ 073 public static boolean isListType(String propertyType) { 074 075 return SCALAR_LIST.equals(propertyType) || COMPLEX_LIST.equals(propertyType) 076 || CONTENT_LIST.equals(propertyType); 077 } 078 079 /** 080 * Checks if is scalar list type. 081 * 082 * @param propertyType the property type 083 * @return true, if is scalar list type 084 */ 085 public static boolean isScalarListType(String propertyType) { 086 087 return SCALAR_LIST.equals(propertyType); 088 } 089 090 /** 091 * Checks if is complex list type. 092 * 093 * @param propertyType the property type 094 * @return true, if is complex list type 095 */ 096 public static boolean isComplexListType(String propertyType) { 097 098 return COMPLEX_LIST.equals(propertyType); 099 } 100 101 /** 102 * Checks if is content list type. 103 * 104 * @param propertyType the property type 105 * @return true, if is content list type 106 */ 107 public static boolean isContentListType(String propertyType) { 108 109 return CONTENT_LIST.equals(propertyType); 110 } 111 112 /** 113 * Checks if is complex type. 114 * 115 * @param propertyType the property type 116 * @return true, if is complex type 117 */ 118 public static boolean isComplexType(String propertyType) { 119 120 return COMPLEX.equals(propertyType); 121 } 122 123 /** 124 * Checks if is content type. 125 * 126 * @param propertyType the property type 127 * @return true, if is content type 128 */ 129 public static boolean isContentType(String propertyType) { 130 131 return CONTENT.equals(propertyType); 132 } 133 134}