Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package icasue.reflect.handles.fields;
import icasue.reflect.handles.object.ObjectOF;
import icasue.reflect.utils.ProxyDigestUtil;
import icasue.reflect.exceptions.HandleException;
import icasue.reflect.handles.HandleSupplier;
import icasue.reflect.handles.OFAble;
import icasue.reflect.handles.arrays.AryOF;
import icasue.reflect.handles.classes.ClassOF;
import icasue.reflect.handles.exception.ExceptionOF;
import icasue.reflect.handles.predicate.SureOF;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.Field;
import java.util.function.Consumer;
/**
* @Author: Qiao Hang
* @CreateDate: 2020/12/3 下午6:57
* @UpdateDate:
* @Description:
*/
public class FieldOF implements OFAble {
/**
* setAccessible_ (field) doc: open field's privileges
* get_ (field,invoker)
* set_ (field,invoker,val)
*
* findField_ofTp_fName_ (fieldOfType,fName)
* doc: find filed in type which you given and supperClass and first interface which type marked.
*
* get_ofTp_fName_instance_ (fieldOfType,fName,invoker)
* doc: invoke get method, this operator divide two steps,
* first, find field by fOfType and fName which you given,
* second, invoke field's get handle by invoker, will throw RuntimeException if field not found.
*
* set_ofTp_fName_instance_val_ (ofType,fName,invoker,val)
* doc: invoke set method, this operator divide two steps,
* first, find field by fOfType and fName which you given,
* second, invoke field's set handle by invoker, will throw RuntimeException if field not found.
*
* get_ofTp_fName_ (ofType,fName)
* doc: invoke get method, this operator divide three steps,
* first, find field by fOfType and fName which you given,
* second, find suitable invoker on environment or create new Instance by construct.
* third,invoke field's get handle by invoker, will throw RuntimeException if field not found.
* notice: using this method is unSafety, cause of find field has less troubles, but find suitAble invoke by fType is
* unSafe when this type is defined as a interface or supperClass or abstractClass and exists multi implements,
* at this time, findSuitAbleInvoke will using any instance from environment! at this case, wu suggest using
* OFAble.findField_ofTp_fName_ and ObjectOF.findSuitInstance_ and OFAble.get_ to complicate your action safety!
*
* set_ofTp_fName_val_ (ofType,fName,val)
* doc: invoke get method, this operator divide three steps,
* first, find field by fOfType and fName which you given,
* second, find suitable invoker on environment or create new Instance by construct.
* third,invoke field's get handle by invoker, will throw RuntimeException if field not found.
* notice: using this method is unSafety, cause of find field has less troubles, but find suitAble invoke by fType is
* unSafe when this type is defined as a interface or supperClass or abstractClass and exists multi implements,
* at this time, findSuitAbleInvoke will using any instance from environment! at this case, wu suggest using
* OFAble.findField_ofTp_fName_ and ObjectOF.findSuitInstance_ and OFAble.get_ to complicate your action safety!
*
*/
public static Consumer setAccessible_ = (field) -> {
try {
SureOF.notNull_.accept(field);
if(!ObjectOF.isPublic_.test(field.getModifiers()))
field.setAccessible(true);
} catch (HandleException deepError){
throw deepError;
} catch (Throwable throwable) {
throw ExceptionOF.handleExcInvocation_.apply("FieldOF.setAccessible_ : occur an error -> " , throwable.getMessage());
}
};
/**
* get accept two params, first as field self, second is invoker.
* notice get's inst be surely!
*/
public static HandleSupplier.FunctionAry