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