Export the collision constraint as a node.

@param root The node root (must not be <code>null</code>).
@param constraint The collision constraint to export (must not be <code>null</code>).
@throws LionEngineException If error on writing.
328974
public static void exports(Xml root, CollisionConstraint constraint)
    {
        Check.notNull(root);
        Check.notNull(constraint);

        for (final Entry<Orientation, Collection<String>> entry : constraint.getConstraints().entrySet())
        {
            final Orientation orientation = entry.getKey();

            for (final String group : entry.getValue())
            {
                final Xml current = root.createChild(NODE_CONSTRAINT);
                current.writeString(ATT_ORIENTATION, orientation.name());
                current.writeString(ATT_GROUP, group);
            }
        }
    }
1327229
public void addConstraint(Constraint constraint) {
        if ( ConstraintType.ALPHA.equals(constraint.getType())) {
            this.addAlphaConstraint( (AlphaNodeFieldConstraint) constraint );
        } else if ( ConstraintType.BETA.equals(constraint.getType())) {
            this.addBetaConstraint( (BetaNodeFieldConstraint) constraint );
        } else {
            throw new RuntimeException( "Constraint type MUST be known in advance.");
        }
    }
1318139
@Override
	public void process(Node externs, Node root) {
		this.expandedDepsList.clear();
		List<DependencyList> enclosingDependencies = new LinkedList<DependencyList>();
		try {
			processChildren(root, enclosingDependencies);
		} catch (ProcessingDependenciesException e) {
			throw new RuntimeProcessingDependenciesException(e);
		} catch (DependencyVerificationException e) {
			throw new RuntimeDependencyVerificationException(e);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		appendConsoleLogging(root);
	}
596473
public static void exports(Xml root, CollisionCategory category)
    {
        Check.notNull(root);
        Check.notNull(category);

        final Xml node = root.createChild(NODE_CATEGORY);
        node.writeString(ATT_NAME, category.getName());
        node.writeString(ATT_AXIS, category.getAxis().name());
        node.writeInteger(ATT_X, category.getOffsetX());
        node.writeInteger(ATT_Y, category.getOffsetY());
        node.writeBoolean(ATT_GLUE, category.isGlue());

        for (final CollisionGroup group : category.getGroups())
        {
            final Xml groupNode = node.createChild(TileGroupsConfig.NODE_GROUP);
            groupNode.setText(group.getName());
        }
    }
715278
public static <T> ConstraintViolation<T> forReturnValueValidation(final String messageTemplate,
      final Map<String, Object> messageParameters, final Map<String, Object> expressionVariables,
      final String interpolatedMessage, final Class<T> rootBeanClass, final T rootBean,
      final Object leafBeanInstance, final Object value, final Path propertyPath,
      final ConstraintDescriptor<?> constraintDescriptor, final ElementType elementType,
      final Object executableReturnValue, final Object dynamicPayload) {
    return new ConstraintViolationImpl<>(messageTemplate, messageParameters, expressionVariables,
        interpolatedMessage, rootBeanClass, rootBean, leafBeanInstance, value, propertyPath,
        constraintDescriptor, elementType, null, executableReturnValue, dynamicPayload);
  }
1112044
public void setRoot(int root)
  {
    super.setRoot(root);
    m_iterator = getDTM(root).getAxisIterator(m_axis);
    m_iterator.setStartNode(root);
  }
181864
public void addSparseConstraint(int component, int index, double value) {
    constraints.add(new Constraint(component, index, value));
  }
473744
public final void setConstraints(@NonNull final Constraint<Type>[] constraints) {
        Condition.INSTANCE.ensureNotNull(constraints, "The constraints may not be null");
        Condition.INSTANCE.ensureAtLeast(constraints.length, 1, "The constraints may not be empty");
        this.constraints = constraints;
    }
1352349
private Constraint getObject(final MathRandom random, final Element element, final Constructor<? extends Constraint> constructor)
			throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
		LOG.debug("Creating constraint: " + element.getAttributes());
		Constraint instance = constructor.newInstance(new Object[] { random, element, generator });
		injector.injectMembers(instance);
		return instance;
	}
855331
@SuppressWarnings("unchecked")
  public final void integrityCheck(AbstractRStarTree<N, E, ?> tree) {
    // leaf node
    if(isLeaf()) {
      for(int i = 0; i < getCapacity(); i++) {
        E e = getEntry(i);
        if(i < getNumEntries() && e == null) {
          throw new RuntimeException("i < numEntries && entry == null");
        }
        if(i >= getNumEntries() && e != null) {
          throw new RuntimeException("i >= numEntries && entry != null");
        }
      }
    }

    // dir node
    else {
      N tmp = tree.getNode(getEntry(0));
      boolean childIsLeaf = tmp.isLeaf();

      for(int i = 0; i < getCapacity(); i++) {
        E e = getEntry(i);

        if(i < getNumEntries() && e == null) {
          throw new RuntimeException("i < numEntries && entry == null");
        }

        if(i >= getNumEntries() && e != null) {
          throw new RuntimeException("i >= numEntries && entry != null");
        }

        if(e != null) {
          N node = tree.getNode(e);

          if(childIsLeaf && !node.isLeaf()) {
            for(int k = 0; k < getNumEntries(); k++) {
              tree.getNode(getEntry(k));
            }

            throw new RuntimeException("Wrong Child in " + this + " at " + i);
          }

          if(!childIsLeaf && node.isLeaf()) {
            throw new RuntimeException("Wrong Child: child id no leaf, but node is leaf!");
          }

          node.integrityCheckParameters((N) this, i);
          node.integrityCheck(tree);
        }
      }

      if(LoggingConfiguration.DEBUG) {
        Logger.getLogger(this.getClass().getName()).fine("DirNode " + getPageID() + " ok!");
      }
    }
  }
212641
public void addShutdownConstraint (ShutdownComponent lhs, Constraint constraint,
                                       ShutdownComponent rhs)
    {
        if (lhs == null || rhs == null) {
            throw new IllegalArgumentException("Cannot add constraint about null component.");
        }
        ShutdownComponent before = (constraint == Constraint.RUNS_BEFORE) ? lhs : rhs;
        ShutdownComponent after = (constraint == Constraint.RUNS_BEFORE) ? rhs : lhs;
        _downers.addDependency(after, before);
    }
256744
public void addBetaConstraint(BetaNodeFieldConstraint constraint) {
        if ( constraint != null ) {
            BetaNodeFieldConstraint[] tmp = this.betaConstraints;
            this.betaConstraints = new BetaNodeFieldConstraint[tmp.length + 1];
            System.arraycopy( tmp,
                              0,
                              this.betaConstraints,
                              0,
                              tmp.length );
            this.betaConstraints[this.betaConstraints.length - 1] = constraint;
            this.updateRequiredDeclarations( constraint );
            this.setType( Constraint.ConstraintType.BETA );
        }
    }
790943
private static void exportAllowedMovements(Xml root, Collection<MovementTile> movements)
    {
        for (final MovementTile movement : movements)
        {
            final Xml node = root.createChild(NODE_MOVEMENT);
            node.setText(movement.name());
        }
    }
