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

com.kenshoo.pl.entity.InsertOnDuplicateUpdateCommand Maven / Gradle / Ivy

Go to download

A Java persistence layer based on JOOQ for high performance and business flow support.

There is a newer version: 0.1.121-jooq-3.16.3
Show newest version
package com.kenshoo.pl.entity;

import static com.kenshoo.pl.entity.ChangeOperation.CREATE;
import static com.kenshoo.pl.entity.ChangeOperation.UPDATE;

public class InsertOnDuplicateUpdateCommand, ID extends Identifier> extends UpdateEntityCommand {

    private ChangeOperation changeOperation = UPDATE;
    private boolean allowMissingEntity = true;

    public InsertOnDuplicateUpdateCommand(E entityType, ID key) {
        super(entityType, key);
    }

    @Override
    public ChangeOperation getChangeOperation() {
        return changeOperation;
    }

    @Override
    public boolean allowMissingEntity() {
        return allowMissingEntity;
    }

    @Override
    public void updateOperator(ChangeOperation changeOperation) {
        if (this.changeOperation == UPDATE && changeOperation == CREATE) {
            this.changeOperation = changeOperation;
            this.allowMissingEntity = false;
            ChangeEntityCommand.copy(this, this.getIdentifier());
            this.getChildren().forEach(child -> child.updateOperator(changeOperation));
        } else {
            throw new UnsupportedOperationException("Unsupported update change operation from " + this.changeOperation + " to " + changeOperation);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy