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

com.github.leeonky.jfactory.LinkProducer Maven / Gradle / Ivy

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

import com.github.leeonky.util.BeanClass;

import java.util.Optional;
import java.util.stream.Stream;

class LinkProducer extends Producer {
    private final Link.Reference linkerReference;
    private final Producer origin;

    public LinkProducer(BeanClass type, Link link, Producer origin, PropertyChain linkProperty) {
        super(type);
        linkerReference = new Link.Reference(linkProperty).setLinker(link);
        this.origin = origin;
    }

    @Override
    protected T produce() {
        return linkerReference.getLinker().chooseProducer().getValue();
    }

    @Override
    public Stream> allLinkerReferences(Producer root, PropertyChain absoluteCurrent) {
        return linkerReference.getLinker().allLinkedReferences();
    }

    @Override
    public Producer getLinkOrigin() {
        return origin;
    }

    @Override
    public Optional> child(String property) {
        return linkerReference.getLinker().chooseProducer().child(property);
    }

    @Override
    protected Producer changeFrom(ObjectProducer producer) {
        return producer.isFixed() ? producer : this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy