001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 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-2.1.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 * Thomas Roger <troger@nuxeo.com> 016 */ 017 018package org.nuxeo.ecm.platform.content.template.service; 019 020import org.nuxeo.common.xmap.annotation.XNode; 021import org.nuxeo.common.xmap.annotation.XObject; 022 023/** 024 * Descriptor of a registered {@link PostContentCreationHandler}. 025 * 026 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 027 * @since 5.5 028 */ 029@XObject("postContentCreationHandler") 030public class PostContentCreationHandlerDescriptor implements Cloneable, 031 Comparable<PostContentCreationHandlerDescriptor> { 032 033 @XNode("@name") 034 private String name; 035 036 @XNode("@class") 037 private Class<PostContentCreationHandler> clazz; 038 039 @XNode("@order") 040 private int order = 0; 041 042 @XNode("@enabled") 043 private boolean enabled = true; 044 045 public String getName() { 046 return name; 047 } 048 049 public Class<PostContentCreationHandler> getClazz() { 050 return clazz; 051 } 052 053 public int getOrder() { 054 return order; 055 } 056 057 public boolean isEnabled() { 058 return enabled; 059 } 060 061 public void setName(String name) { 062 this.name = name; 063 } 064 065 public void setClazz(Class<PostContentCreationHandler> clazz) { 066 this.clazz = clazz; 067 } 068 069 public void setOrder(int order) { 070 this.order = order; 071 } 072 073 public void setEnabled(boolean enabled) { 074 this.enabled = enabled; 075 } 076 077 /* 078 * Override the Object.clone to make it public 079 */ 080 @Override 081 public Object clone() throws CloneNotSupportedException { 082 return super.clone(); 083 } 084 085 @Override 086 public int compareTo(PostContentCreationHandlerDescriptor o) { 087 int cmp = order - o.order; 088 if (cmp == 0) { 089 // make sure we have a deterministic sort 090 cmp = name.compareTo(o.name); 091 } 092 return cmp; 093 } 094}