974824
private void addConstraintToCatalog(Table table,
            VoltXMLElement node,
            Map<String, String> indexReplacementMap,
            Map<String, Index> indexMap)
            throws VoltCompilerException
    {
        assert node.name.equals("constraint");

        String name = node.attributes.get("name");
        String typeName = node.attributes.get("constrainttype");
        ConstraintType type = ConstraintType.valueOf(typeName);
        String tableName = table.getTypeName();

        if (type == ConstraintType.LIMIT) {
            int tupleLimit = Integer.parseInt(node.attributes.get("rowslimit"));
            if (tupleLimit < 0) {
                throw m_compiler.new VoltCompilerException("Invalid constraint limit number '" + tupleLimit + "'");
            }
            if (tableLimitConstraintCounter.contains(tableName)) {
                throw m_compiler.new VoltCompilerException("Too many table limit constraints for table " + tableName);
            } else {
                tableLimitConstraintCounter.add(tableName);
            }

            table.setTuplelimit(tupleLimit);
            String deleteStmt = node.attributes.get("rowslimitdeletestmt");
            if (deleteStmt != null) {
                Statement catStmt = table.getTuplelimitdeletestmt().add("limit_delete");
                catStmt.setSqltext(deleteStmt);
                validateTupleLimitDeleteStmt(catStmt);
            }
            return;
        }

        if (type == ConstraintType.CHECK) {
            String msg = "VoltDB does not enforce check constraints. ";
            msg += "Constraint on table " + tableName + " will be ignored.";
            m_compiler.addWarn(msg);
            return;
        }
        else if (type == ConstraintType.FOREIGN_KEY) {
            String msg = "VoltDB does not enforce foreign key references and constraints. ";
            msg += "Constraint on table " + tableName + " will be ignored.";
            m_compiler.addWarn(msg);
            return;
        }
        else if (type == ConstraintType.MAIN) {
            // should never see these
            assert(false);
        }
        else if (type == ConstraintType.NOT_NULL) {
            // these get handled by table metadata inspection
            return;
        }
        else if (type != ConstraintType.PRIMARY_KEY &&  type != ConstraintType.UNIQUE) {
            throw m_compiler.new VoltCompilerException("Invalid constraint type '" + typeName + "'");
        }

        // else, create the unique index below
        // primary key code is in other places as well

        // The constraint is backed by an index, therefore we need to create it
        // TODO: We need to be able to use indexes for foreign keys. I am purposely
        //       leaving those out right now because HSQLDB just makes too many of them.
        Constraint catalog_const = table.getConstraints().add(name);
        String indexName = node.attributes.get("index");
        assert(indexName != null);
        // handle replacements from duplicate index pruning
        if (indexReplacementMap.containsKey(indexName)) {
            indexName = indexReplacementMap.get(indexName);
        }

        Index catalog_index = indexMap.get(indexName);

        // Attach the index to the catalog constraint (catalog_const).
        if (catalog_index != null) {
            catalog_const.setIndex(catalog_index);
            // This may be redundant.
            catalog_index.setUnique(true);

            boolean assumeUnique = Boolean.parseBoolean(node.attributes.get("assumeunique"));
            catalog_index.setAssumeunique(assumeUnique);
        }
        catalog_const.setType(type.getValue());
    }
1132060
public void setInitialConstraintsFrom(final Component comp) {
        gc = getConstraints(comp);
        if (gc == null) {
            throw new IllegalArgumentException(comp + " has no existing constraints");
        }
        setConstraints(comp, gc);
    }
738156
public static CollisionCategory imports(Xml root, MapTileCollision map)
    {
        Check.notNull(root);
        Check.notNull(map);

        final Collection<Xml> children = root.getChildren(TileGroupsConfig.NODE_GROUP);
        final Collection<CollisionGroup> groups = new ArrayList<>(children.size());

        for (final Xml groupNode : children)
        {
            final String groupName = groupNode.getText();
            final CollisionGroup group = map.getCollisionGroup(groupName);
            groups.add(group);
        }

        final String axisName = root.readString(ATT_AXIS);
        final Axis axis;
        try
        {
            axis = Axis.valueOf(axisName);
        }
        catch (final IllegalArgumentException exception)
        {
            throw new LionEngineException(exception, ERROR_AXIS + axisName);
        }

        final int x = root.readInteger(ATT_X);
        final int y = root.readInteger(ATT_Y);
        final boolean glue = root.readBoolean(true, ATT_GLUE);
        final String name = root.readString(ATT_NAME);

        return new CollisionCategory(name, axis, x, y, glue, groups);
    }
416010
public boolean hasConstraint (String constraint)
    {
        return (_constraints == null) ? false :
            ListUtil.contains(_constraints, constraint);
    }