当前位置: 首页>>代码示例>>Java>>正文


Java AbstractConstraint类代码示例

本文整理汇总了Java中de.invation.code.toval.constraint.AbstractConstraint的典型用法代码示例。如果您正苦于以下问题:Java AbstractConstraint类的具体用法?Java AbstractConstraint怎么用?Java AbstractConstraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractConstraint类属于de.invation.code.toval.constraint包,在下文中一共展示了AbstractConstraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clone

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
@Override
public RegularIFNetTransition clone() {
	RegularIFNetTransition result = (RegularIFNetTransition) super.clone();
	try {
		if (dataContainer != null)
			result.setGuardDataContainer(dataContainer);
		for (AbstractConstraint<?> guard : guards) {
			result.addGuard(guard.clone());
		}

		for (String color : accessModes.keySet()) {
			result.setAccessMode(color, getAccessModes(color));
		}
	} catch (ParameterException e) {
		e.printStackTrace();
	}
	return result;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:19,代码来源:RegularIFNetTransition.java

示例2: testRemoveGuard

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
@Test
public void testRemoveGuard() throws ParameterException {
	IFNet sNet = IFNetTestUtil.createSimpleIFNet();
	RegularIFNetTransition trans = (RegularIFNetTransition) sNet.getTransition("tIn");

	// Get the gurads and check there are no guards initially
	Set<AbstractConstraint<?>> guards = trans.getGuards();
	assertTrue(guards.isEmpty());

	// add a guard and make sure it is really there
	trans.setGuardDataContainer(new TestGuardDataContainer(sNet.getTokenColors()));
	NumberConstraint nc = new NumberConstraint("green", NumberOperator.LARGER, -3);
	trans.addGuard(nc);
	assertFalse(guards.isEmpty());

	// remove it again
	trans.removeGuard(nc);
	assertTrue(guards.isEmpty());
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:20,代码来源:RegularIFNetTransitionTest.java

示例3: addRoutingConstraint

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
/**
 * Adds a routing constraint for an activity.
 * @param activity The name of the activity for which the constraint is added.
 * @param constraint The routing constraint to add.
 * @throws ParameterException if the given parameters are invalid.
 * @throws PropertyException if the given constraint cannot be added as a property.
 * @see #addConstraint(AbstractConstraint)
 * @see #addActivityWithConstraints(String)
 */
public void addRoutingConstraint(String activity, AbstractConstraint<?> constraint) throws PropertyException{
	Validate.notNull(activity);
	Validate.notEmpty(activity);
	Validate.notNull(constraint);
	
	//1. Add constraint itself
	//   This also adds the constraint to the list of constraints
	String propertyNameForNewConstraint = addConstraint(constraint);
	
	//2. Add constraint name to the list of constraints for this activity
	Set<String> currentConstraintNames = getConstraintNames(activity);
	currentConstraintNames.add(propertyNameForNewConstraint);
	if(currentConstraintNames.size() == 1){
		//Add the activity to the list of activities with routing constraints
		addActivityWithConstraints(activity);
	}
	props.setProperty(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity), ArrayUtils.toString(currentConstraintNames.toArray()));
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:28,代码来源:ConstraintContextProperties.java

示例4: getConstraint

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
/**
 * Extracts the constraint with the given name in form of a constraint-object.<br>
 * @param constraintName The property-name of the constraint (CONSTRAINT_X)
 * @return The constraint-representation of the constraint-property
 * @throws PropertyException if there is no constraint with the given name or the value cannot be converted into a number- or string-constraint.
 */
private AbstractConstraint<?> getConstraint(String constraintName) throws PropertyException{
	String constraintString = props.getProperty(constraintName);
	if(constraintString == null)
		throw new PropertyException(ConstraintContextProperty.CONSTRAINT, constraintName, "Unparseable constraint");
	AbstractConstraint<?> result = null;
	try{
		result = NumberConstraint.parse(constraintString);
	}catch(Exception e){
		try{
			result = StringConstraint.parse(constraintString);
		}catch(Exception e1){
			throw new PropertyException(ConstraintContextProperty.CONSTRAINT, constraintName, "Unparseable constraint", e1);
		}
	}
	return result;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:23,代码来源:ConstraintContextProperties.java

示例5: addRoutingConstraint

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public final <C extends AbstractConstraint<?>> boolean addRoutingConstraint(String activity, C constraint, boolean notifyListeners) throws CompatibilityException {
        validateActivity(activity);
        Validate.notNull(constraint);
        validateAttribute(constraint.getElement());
        if (!getAttributesFor(activity).contains(constraint.getElement())) {
                throw new CompatibilityException("Cannot add constraint on attribute " + constraint.getElement() + " for activity " + activity + ". Activity does not use attribute.");
        }

        if (!routingConstraints.containsKey(activity)) {
                routingConstraints.put(activity, new HashSet<>());
        }
        if (routingConstraints.get(activity).add(constraint)) {
                if (notifyListeners) {
                        constraintContextListenerSupport.notifyConstraintAdded(activity, constraint);
                }
                return true;
        }
        return false;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:20,代码来源:ConstraintContext.java

示例6: removeRoutingConstraint

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public <C extends AbstractConstraint<?>> boolean removeRoutingConstraint(String activity, C constraint, boolean notifyListeners) throws CompatibilityException {
        validateActivity(activity);
        Validate.notNull(constraint);
        validateAttribute(constraint.getElement());

        if (!routingConstraints.containsKey(activity)) {
                return false;
        }
        if (routingConstraints.get(activity).remove(constraint)) {
                if (notifyListeners) {
                        constraintContextListenerSupport.notifyConstraintRemoved(activity, constraint);
                }
                return true;
        }
        return false;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:17,代码来源:ConstraintContext.java

示例7: updateListConstraints

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
private void updateListConstraints() {
    constraints.clear();
    modelListConstraints.clear();
    String activity = listActivities.getSelectedValue().toString();

    if (activity != null) {
        if (getDialogObject().hasRoutingConstraints(activity)) {
            constraints.addAll(getDialogObject().getRoutingConstraints(activity));
        }
    }

    for (AbstractConstraint<?> constraint : constraints) {
        modelListConstraints.addElement(constraint.toString());
    }
    if (!modelListConstraints.isEmpty()) {
        listConstraints.setSelectedIndex(0);
    }
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:19,代码来源:RoutingConstraintsDialog.java

示例8: setGuardDataContainer

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public void setGuardDataContainer(GuardDataContainer dataContainer) {
	Validate.notNull(dataContainer);

	// Check if data container provides values for all processed data elements (colors)
	if (!dataContainer.getAttributes().containsAll(getProcessedColors()))
		throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Data container must provide values for all data elements processed by this transition.");

	// Check if the type of generated values matches the type of guard attributes.
	for (AbstractConstraint<?> guard : guards) {
		if (!dataContainer.getAttributeValueClass(guard.getElement()).isAssignableFrom(guard.getParameterClass()))
			throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Type of generated values for attribute \"" + guard.getElement() + "\" does not match the expected value type of constraint \"" + guard + "\".");
	}
	this.dataContainer = dataContainer;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:15,代码来源:AbstractRegularIFNetTransition.java

示例9: addGuard

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public boolean addGuard(AbstractConstraint<?> guard) {
	if (dataContainer == null)
		throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Cannot add guard. Please set guard data container first.");
	if (!getProcessedColors().contains(guard.getElement()))
		throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Cannot add constraint for attribute which is not processed by the transition");
	if (!dataContainer.getAttributes().contains(guard.getElement()))
		throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Cannot add constraint for attribute for which the data container does not produce values.");
	if (!guard.getParameterClass().isAssignableFrom(dataContainer.getAttributeValueClass(guard.getElement())))
		throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Type mismatch for guard element and produced values within the assigned data container.\n" + "Guard requires values of type \"" + guard.getParameters()[0].getClass() + "\"\n" + "Generated values are of type \"" + dataContainer.getAttributeValueClass(guard.getElement()) + "\"");
	return guards.add(guard);
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:13,代码来源:AbstractRegularIFNetTransition.java

示例10: removeRoutingConstraint

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public void removeRoutingConstraint(String activity, AbstractConstraint<?> constraint) throws PropertyException{
	Validate.notNull(activity);
	Validate.notEmpty(activity);
	Validate.notNull(constraint);
	//Find name of the given constraint
	Set<String> propertyNamesForActivityConstraints = getConstraintNames(activity);
	if(propertyNamesForActivityConstraints.isEmpty()){
		//This activity has no constraints.
		return;
	}
	String propertyNameForConstraintToRemove = null;
	for(String propertyNameForActivityConstraint: propertyNamesForActivityConstraints){
		AbstractConstraint<?> activityConstraint = getConstraint(propertyNameForActivityConstraint);
		if(activityConstraint.equals(constraint)){
			propertyNameForConstraintToRemove = propertyNameForActivityConstraint;
			break;
		}
	}
	if(propertyNameForConstraintToRemove == null){
		//There is no stored reference to the given constraint to remove
		//-> Removal not necessary
		return;
	}
	
	//1. Remove the constraint itself
	props.remove(propertyNameForConstraintToRemove);
	
	//2. Remove the constraint from the list of constraints
	removeConstraintNameFromList(propertyNameForConstraintToRemove);
	
	//3. Remove the constraint from the activity constraint list.
	Set<String> currentConstraintNames = getConstraintNames(activity);
	currentConstraintNames.remove(propertyNameForConstraintToRemove);
	if(currentConstraintNames.isEmpty()){
		removeActivityWithConstraints(activity);
		props.remove(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity));
	} else {
		props.setProperty(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity), ArrayUtils.toString(currentConstraintNames.toArray()));
	}
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:41,代码来源:ConstraintContextProperties.java

示例11: ConstraintContext

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public ConstraintContext(ConstraintContextProperties properties) throws PropertyException {
        super(properties);
        // Set routing constraints
        routingConstraints.clear();
        for (String activity : properties.getActivitiesWithRoutingConstraints()) {
                Set<AbstractConstraint<?>> otherRoutingConstraints = properties.getRoutingConstraints(activity);
                for (AbstractConstraint<?> routingConstraint : otherRoutingConstraints) {
                        addRoutingConstraint(activity, routingConstraint.clone());
                }
        }
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:12,代码来源:ConstraintContext.java

示例12: removeRoutingConstraintsOnAttribute

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
private void removeRoutingConstraintsOnAttribute(String activity, String attribute, boolean notifyListeners) {
        if (!routingConstraints.containsKey(activity)) {
                return;
        }

        Set<AbstractConstraint<?>> constraintsToRemove = new HashSet<>();
        for (AbstractConstraint<?> c : routingConstraints.get(activity)) {
                if (attribute.equals(c.getElement())) {
                        constraintsToRemove.add(c);
                }
        }
        for (AbstractConstraint<?> constraintToRemove : constraintsToRemove) {
                removeRoutingConstraint(activity, constraintToRemove, notifyListeners);
        }
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:16,代码来源:ConstraintContext.java

示例13: hasRoutingConstraints

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public boolean hasRoutingConstraints(String activity, String attribute) throws CompatibilityException {
        if (!hasRoutingConstraints(activity)) {
                return false;
        }
        validateAttribute(attribute);
        for (AbstractConstraint<?> constraint : getRoutingConstraints(activity)) {
                if (constraint.getElement().equals(attribute)) {
                        return true;
                }
        }
        return false;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:13,代码来源:ConstraintContext.java

示例14: removeRoutingConstraints

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
public <C extends AbstractConstraint<?>> boolean removeRoutingConstraints(String activity, boolean notifyListeners) throws CompatibilityException {
        if (!hasRoutingConstraints(activity)) {
                return false;
        }
        for (AbstractConstraint<?> constraint : getRoutingConstraints(activity)) {
                removeRoutingConstraint(activity, constraint, notifyListeners);
        }
        return true;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:10,代码来源:ConstraintContext.java

示例15: getProperties

import de.invation.code.toval.constraint.AbstractConstraint; //导入依赖的package包/类
@Override
public ConstraintContextProperties getProperties() throws PropertyException {
        ConstraintContextProperties result = (ConstraintContextProperties) super.getProperties();

        for (String activity : getActivities()) {
                Set<AbstractConstraint<?>> routingConstraintsOfActivity = getRoutingConstraints(activity);
                if (routingConstraintsOfActivity != null && !routingConstraintsOfActivity.isEmpty()) {
                        for (AbstractConstraint<?> routingConstraint : routingConstraintsOfActivity) {
                                result.addRoutingConstraint(activity, routingConstraint);
                        }
                }
        }
        return result;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:15,代码来源:ConstraintContext.java


注:本文中的de.invation.code.toval.constraint.AbstractConstraint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。