001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 */
016package org.kuali.rice.krad.datadictionary.parse;
017
018import java.lang.reflect.Type;
019
020/**
021 * Data storage class for information related to a single property of a defined custom tag.
022 *
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 */
025public class BeanTagAttributeInfo {
026    private String name;
027    private String propertyName;
028    private BeanTagAttribute.AttributeType type;
029    private Class<?> valueType;
030    private Type genericType;
031
032    /**
033     * Constructor initializing the global variables
034     */
035    public BeanTagAttributeInfo() {
036        name = null;
037        type = null;
038    }
039
040    /**
041     * Retrieves the name of the property in the schema (tag or attribute).
042     *
043     * @return name of property in schema
044     */
045    public String getName() {
046        return name;
047    }
048
049    /**
050     * @see BeanTagAttributeInfo#getName()
051     */
052    public void setName(String name) {
053        this.name = name;
054    }
055
056    /**
057     * Name of the property in the component class.
058     *
059     * @return property name
060     */
061    public String getPropertyName() {
062        return propertyName;
063    }
064
065    /**
066     * @see BeanTagAttributeInfo#getPropertyName()
067     */
068    public void setPropertyName(String propertyName) {
069        this.propertyName = propertyName;
070    }
071
072    /**
073     * Retrieves the type of information being stored.
074     * This is the type of information being stored and is used to decide how to parse the information in the xml.
075     *
076     * @return The type of information being stored by the tag.
077     */
078    public BeanTagAttribute.AttributeType getType() {
079        return type;
080    }
081
082    /**
083     * Sets the type of information being stored by the property.
084     *
085     * @param type - The type of information being stored by the property.
086     */
087    public void setType(BeanTagAttribute.AttributeType type) {
088        this.type = type;
089    }
090
091    /**
092     * The value type (class or primitive type) of the is attribute
093     *
094     * @return the value type
095     */
096    public Class<?> getValueType() {
097        return valueType;
098    }
099
100    /**
101     * Set the value type
102     *
103     * @param valueType
104     */
105    public void setValueType(Class<?> valueType) {
106        this.valueType = valueType;
107    }
108
109    /**
110     * Gets the type of the generic on the attribute's value type (only matters for lists)
111     *
112     * @return the genericType
113     */
114    public Type getGenericType() {
115        return genericType;
116    }
117
118    /**
119     * Set the generic type
120     *
121     * @param genericType
122     */
123    public void setGenericType(Type genericType) {
124        this.genericType = genericType;
125    }
126
127    /**
128     * Returns true if valueType, type, and name match
129     *
130     * @param obj
131     * @return true if valueType, type, and name match
132     */
133    @Override
134    public boolean equals(Object obj) {
135        if (obj instanceof BeanTagAttributeInfo) {
136            return valueType.equals(((BeanTagAttributeInfo) obj).getValueType()) && type.equals(
137                    ((BeanTagAttributeInfo) obj).getType()) && name.equals(((BeanTagAttributeInfo) obj).getName());
138        } else {
139            return false;
140        }
141    }
142}