001package conexp.fx.core.dl; 002 003/* 004 * #%L 005 * Concept Explorer FX 006 * %% 007 * Copyright (C) 2010 - 2019 Francesco Kriegel 008 * %% 009 * This program is free software: you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as 011 * published by the Free Software Foundation, either version 3 of the 012 * License, or (at your option) any later version. 013 * 014 * This program is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public 020 * License along with this program. If not, see 021 * <http://www.gnu.org/licenses/gpl-3.0.html>. 022 * #L% 023 */ 024 025import java.util.Arrays; 026 027import org.semanticweb.owlapi.model.IRI; 028 029import com.google.common.collect.Collections2; 030 031import conexp.fx.core.collections.setlist.HashSetArrayList; 032import conexp.fx.core.collections.setlist.SetList; 033 034public final class Signature { 035 036 private final IRI baseIRI; 037 private final SetList<IRI> conceptNames = new HashSetArrayList<IRI>(); 038 private final SetList<IRI> roleNames = new HashSetArrayList<IRI>(); 039 private final SetList<IRI> individualNames = new HashSetArrayList<IRI>(); 040 041 public Signature(final IRI baseIRI) { 042 super(); 043 this.baseIRI = baseIRI; 044 } 045 046 public final IRI getBaseIRI() { 047 return baseIRI; 048 } 049 050 public final SetList<IRI> getConceptNames() { 051 return conceptNames; 052 } 053 054 public final SetList<IRI> getRoleNames() { 055 return roleNames; 056 } 057 058 public final SetList<IRI> getIndividualNames() { 059 return individualNames; 060 } 061 062 public final boolean addConceptNames(final IRI... conceptNames) { 063 return this.conceptNames.addAll(Arrays.asList(conceptNames)); 064 } 065 066 public final boolean addConceptNames(final String... conceptNames) { 067 return this.conceptNames.addAll(Collections2.transform(Arrays.asList(conceptNames), IRI::create)); 068 } 069 070 public final boolean addRoleNames(final IRI... roleNames) { 071 return this.roleNames.addAll(Arrays.asList(roleNames)); 072 } 073 074 public final boolean addRoleNames(final String... roleNames) { 075 return this.roleNames.addAll(Collections2.transform(Arrays.asList(roleNames), IRI::create)); 076 } 077 078 public final boolean addIndividualNames(final IRI... individualNames) { 079 return this.individualNames.addAll(Arrays.asList(individualNames)); 080 } 081 082 public final boolean addIndividualNames(final String... individualNames) { 083 return this.individualNames.addAll(Collections2.transform(Arrays.asList(individualNames), IRI::create)); 084 } 085 086 @Override 087 public final boolean equals(final Object obj) { 088 if (!(obj instanceof Signature)) 089 return false; 090 final Signature other = (Signature) obj; 091 return this.getConceptNames().equals(other.getConceptNames()) && this.getRoleNames().equals(other.getRoleNames()) 092 && this.getIndividualNames().equals(other.getIndividualNames()); 093 } 094 095 @Override 096 public final int hashCode() { 097 return 17 + 23 * conceptNames.hashCode() + 29 * roleNames.hashCode() + 31 * individualNames.hashCode(); 098 } 099 100 @Override 101 public final String toString() { 102 final StringBuilder sb = new StringBuilder(); 103 sb.append(" concept names: " + conceptNames.toString() + "\r\n"); 104 sb.append(" role names: " + roleNames.toString() + "\r\n"); 105 sb.append("individual names: " + individualNames.toString() + "\r\n"); 106 return sb.toString(); 107 } 108 109}