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    
018    package org.apache.commons.jexl2.introspection;
019    
020    /**
021     * Interface used for setting values that appear to be properties.
022     * Ex.
023     * <code>
024     * ${foo.bar = "hello"}
025     * </code>
026     * @since 1.0
027     */
028    public interface JexlPropertySet {
029        /**
030         * Method used to set the property value of an object.
031         * 
032         * @param obj Object on which the property setter will be called with the value
033         * @param arg value to be set
034         * @return the value returned from the set operation (impl specific)
035         * @throws Exception on any error.
036         */
037        Object invoke(Object obj, Object arg) throws Exception;
038    
039        /**
040         * Attempts to reuse this JexlPropertySet, checking that it is compatible with
041         * the actual set of arguments.
042         * @param obj the object to invoke the the get upon
043         * @param key the property key to get
044         * @param value the property value to set
045         * @return the result of the method invocation that should be checked by tryFailed to determine if it succeeded
046         * or failed.
047         */
048        Object tryInvoke(Object obj, Object key, Object value);
049    
050        /**
051         * Checks whether a tryInvoke failed or not.
052         * @param rval the value returned by tryInvoke
053         * @return true if tryInvoke failed, false otherwise
054         */
055        boolean tryFailed(Object rval);
056        
057        /**
058         * Specifies if this JexlPropertySet is cacheable and able to be reused for
059         * this class of object it was returned for.
060         * 
061         * @return true if can be reused for this class, false if not
062         */
063        boolean isCacheable();
064    }