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

com.vmware.dcm.compiler.ir.TableRowGenerator Maven / Gradle / Ivy

Go to download

Library for building declarative cluster managers. Please refer to the README at github.com/vmware/declarative-cluster-management/ for instructions on setting up solvers before use.

There is a newer version: 0.15.0
Show newest version
/*
 * Copyright 2018-2020 VMware, Inc. All Rights Reserved.
 *
 * SPDX-License-Identifier: BSD-2
 */

package com.vmware.dcm.compiler.ir;

import com.vmware.dcm.IRColumn;
import com.vmware.dcm.IRTable;
import com.vmware.dcm.IRPrimaryKey;

import java.util.Optional;

public final class TableRowGenerator extends Qualifier {
    private final IRTable table;

    public TableRowGenerator(final IRTable table) {
        this.table = table;
    }

    public IRTable getTable() {
        return table;
    }

    public Optional getUniquePrimaryKeyColumn() {
        return table.getPrimaryKey().map(IRPrimaryKey::getPrimaryKeyFields)
                .filter(l -> l.size() == 1)
                .map(l -> l.get(0));
    }

    @Override
    public String toString() {
        return "TableRowGenerator{" +
                "table=" + table.getName() +
                '}';
    }

    @Override
     T acceptVisitor(final IRVisitor visitor, final C context) {
        return visitor.visitTableRowGenerator(this, context);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy