X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.mapping%2Fsrc%2Forg%2Fsimantics%2Fmapping%2Fconstraint%2FUnaryPredicateConstraint.java;h=c7142e2d86f75664f260f20cd8827c33a9e93130;hb=refs%2Fchanges%2F38%2F238%2F2;hp=952bf44461f2ad4b525a67858f527c022e57e244;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/UnaryPredicateConstraint.java b/bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/UnaryPredicateConstraint.java index 952bf4446..c7142e2d8 100644 --- a/bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/UnaryPredicateConstraint.java +++ b/bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/UnaryPredicateConstraint.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.mapping.constraint; - -import gnu.trove.map.hash.TObjectIntHashMap; - -import org.simantics.db.Resource; -import org.simantics.layer0.utils.predicates.IUnaryPredicate; -import org.simantics.mapping.constraint.instructions.IInstruction; -import org.simantics.mapping.constraint.instructions.UnaryPredicateInstruction; -import org.simantics.utils.datastructures.persistent.ImmutableSet; - -public class UnaryPredicateConstraint implements IConstraint { - - Resource variable0; - IUnaryPredicate predicate; - - public UnaryPredicateConstraint(IUnaryPredicate predicate, Resource variable0) { - this.predicate = predicate; - this.variable0 = variable0; - } - - @Override - public ImmutableSet binds() { - return ImmutableSet.of(variable0); - } - - @Override - public IInstruction createInstruction( - TObjectIntHashMap variableIds, - ImmutableSet bound) throws TooManyUnboundVariablesException { - if(!bound.contains(variable0)) - throw new TooManyUnboundVariablesException(); - return new UnaryPredicateInstruction(variableIds.get(variable0), predicate); - } - - @Override - public int isApplicable(ImmutableSet bound) { - return bound.contains(variable0) ? Integer.MAX_VALUE : 0; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.mapping.constraint; + +import gnu.trove.map.hash.TObjectIntHashMap; + +import org.simantics.db.Resource; +import org.simantics.layer0.utils.predicates.IUnaryPredicate; +import org.simantics.mapping.constraint.instructions.IInstruction; +import org.simantics.mapping.constraint.instructions.UnaryPredicateInstruction; +import org.simantics.utils.datastructures.persistent.ImmutableSet; + +public class UnaryPredicateConstraint implements IConstraint { + + Resource variable0; + IUnaryPredicate predicate; + + public UnaryPredicateConstraint(IUnaryPredicate predicate, Resource variable0) { + this.predicate = predicate; + this.variable0 = variable0; + } + + @Override + public ImmutableSet binds() { + return ImmutableSet.of(variable0); + } + + @Override + public IInstruction createInstruction( + TObjectIntHashMap variableIds, + ImmutableSet bound) throws TooManyUnboundVariablesException { + if(!bound.contains(variable0)) + throw new TooManyUnboundVariablesException(); + return new UnaryPredicateInstruction(variableIds.get(variable0), predicate); + } + + @Override + public int isApplicable(ImmutableSet bound) { + return bound.contains(variable0) ? Integer.MAX_VALUE : 0; + } + +}