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

it.tidalwave.metadata.persistence.spi.BeanAccessorSupport Maven / Gradle / Ivy

The newest version!
/***********************************************************************************************************************
 *
 * blueMarine Metadata - open source media workflow
 * Copyright (C) 2007-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * 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.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://bluemarine.tidalwave.it
 * SCM: https://kenai.com/hg/bluemarine~metadata-src
 *
 **********************************************************************************************************************/
package it.tidalwave.metadata.persistence.spi;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/*******************************************************************************
 *
 * This class provides partial support for implementing a {@link BeanAccessor}.
 * 
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 ******************************************************************************/
public abstract class BeanAccessorSupport implements BeanAccessor
  {
    @Nonnull 
    private final Class itemClass;

    @Nonnull 
    private final String propertySetName;
    
    /***************************************************************************
     *
     * Creates this object passing the class of the represented item and the name
     * of the property set.
     * 
     * @param  itemClass        the class of the represented item
     * @param  propertySetName  the name of the property set
     * 
     **************************************************************************/
    public BeanAccessorSupport (@Nonnull final Class itemClass,
                                @Nonnull final String propertySetName) 
      {
        this.itemClass = itemClass;
        this.propertySetName = propertySetName;
      }
    
    /***************************************************************************
     *
     * {@inheritDoc}. This implementation always returns true.
     * 
     **************************************************************************/
    public boolean isPersistent (@Nonnull final String propertyName) 
      {
        return true;
      }

    /***************************************************************************
     *
     * {@inheritDoc}
     * 
     **************************************************************************/
    @Nonnull 
    public final String getPropertySetName()  
      {
        return propertySetName;
      }
    
    /***************************************************************************
     *
     * {@inheritDoc}. This implementation returns the passed value with no
     * conversion.
     *  
     **************************************************************************/
    @CheckForNull
    public Object convertValueToPersistence (@Nonnull final String propertyName,
                                             @CheckForNull final Object value) 
      throws UnknownPropertyException
      {
        return value;
      }

    /***************************************************************************
     *
     * {@inheritDoc}. This implementation returns the passed value with no
     * conversion.
     * 
     **************************************************************************/
    @CheckForNull
    public Object convertValueFromPersistence (@Nonnull final String propertyName, 
                                               @CheckForNull final Object value)
      throws UnknownPropertyException
      {
        return value;
      }   

    /***************************************************************************
     * 
     * {@inheritDoc}. This implementation returns the passed propertyName with no
     * conversion.
     *
     **************************************************************************/
    @Nonnull
    public String convertPropertyNameToPersistence (@Nonnull final String propertyName) 
      throws UnknownPropertyException
      {
        return propertyName;
      }

    /***************************************************************************
     *
     * {@inheritDoc}. This implementation returns the passed propertyName with no
     * conversion.
     * 
     **************************************************************************/
    @Nonnull
    public String convertPropertyNameFromPersistence (@Nonnull final String propertyName) 
      {
        return propertyName;
      }
    
    /***************************************************************************
     *
     **************************************************************************/
    @Nonnull
    protected Class getItemClass()
      {
        return itemClass;    
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy