All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.squeakysand.commons.beans.RemotePropertyDescriptor Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2010-2012 Craig S. Dickson (http://craigsdickson.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squeakysand.commons.beans;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Class to support the remote description of a Bean. This class mimics the {@link
 * java.beans.PropertyDescriptor} except that it is Serializable.
 *
 * @author Craig S. Dickson
 */
public class RemotePropertyDescriptor implements Serializable {

    private static final long serialVersionUID = -7725572608686617837L;
    private static final Logger LOG = LoggerFactory.getLogger(RemotePropertyDescriptor.class);

    /** The display name of the property. */
    private String displayName;

    /** The name of the property. */
    private String name;

    /** The Class of the editor to use for the property. */
    private Class propertyEditorClass;

    /** The Class of the property. */
    private Class propertyType;

    /** A displayable description of the property. */
    private String shortDescription;

    /**
     * Creates a new RemotePropertyDescriptor object.
     *
     * @param name                the property name.
     * @param displayName         String to use to label the property in the UI
     * @param propertyType        The Java type of the property.
     * @param propertyEditorClass The editor to use for this property
     * @param shortDescription    A displayable description of the property
     */
    public RemotePropertyDescriptor(String name, String displayName, Class propertyType, Class propertyEditorClass, String shortDescription) {
        super();
        this.name = name;
        this.displayName = displayName;
        // ###### BIG PROBLEM!!!! Can't seem to serialize the Class of a primitive type
        // Uncomment is for now so that UI won't null.  If UI get trouble for primtive type,
        // I can convert it to wrapper class.
        this.propertyType = propertyType;
        LOG.debug("propertyType: {}", propertyType.getName());
        this.propertyEditorClass = propertyEditorClass;
        this.shortDescription = shortDescription;
    }

    /**
     * Accessor for the displayName property.
     *
     * @return the current value of the displayName property.
     */
    public String getDisplayName() {
        return displayName;
    }

    /**
     * Accessor for the name property.
     *
     * @return the current value of the name property.
     */
    public String getName() {
        return name;
    }

    /**
     * Accessor for the propertyEditorClass property.
     *
     * @return the current value of the propertyEditorClass property.
     */
    public Class getPropertyEditorClass() {
        return propertyEditorClass;
    }

    /**
     * Accessor for the propertyType property.
     *
     * @return the current value of the propertyType property.
     */
    public Class getPropertyType() {
        return propertyType;
    }

    /**
     * Accessor for the shortDescription property.
     *
     * @return the current value for the shortDescription property.
     */
    public String getShortDescription() {
        return shortDescription;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy