001/* 002 * (C) Copyright 2006-2009 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 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.types; 023 024import java.util.ArrayList; 025import java.util.Arrays; 026import java.util.List; 027 028import org.nuxeo.common.xmap.annotation.XNode; 029import org.nuxeo.common.xmap.annotation.XObject; 030 031/** 032 * Type view to display a given document sub-type. 033 * 034 * @author <a href="mailto:cbaican@nuxeo.com">Catalin Baican</a> 035 */ 036@XObject("type") 037public class SubType { 038 039 @XNode 040 protected String name; 041 042 protected List<String> hidden; 043 044 public List<String> getHidden() { 045 if (hidden == null) { 046 hidden = new ArrayList<>(); 047 } 048 return hidden; 049 } 050 051 @XNode("@hidden") 052 public void setHidden(String value) { 053 String[] hiddenCases = value.split("(\\s+)(?=[^,])|(\\s*,\\s*)"); 054 hidden = new ArrayList<>(Arrays.asList(hiddenCases)); 055 } 056 057 public String getName() { 058 return name; 059 } 060 061 public void setName(String name) { 062 this.name = name; 063 } 064 065 /** 066 * Clone method to handle hot reload 067 * 068 * @since 5.6 069 */ 070 @Override 071 protected SubType clone() { 072 SubType clone = new SubType(); 073 clone.setName(getName()); 074 List<String> hidden = getHidden(); 075 if (hidden != null) { 076 List<String> chidden = new ArrayList<>(); 077 chidden.addAll(hidden); 078 clone.hidden = chidden; 079 } 080 return clone; 081 } 082}