Returns the constraint set with the given name.
189944
def get_lin_constraint(self, name):
        
        for c in self.lin_constraints:
            if c.name == name:
                return c
        else:
            raise ValueError
1278413
@Override
	public Set<String> getContainedIds() {
		Set<String> s = super.getContainedIds();
		s.addAll(constraint.getContainedIds());
		return s;
	}
66327
function Constraint(constraintName, constraintPayload) {
	var name = constraintName;
	var payload = constraintPayload;

	/**
	 * The constraint name.
	 * @returns {String} a name
	 */
	this.getName = function () {
		return name;
	};

	/**
	 * Sets the name of the constraint.
	 * @param {String} n name
	 */
	this.setName = function (n) {
		name = n;
	};

	/**
	 * The payload (a map)
	 * @returns {Object} an object
	 */
	this.getPayload = function () {
		return payload;
	};

	/**
	 * Sets the payload.
	 * @param {Object} p the payload object
	 */
	this.setPayload = function (p) {
		payload = p;
	};
}
957289
OrderedHashSet getDependentConstraints(int colIndex) {

        OrderedHashSet set = new OrderedHashSet();

        for (int i = 0, size = constraintList.length; i < size; i++) {
            Constraint c = constraintList[i];

            if (c.hasColumnOnly(colIndex)) {
                set.add(c);
            }
        }

        return set;
    }
740525
int getConstraintIndex(String constraintName) {

        for (int i = 0, size = constraintList.length; i < size; i++) {
            if (constraintList[i].getName().name.equals(constraintName)) {
                return i;
            }
        }

        return -1;
    }
1350971
public Collection findAll(Collection collection, Constraint constraint) {
		return findAll(collection.iterator(), constraint);
	}
895242
def get_configurable_by_name(self, name):
        
        l = [c for c in self.configurables if c.name == name]
        if l:
            return l[0]
213265
def GetPresetByName(self, name):
    
    name = name.lower()
    return self._definitions.get(name, None)
113408
def get_constraints(self, cursor, table_name):
        
        constraints = {}
        # Loop over the key table, collecting things as constraints
        # This will get PKs, FKs, and uniques, but not CHECK
        cursor.execute("""
            SELECT
                kc.constraint_name,
                kc.column_name,
                c.constraint_type,
                array(SELECT table_name::text || '.' || column_name::text
                      FROM information_schema.constraint_column_usage
                      WHERE constraint_name = kc.constraint_name
                        AND constraint_schema = kc.constraint_schema)
            FROM information_schema.key_column_usage AS kc
            JOIN information_schema.table_constraints AS c ON
                kc.table_schema = c.table_schema AND
                kc.table_name = c.table_name AND
                kc.constraint_name = c.constraint_name
            WHERE
                kc.table_schema = %s AND
                kc.table_name = %s
            ORDER BY kc.ordinal_position ASC
        """, [self.connection.schema, table_name])
        for constraint, column, kind, used_cols in cursor.fetchall():
            # If we're the first column, make the record
            if constraint not in constraints:
                constraints[constraint] = {
                    "columns": [],
                    "primary_key": kind.lower() == "primary key",
                    "unique": kind.lower() in ["primary key", "unique"],
                    "foreign_key": tuple(used_cols[0].split(".", 1)) if kind.lower() == "foreign key" else None,
                    "check": False,
                    "index": False,
                }
            # Record the details
            constraints[constraint]['columns'].append(column)
        # Now get CHECK constraint columns
        cursor.execute("""
            SELECT kc.constraint_name, kc.column_name
            FROM information_schema.constraint_column_usage AS kc
            JOIN information_schema.table_constraints AS c ON
                kc.table_schema = c.table_schema AND
                kc.table_name = c.table_name AND
                kc.constraint_name = c.constraint_name
            WHERE
                c.constraint_type = 'CHECK' AND
                kc.table_schema = %s AND
                kc.table_name = %s
        """, [self.connection.schema, table_name])
        for constraint, column in cursor.fetchall():
            # If we're the first column, make the record
            if constraint not in constraints:
                constraints[constraint] = {
                    "columns": [],
                    "primary_key": False,
                    "unique": False,
                    "foreign_key": None,
                    "check": True,
                    "index": False,
                }
            # Record the details
            constraints[constraint]['columns'].append(column)
        # Now get indexes
        cursor.execute("""
            SELECT
                c2.relname,
                ARRAY(
                    SELECT (SELECT attname FROM pg_catalog.pg_attribute WHERE attnum = i AND attrelid = c.oid)
                    FROM unnest(idx.indkey) i
                ),
                idx.indisunique,
                idx.indisprimary
            FROM pg_catalog.pg_class c, pg_catalog.pg_class c2,
                pg_catalog.pg_index idx, pg_catalog.pg_namespace n
            WHERE c.oid = idx.indrelid
                AND idx.indexrelid = c2.oid
                AND c.relnamespace = n.oid
                AND n.nspname = %s
                AND c.relname = %s
        """, [self.connection.schema, table_name])
        for index, columns, unique, primary in cursor.fetchall():
            if index not in constraints:
                constraints[index] = {
                    "columns": list(columns),
                    "primary_key": primary,
                    "unique": unique,
                    "foreign_key": None,
                    "check": False,
                    "index": True,
                }
        return constraints
