001/* 002 * (C) Copyright 2010 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 * Anahide Tchertchian 018 */ 019package org.nuxeo.ecm.platform.forms.layout.api.impl; 020 021import org.nuxeo.ecm.platform.forms.layout.api.FieldDefinition; 022 023/** 024 * @author Anahide Tchertchian 025 * @since 5.4 026 */ 027public class FieldDefinitionImpl implements FieldDefinition { 028 029 private static final long serialVersionUID = 1L; 030 031 protected String schema; 032 033 protected String field; 034 035 // needed by GWT serialization 036 protected FieldDefinitionImpl() { 037 } 038 039 public FieldDefinitionImpl(String schema, String field) { 040 this.schema = schema; 041 this.field = field; 042 } 043 044 public String getSchemaName() { 045 return schema; 046 } 047 048 public String getFieldName() { 049 return field; 050 } 051 052 public String getPropertyName() { 053 if (schema == null || schema.length() == 0) { 054 return field; 055 } else { 056 return schema + ":" + field; 057 } 058 } 059 060 @Override 061 public FieldDefinition clone() { 062 return new FieldDefinitionImpl(schema, field); 063 } 064 065 /** 066 * @since 7.1 067 */ 068 @Override 069 public String toString() { 070 final StringBuilder buf = new StringBuilder(); 071 072 buf.append("FieldDefinitionImpl"); 073 buf.append(" {"); 074 buf.append(" schema="); 075 buf.append(schema); 076 buf.append(", field="); 077 buf.append(field); 078 buf.append('}'); 079 080 return buf.toString(); 081 } 082 083 /** 084 * @since 7.2 085 */ 086 @Override 087 public boolean equals(Object obj) { 088 if (!(obj instanceof FieldDefinitionImpl)) { 089 return false; 090 } 091 if (obj == this) { 092 return true; 093 } 094 FieldDefinitionImpl fd = (FieldDefinitionImpl) obj; 095 return new EqualsBuilder().append(schema, fd.schema).append(field, fd.field).isEquals(); 096 } 097 098}