001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.xbean.spring.generator; 018 019 /** 020 * @author Dain Sundstrom 021 * @version $Id$ 022 * @since 1.0 023 */ 024 public class AttributeMapping implements Comparable { 025 private final String attributeName; 026 private final String propertyName; 027 private final String description; 028 private final Type type; 029 private final String value; 030 private final boolean fixed; 031 private final boolean required; 032 private final String propertyEditor; 033 034 public AttributeMapping(String attributeName, String propertyName, String description, Type type, String value, boolean fixed, boolean required, String propertyEditor) { 035 this.propertyEditor = propertyEditor; 036 if (attributeName == null) throw new NullPointerException("attributeName"); 037 if (propertyName == null) throw new NullPointerException("propertyName"); 038 if (type == null) throw new NullPointerException("type"); 039 this.attributeName = attributeName; 040 this.propertyName = propertyName; 041 if (description == null) description = ""; 042 this.description = description; 043 this.type = type; 044 this.value = value; 045 this.fixed = fixed; 046 this.required = required; 047 } 048 049 public String getAttributeName() { 050 return attributeName; 051 } 052 053 public String getPropertyName() { 054 return propertyName; 055 } 056 057 public String getDescription() { 058 return description; 059 } 060 061 public Type getType() { 062 return type; 063 } 064 065 public String getValue() { 066 return value; 067 } 068 069 public boolean isFixed() { 070 return fixed; 071 } 072 073 public boolean isRequired() { 074 return required; 075 } 076 077 public int hashCode() { 078 return attributeName.hashCode(); 079 } 080 081 public boolean equals(Object obj) { 082 if (obj instanceof AttributeMapping) { 083 return attributeName.equals(((AttributeMapping) obj).attributeName); 084 } 085 return false; 086 } 087 088 public int compareTo(Object obj) { 089 return attributeName.compareTo(((AttributeMapping) obj).attributeName); 090 } 091 092 public String getPropertyEditor() { 093 return propertyEditor; 094 } 095 }