001/** 002 * Copyright (C) 2007 - 2016, Jens Lehmann 003 * 004 * This file is part of DL-Learner. 005 * 006 * DL-Learner is free software; you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation; either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * DL-Learner is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.dllearner.core.owl; 020 021import java.util.HashSet; 022import java.util.List; 023import java.util.Set; 024 025import org.semanticweb.owlapi.model.ClassExpressionType; 026import org.semanticweb.owlapi.model.OWLClassExpression; 027import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; 028import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; 029import org.semanticweb.owlapi.model.OWLObjectUnionOf; 030import org.semanticweb.owlapi.model.OWLObjectVisitor; 031import org.semanticweb.owlapi.model.OWLObjectVisitorEx; 032import org.semanticweb.owlapi.util.OWLObjectTypeIndexProvider; 033 034/** 035 * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics 036 * Group, Date: 26-Oct-2006 037 */ 038public class OWLObjectUnionOfImplExt extends OWLNaryBooleanClassExpressionImplExt 039 implements OWLObjectUnionOf { 040 041 private static final long serialVersionUID = 30406L; 042 043 @Override 044 protected int index() { 045 return OWLObjectTypeIndexProvider.CLASS_EXPRESSION_TYPE_INDEX_BASE + 2; 046 } 047 048 /** 049 * @param operands 050 * operands 051 */ 052 public OWLObjectUnionOfImplExt(Set<? extends OWLClassExpression> operands) { 053 super(operands); 054 } 055 056 /** 057 * @param operands 058 * operands 059 */ 060 public OWLObjectUnionOfImplExt(List<? extends OWLClassExpression> operands) { 061 super(operands); 062 } 063 064 @Override 065 public ClassExpressionType getClassExpressionType() { 066 return ClassExpressionType.OBJECT_UNION_OF; 067 } 068 069 @Override 070 public boolean equals(Object obj) { 071 if (super.equals(obj)) { 072 return obj instanceof OWLObjectUnionOf; 073 } 074 return false; 075 } 076 077 @Override 078 public Set<OWLClassExpression> asDisjunctSet() { 079 Set<OWLClassExpression> disjuncts = new HashSet<>(); 080 for (OWLClassExpression op : getOperands()) { 081 disjuncts.addAll(op.asDisjunctSet()); 082 } 083 return disjuncts; 084 } 085 086 @Override 087 public void accept(OWLClassExpressionVisitor visitor) { 088 visitor.visit(this); 089 } 090 091 @Override 092 public void accept(OWLObjectVisitor visitor) { 093 visitor.visit(this); 094 } 095 096 @Override 097 public <O> O accept(OWLClassExpressionVisitorEx<O> visitor) { 098 return visitor.visit(this); 099 } 100 101 @Override 102 public <O> O accept(OWLObjectVisitorEx<O> visitor) { 103 return visitor.visit(this); 104 } 105}