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

org.babyfish.jimmer.sql.ast.mutation.AbstractMutationResult Maven / Gradle / Ivy

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

import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.TypedProp;

import java.util.Collections;
import java.util.Map;

public class AbstractMutationResult implements MutationResult {

    protected int totalAffectedRowCount;

    protected Map affectedRowCountMap;

    public AbstractMutationResult(Map affectedRowCountMap) {
        this.affectedRowCountMap = Collections.unmodifiableMap(affectedRowCountMap);
        int totalAffectedRowCount = 0;
        for (Integer affectedRowCount : affectedRowCountMap.values()) {
            totalAffectedRowCount += affectedRowCount;
        }
        this.totalAffectedRowCount = totalAffectedRowCount;
    }

    @Override
    public int getTotalAffectedRowCount() {
        return totalAffectedRowCount;
    }

    @Override
    public Map getAffectedRowCountMap() {
        return affectedRowCountMap;
    }

    @Override
    public int getAffectedRowCount(AffectedTable affectTable) {
        Integer affectedRowCount = affectedRowCountMap.get(affectTable);
        return affectedRowCount != null ? affectedRowCount : 0;
    }

    @Override
    public int getAffectedRowCount(Class entityType) {
        return getAffectedRowCount(AffectedTable.of(entityType));
    }

    @Override
    public int getAffectedRowCount(TypedProp.Association associationProp) {
        return getAffectedRowCount(AffectedTable.of(associationProp.unwrap()));
    }

    @Override
    public int getAffectedRowCount(ImmutableProp prop) {
        return getAffectedRowCount(AffectedTable.of(prop));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy