View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3    Copyright (c) 2005 University of Innsbruck, Austria
4                  2005 National University of Ireland, Galway
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  package org.deri.wsmo4j.logicalexpression;
19  
20  
21  import java.util.*;
22  
23  import org.deri.wsmo4j.logicalexpression.util.*;
24  import org.omwg.logicalexpression.*;
25  import org.omwg.ontology.*;
26  
27  
28  /**
29   * @author DERI Innsbruck, reto.krummenacher@deri.org
30   * @author DERI Innsbruck, thomas.haselwanter@deri.org
31   */
32  public class UniversalQuantificationImpl
33          extends QuantifiedImpl
34          implements
35          UniversalQuantification {
36  
37      public UniversalQuantificationImpl(Variable variable, LogicalExpression expr)
38              throws IllegalArgumentException {
39          this(SetUtil.createSet(variable), expr);
40      }
41  
42      public UniversalQuantificationImpl(Set <Variable> variables, LogicalExpression expr)
43              throws IllegalArgumentException {
44          super(variables, expr);
45      }
46  
47      public void accept(Visitor v) {
48          v.visitUniversalQuantification(this);
49      }
50  
51      /**
52       * <p>
53       * The <code>equals</code> method implements an equivalence relation
54       * on non-null object references. Quantified expressions are equal if their operator,
55       * their logical expresssion and their set of variables are equal.
56       * </p>
57       * <p>
58       * It is generally necessary to override the <code>hashCode</code> method whenever this method
59       * is overridden.
60       * </p>
61       * @param o the reference object with which to compare.
62       * @return <code>true</code> if this object is the same as the obj
63       *          argument; <code>false</code> otherwise.
64       * @see java.lang.Object#equals(java.lang.Object)
65       * @see java.lang.Object#hashCode()
66       */
67      public boolean equals(Object o) {
68          if (o instanceof UniversalQuantification) {
69              UniversalQuantification q = (UniversalQuantification)o;
70              if (!variables.equals(q.listVariables())) {
71                  return false;
72              }
73              return expr.equals(q.getOperand());
74          }
75          return false;
76      }
77  }