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.OWLObjectIntersectionOf; 030import org.semanticweb.owlapi.model.OWLObjectVisitor; 031import org.semanticweb.owlapi.model.OWLObjectVisitorEx; 032import org.semanticweb.owlapi.util.OWLObjectTypeIndexProvider; 033 034/** 035 * 036 * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics 037 * Group, Date: 26-Oct-2006 038 * 039 * modified by 040 * @author Lorenz Buehmann 041 * @since Jan 24, 2015 042 * 043 * Modification: extend modified super class 044 */ 045public class OWLObjectIntersectionOfImplExt extends 046 OWLNaryBooleanClassExpressionImplExt implements OWLObjectIntersectionOf { 047 048 private static final long serialVersionUID = 30406L; 049 050 @Override 051 protected int index() { 052 return OWLObjectTypeIndexProvider.CLASS_EXPRESSION_TYPE_INDEX_BASE + 1; 053 } 054 055 /** 056 * @param operands 057 * operands 058 */ 059 public OWLObjectIntersectionOfImplExt( 060 Set<? extends OWLClassExpression> operands) { 061 super(operands); 062 } 063 064 /** 065 * @param operands 066 * operands 067 */ 068 public OWLObjectIntersectionOfImplExt( 069 List<? extends OWLClassExpression> operands) { 070 super(operands); 071 } 072 073 @Override 074 public ClassExpressionType getClassExpressionType() { 075 return ClassExpressionType.OBJECT_INTERSECTION_OF; 076 } 077 078 @Override 079 public boolean equals(Object obj) { 080 if (super.equals(obj)) { 081 return obj instanceof OWLObjectIntersectionOf; 082 } 083 return false; 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(OWLObjectVisitorEx<O> visitor) { 098 return visitor.visit(this); 099 } 100 101 @Override 102 public <O> O accept(OWLClassExpressionVisitorEx<O> visitor) { 103 return visitor.visit(this); 104 } 105 106 @Override 107 public Set<OWLClassExpression> asConjunctSet() { 108 Set<OWLClassExpression> conjuncts = new HashSet<>(); 109 for (OWLClassExpression op : getOperands()) { 110 conjuncts.addAll(op.asConjunctSet()); 111 } 112 return conjuncts; 113 } 114 115 @Override 116 public boolean containsConjunct(OWLClassExpression ce) { 117 if (ce.equals(this)) { 118 return true; 119 } 120 for (OWLClassExpression op : getOperands()) { 121 if (op.containsConjunct(ce)) { 122 return true; 123 } 124 } 125 return false; 126 } 127 128}