001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.transform;
014
015/**
016 * Bean property filter.
017 *
018 * @deprecated Use {@link BeanInterceptor}.
019 */
020@Deprecated
021public class PropertyFilter {
022
023   /**
024    * Default reusable property filter instance.
025    */
026   public static final PropertyFilter DEFAULT = new PropertyFilter();
027
028   /**
029    * Property read interceptor.
030    *
031    * <p>
032    * Subclasses can override this property to convert property values to some other object just before serialization.
033    *
034    * <h5 class='section'>Example:</h5>
035    * <p class='bcode w800'>
036    *    <jc>// Address filter that strips out sensitive information.</jc>
037    *    <jk>public class</jk> AddressPropertyFilter <jk>extends</jk> PropertyFilter {
038    *
039    *       <jk>public</jk> Object readProperty(Object bean, String name, Object value) {
040    *          <jk>if</jk> (<js>"taxInfo"</js>.equals(name))
041    *             <jk>return</jk> <js>"redacted"</js>;
042    *          <jk>return</jk> value;
043    *       }
044    *    }
045    * </p>
046    *
047    * @param bean The bean from which the property was read.
048    * @param name The property name.
049    * @param value The value just extracted from calling the bean getter.
050    * @return The value to serialize.  Default is just to return the existing value.
051    */
052   public Object readProperty(Object bean, String name, Object value) {
053      return value;
054   }
055
056   /**
057    * Property write interceptor.
058    *
059    * <p>
060    * Subclasses can override this property to convert property values to some other object just before calling the
061    * bean setter.
062    *
063    * <h5 class='section'>Example:</h5>
064    * <p class='bcode w800'>
065    *    <jc>// Address filter that strips out sensitive information.</jc>
066    *    <jk>public class</jk> AddressPropertyFilter <jk>extends</jk> PropertyFilter {
067    *
068    *       <jk>public</jk> Object writeProperty(Object bean, String name, Object value) {
069    *          AddressBook a = (Address)bean;
070    *          <jk>if</jk> (<js>"taxInfo"</js>.equals(name) &amp;&amp; <js>"redacted"</js>.equals(value))
071    *             <jk>return</jk> TaxInfoUtils.<jsm>lookup</jsm>(a.getStreet(), a.getCity(), a.getState());
072    *          <jk>return</jk> value;
073    *       }
074    *    }
075    * </p>
076    *
077    * @param bean The bean from which the property was read.
078    * @param name The property name.
079    * @param value The value just parsed.
080    * @return The value to serialize.  Default is just to return the existing value.
081    */
082   public Object writeProperty(Object bean, String name, Object value) {
083      return value;
084   }
085}