167276
protected Constraints getConstraints (Component child)
    {
        if (_constraints != null) {
            Constraints c = _constraints.get(child);
            if (c != null) {
                return c;
            }
        }

        return DEFAULT_CONSTRAINTS;
    }
968658
NFRuleSet findRuleSet(String name) throws IllegalArgumentException {
        NFRuleSet result = ruleSetsMap.get(name);
        if (result == null) {
            throw new IllegalArgumentException("No rule set named " + name);
        }
        return result;
    }
1303422
def getConstraint(self, name):
        
        return lock_and_call(
            lambda: Constraint(self._impl.getConstraint(name)),
            self._lock
        )
983375
def add_constraint(self, con):
        
        if isinstance(con, LinearConstraint):
            N, M = con.A.shape
            if con.name in [c.name for c in self.lin_constraints]:
                logger.error("Constraint set named '%s' already exists."
                             % con.name)
                return False
            else:
                con.i1 = self.lin_N# + 1
                con.iN = self.lin_N + N - 1

                nv = 0
                for vs in con.vs:
                    nv = nv + self.get_var_N(vs)
                if M != nv:
                    logger.error("Number of columns of A does not match number"
                        " of variables, A is %d x %d, nv = %d", N, M, nv)
                self.lin_constraints.append(con)
        elif isinstance(con, NonLinearConstraint):
            N = con.N
            if con.name in [c.name for c in self.nln_constraints]:
                logger.error("Constraint set named '%s' already exists."
                             % con.name)
                return False
            else:
                con.i1 = self.nln_N# + 1
                con.iN = self.nln_N + N
                self.nln_constraints.append(con)
        else:
            raise ValueError

        return True
168725
private function acquireConstraintName($nameType, $nbr)
    {
        $inputs = array();
        $inputs[] = $this->getDatabase();
        $inputs[] = $this->getCommonName();
        $inputs[] = $nameType;
        $inputs[] = $nbr;

        return NameFactory::generateName(NameFactory::CONSTRAINT_GENERATOR, $inputs);
    }
