001/* 002 * Copyright 2002-2014 the original author or authors. 003 * 004 * Licensed under the Apache 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 * https://www.apache.org/licenses/LICENSE-2.0 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 */ 016 017package org.springframework.expression.spel; 018 019import org.springframework.asm.MethodVisitor; 020import org.springframework.asm.Opcodes; 021import org.springframework.expression.PropertyAccessor; 022 023/** 024 * A compilable property accessor is able to generate bytecode that represents 025 * the access operation, facilitating compilation to bytecode of expressions 026 * that use the accessor. 027 * 028 * @author Andy Clement 029 * @since 4.1 030 */ 031public interface CompilablePropertyAccessor extends PropertyAccessor, Opcodes { 032 033 /** 034 * Return {@code true} if this property accessor is currently suitable for compilation. 035 */ 036 boolean isCompilable(); 037 038 /** 039 * Return the type of the accessed property - may only be known once an access has occurred. 040 */ 041 Class<?> getPropertyType(); 042 043 /** 044 * Generate the bytecode the performs the access operation into the specified MethodVisitor 045 * using context information from the codeflow where necessary. 046 * @param propertyName the name of the property 047 * @param mv the Asm method visitor into which code should be generated 048 * @param cf the current state of the expression compiler 049 */ 050 void generateCode(String propertyName, MethodVisitor mv, CodeFlow cf); 051 052}