All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.joekerouac.common.tools.reflect.bean.PropertyEditor Maven / Gradle / Ivy

The newest version!
/*
 * 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.
 */
package com.github.joekerouac.common.tools.reflect.bean;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Type;

/**
 * 属性编辑器
 *
 * @since 1.0.0
 * @author JoeKerouac
 * @date 2022-10-14 14:37:00
 */
public interface PropertyEditor {

    /**
     * 是否有写入方法
     * 
     * @return true表示有写入方法
     */
    boolean hasWriteMethod();

    /**
     * 是否有读取方法
     * 
     * @return true表示有读取方法
     */
    boolean hasReadMethod();

    /**
     * 将指定值写入指定对象的指定字段
     * 
     * @param target
     *            指定对象
     * @param value
     *            要写入的值
     */
    void write(Object target, Object value);

    /**
     * 读取指定对象的字段值
     * 
     * @param target
     *            指定对象
     * @param 
     *            字段实际类型
     * @return 字段值
     */
     T read(Object target);

    /**
     * 原始字段
     * 
     * @return 字段
     */
    Field original();

    /**
     * 字段名
     * 
     * @return 字段名
     */
    String name();

    /**
     * 字段类型
     * 
     * @return 字段类型
     */
    Class type();

    /**
     * 字段类型
     * 
     * @return 类型
     */
    Type getGenericType();

    /**
     * 字段所属class
     * 
     * @return 字段所属class
     */
    Class owner();

    /**
     * 获取指定类型的枚举
     * 
     * @param annotationClass
     *            枚举class
     * @param 
     *            枚举实际类型
     * @return 枚举
     */
     T getAnnotation(Class annotationClass);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy