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

org.babyfish.jimmer.sql.fetcher.Fetcher Maven / Gradle / Ivy

There is a newer version: 0.9.19
Show newest version
package org.babyfish.jimmer.sql.fetcher;

import org.babyfish.jimmer.lang.NewChain;
import org.babyfish.jimmer.meta.ImmutableType;
import org.babyfish.jimmer.sql.ast.table.Table;

import java.util.Map;
import java.util.function.Consumer;

public interface Fetcher {

    Class getJavaClass();

    ImmutableType getImmutableType();

    Map getFieldMap();

    @NewChain
    Fetcher allScalarFields();

    @NewChain
    Fetcher allReferenceFields();

    /**
     * allScalars + allForeignKeys
     * @return A new fetcher
     */
    @NewChain
    Fetcher allTableFields();

    /**
     * Fetch a property without child fetcher,
     * for associated property, that means fetch id-only object
     * @param prop Propery name
     * @return A new fetcher
     */
    @NewChain
    Fetcher add(String prop);

    /**
     * Fetch a property with child fetcher,
     * error will be raised if the specified property is not association
     * @param prop Property name
     * @param childFetcher Deeper child fetcher for associated objects
     * @return A new fetcher
     */
    @NewChain
    Fetcher add(
            String prop,
            Fetcher childFetcher
    );

    /**
     * Fetch a property with child fetcher and more configuration,
     * error will be raised if the specified property is not association
     * @param prop Property name
     * @param childFetcher Deeper child fetcher for associated objects
     * @param loaderBlock An optional lambda expression that lets the user set more configurations
     * @return A new fetcher
     */
    @NewChain
    Fetcher add(
            String prop,
            Fetcher childFetcher,
            Consumer>> loaderBlock
    );

    @NewChain
    Fetcher addRecursion(
            String prop,
            Consumer>> loaderBlock
    );

    /**
     * Fetch association directly based on foreign key, the associated object has only id property
     * @param prop Property name
     * @param referenceType Reference type which has 2 choices
     *                      
    *
  • DEFAULT: The associated will filtered by global filters(include built-lt logical deleted filter)
  • *
  • RAW: Raw value of foreign key
  • *
*

If the property is not an association directly based on foreign key, this argument will be ignored

* @return A new fetcher */ @NewChain Fetcher add(String prop, IdOnlyFetchType referenceType); /** * Unfetch a property * @param prop Property name * @return A new fetcher */ @NewChain Fetcher remove(String prop); String toString(boolean multiLine); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy