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

org.sfm.reflect.meta.MethodPropertyMeta Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
package org.sfm.reflect.meta;

import org.sfm.reflect.Getter;
import org.sfm.reflect.ReflectionService;
import org.sfm.reflect.Setter;
import org.sfm.reflect.SetterHelper;

import java.lang.reflect.Method;
import java.lang.reflect.Type;

public class MethodPropertyMeta extends PropertyMeta {

	private final Method method;
	private final Type type;

	public MethodPropertyMeta(String name, String columnName, ReflectionService reflectService, Method method, Type type) {
		super(name, columnName, reflectService);
		this.method = method;
		this.type = type;
	}

	@Override
	protected Setter newSetter() {
		return reflectService.getObjectSetterFactory().getMethodSetter(method);
	}

    @SuppressWarnings("unchecked")
    @Override
    protected Getter newGetter() {
        return reflectService.getObjectGetterFactory().getGetter((Class) method.getDeclaringClass(), SetterHelper.getPropertyNameFromMethodName(method.getName()));
    }

    @Override
	public Type getType() {
		return type;
	}

	@Override
	public String getPath() {
		return getName();
	}

    @Override
    public String toString() {
        return "MethodPropertyMeta{" +
                "method=" + method +
                ", type=" + type +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy