001/* 002 * (C) Copyright 2011 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 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.platform.forms.layout.descriptors; 018 019import java.io.Serializable; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.common.xmap.annotation.XNodeList; 023import org.nuxeo.common.xmap.annotation.XObject; 024 025/** 026 * @since 5.5 027 */ 028@XObject("layoutConverter") 029public class LayoutConverterDescriptor implements Serializable, Comparable<LayoutConverterDescriptor> { 030 031 private static final long serialVersionUID = 1L; 032 033 @XNode("@name") 034 String name; 035 036 @XNode("@order") 037 int order = 0; 038 039 @XNode("converter-class") 040 String converterClassName; 041 042 @XNodeList(value = "categories/category", type = String[].class, componentType = String.class) 043 String[] categories = new String[0]; 044 045 public String getName() { 046 return name; 047 } 048 049 public String getConverterClassName() { 050 return converterClassName; 051 } 052 053 public String[] getCategories() { 054 return categories; 055 } 056 057 public int getOrder() { 058 return order; 059 } 060 061 @Override 062 public int compareTo(LayoutConverterDescriptor otherConverter) { 063 int cmp = order - otherConverter.order; 064 if (cmp == 0) { 065 // make sure we have a deterministic sort 066 cmp = name.compareTo(otherConverter.name); 067 } 068 return cmp; 069 } 070 071}