269386
def get_constraints(self, cursor, table_name):
    
    constraints = {}
    # Loop over the key table, collecting things as constraints. The column
    # array must return column names in the same order in which they were
    # created.
    # The subquery containing generate_series can be replaced with
    # "WITH ORDINALITY" when support for PostgreSQL 9.3 is dropped.
    cursor.execute("""
        SELECT
            c.conname,
            array(
                SELECT attname
                FROM (
                    SELECT unnest(c.conkey) AS colid,
                           generate_series(1, array_length(c.conkey, 1)) AS arridx
                ) AS cols
                JOIN pg_attribute AS ca ON cols.colid = ca.attnum
                WHERE ca.attrelid = c.conrelid
                ORDER BY cols.arridx
            ),
            c.contype,
            (SELECT fkc.relname || '.' || fka.attname
            FROM pg_attribute AS fka
            JOIN pg_class AS fkc ON fka.attrelid = fkc.oid
            WHERE fka.attrelid = c.confrelid AND fka.attnum = c.confkey[1]),
            cl.reloptions
        FROM pg_constraint AS c
        JOIN pg_class AS cl ON c.conrelid = cl.oid
        JOIN pg_namespace AS ns ON cl.relnamespace = ns.oid
        WHERE ns.nspname = %s AND cl.relname = %s
    """, [self.connection.schema_name, table_name])
    for constraint, columns, kind, used_cols, options in cursor.fetchall():
        constraints[constraint] = {
            "columns": columns,
            "primary_key": kind == "p",
            "unique": kind in ["p", "u"],
            "foreign_key": tuple(used_cols.split(".", 1)) if kind == "f" else None,
            "check": kind == "c",
            "index": False,
            "definition": None,
            "options": options,
        }
    # Now get indexes
    # The row_number() function for ordering the index fields can be
    # replaced by WITH ORDINALITY in the unnest() functions when support
    # for PostgreSQL 9.3 is dropped.
    cursor.execute("""
        SELECT
            indexname, array_agg(attname ORDER BY rnum), indisunique, indisprimary,
            array_agg(ordering ORDER BY rnum), amname, exprdef, s2.attoptions
        FROM (
            SELECT
                row_number() OVER () as rnum, c2.relname as indexname,
                idx.*, attr.attname, am.amname,
                CASE
                    WHEN idx.indexprs IS NOT NULL THEN
                        pg_get_indexdef(idx.indexrelid)
                END AS exprdef,
                CASE am.amname
                    WHEN 'btree' THEN
                        CASE (option & 1)
                            WHEN 1 THEN 'DESC' ELSE 'ASC'
                        END
                END as ordering,
                c2.reloptions as attoptions
            FROM (
                SELECT
                    *, unnest(i.indkey) as key, unnest(i.indoption) as option
                FROM pg_index i
            ) idx
            LEFT JOIN pg_class c ON idx.indrelid = c.oid
            LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
            LEFT JOIN pg_class c2 ON idx.indexrelid = c2.oid
            LEFT JOIN pg_am am ON c2.relam = am.oid
            LEFT JOIN pg_attribute attr ON attr.attrelid = c.oid AND attr.attnum = idx.key
            WHERE c.relname = %s and n.nspname = %s
        ) s2
        GROUP BY indexname, indisunique, indisprimary, amname, exprdef, attoptions;
    """, [table_name, self.connection.schema_name])
    for index, columns, unique, primary, orders, type_, definition, options in cursor.fetchall():
        if index not in constraints:
            constraints[index] = {
                "columns": columns if columns != [None] else [],
                "orders": orders if orders != [None] else [],
                "primary_key": primary,
                "unique": unique,
                "foreign_key": None,
                "check": False,
                "index": True,
                "type": Index.suffix if type_ == 'btree' else type_,
                "definition": definition,
                "options": options,
            }
    return constraints
431279
def constraint(self):
        """"""
        constraint_arr = []
        if self._not_null:
            constraint_arr.append("PRIMARY KEY" if self._pk else "NOT NULL")
        if self._unique:
            constraint_arr.append("UNIQUE")

        return " ".join(constraint_arr)
800560
def constraint_join(cfg_nodes):
    """"""
    r = 0
    for e in cfg_nodes:
        r = r | constraint_table[e]
    return r