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

com.github.leeonky.util.PropertyReader Maven / Gradle / Ivy

The newest version!
package com.github.leeonky.util;

import java.util.LinkedList;
import java.util.List;

public interface PropertyReader extends PropertyAccessor {
    Object getValue(T instance);

    default PropertyReader getPropertyChainReader(List chain) {
        PropertyReader reader = this;
        LinkedList linkedChain = new LinkedList<>(chain);
        while (!linkedChain.isEmpty()) {
            Object p = linkedChain.removeFirst();
            if (p instanceof Integer)
                return BeanClass.create(getType().getElementType().getType()).getPropertyChainReader(linkedChain);
            else
                reader = getType().getPropertyReader((String) p);
        }
        return reader;
    }
}