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 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.schema; 020 021import static java.lang.Boolean.FALSE; 022 023import org.nuxeo.common.xmap.annotation.XNode; 024import org.nuxeo.common.xmap.annotation.XNodeList; 025import org.nuxeo.common.xmap.annotation.XObject; 026 027/** 028 * Facet Descriptor. 029 */ 030@XObject("facet") 031public class FacetDescriptor { 032 033 @XNode("@name") 034 public String name; 035 036 @XNode("@perDocumentQuery") 037 public Boolean perDocumentQuery; 038 039 @XNode("@enabled") 040 public Boolean enabled; 041 042 @XNodeList(value = "schema", type = SchemaDescriptor[].class, componentType = SchemaDescriptor.class) 043 public SchemaDescriptor[] schemas; 044 045 /* empty constructor needed by XMap */ 046 public FacetDescriptor() { 047 } 048 049 public FacetDescriptor(String name, SchemaDescriptor[] schemas) { 050 this.name = name; 051 this.schemas = schemas == null ? new SchemaDescriptor[0] : schemas; 052 } 053 054 public String getName() { 055 return name; 056 } 057 058 @Override 059 public String toString() { 060 return "Facet(" + name + (FALSE.equals(enabled) ? ",disabled," : ",") 061 + SchemaDescriptor.getSchemaNames(schemas) + ')'; 062 } 063 064}