public abstract class ConversionHandler extends Object
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.
Constructor and description |
---|
ConversionHandler
(Object delegate) Creates a ConversionHandler with an delegate. |
Type | Name and description |
---|---|
protected boolean |
checkMethod(Method method) |
boolean |
equals(Object obj) Indicates whether some other object is "equal to" this one. |
Object |
getDelegate() Returns the delegate. |
int |
hashCode() Returns a hash code value for the delegate. |
Object |
invoke(Object proxy, Method method, Object[] args) This method is a default implementation for the invoke method given in InvocationHandler. |
Object |
invokeCustom(Object proxy, Method method, Object[] args) This method is called for all Methods not defined on Object. |
static boolean |
isCoreObjectMethod(Method method) Checks whether a method is a core method from java.lang.Object. |
protected boolean |
isDefaultMethod(Method method) |
String |
toString() Returns a String version of the delegate. |
Creates a ConversionHandler with an delegate.
delegate
- the delegateIndicates whether some other object is "equal to" this one. The delegate is used if the class of the parameter and the current class are equal. In other cases the method will return false. The exact class is here used, if inheritance is needed, this method must be overwritten.
Returns the delegate.
Returns a hash code value for the delegate.
This method is a default implementation for the invoke method given in InvocationHandler. Any call to a method with a declaring class that is not Object, excluding toString() and default methods is redirected to invokeCustom.
Methods like equals and hashcode are called on the class itself instead of the delegate because they are considered fundamental methods that should not be overwritten. The toString() method gets special treatment as it is deemed to be a method that you might wish to override when called from Groovy. Interface default methods from Java 8 on the other hand are considered being default implementations you don't normally want to change. So they are called directly too
In many scenarios, it is better to overwrite the invokeCustom method where the core Object related methods are filtered out.
proxy
- the proxymethod
- the methodargs
- the argumentsThis method is called for all Methods not defined on Object. The delegate should be called here.
proxy
- the proxymethod
- the methodargs
- the argumentsChecks whether a method is a core method from java.lang.Object. Such methods often receive special treatment because they are deemed fundamental enough to not be tampered with.
method
- the method to checkReturns a String version of the delegate.
Copyright © 2003-2015 The Apache Software Foundation. All rights reserved.