001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * Copyright © 2004-2024 Open Geospatial Consortium, Inc. 004 * http://www.geoapi.org 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.opengis.metadata.citation; 019 020import java.util.Collection; 021import java.util.Collections; 022import org.opengis.annotation.UML; 023import org.opengis.annotation.Classifier; 024import org.opengis.annotation.Stereotype; 025 026import static org.opengis.annotation.Obligation.*; 027import static org.opengis.annotation.Specification.*; 028 029 030/** 031 * Telephone numbers for contacting the responsible individual or organization. 032 * 033 * @author Martin Desruisseaux (IRD) 034 * @author Cory Horner (Refractions Research) 035 * @author Rémi Maréchal (Geomatys) 036 * @version 3.1 037 * @since 1.0 038 * 039 * @see Contact#getPhones() 040 */ 041@Classifier(Stereotype.DATATYPE) 042@UML(identifier="CI_Telephone", specification=ISO_19115) 043public interface Telephone { 044 /** 045 * Telephone number by which individuals can contact responsible organisation or individual. 046 * 047 * @return telephone number by which individuals can contact responsible organisation or individual. 048 * 049 * @since 3.1 050 */ 051 @UML(identifier="number", obligation=MANDATORY, specification=ISO_19115) 052 String getNumber(); 053 054 /** 055 * Type of telephone number, or {@code null} if none. 056 * 057 * @return type of telephone number, or {@code null} if none. 058 * 059 * @since 3.1 060 */ 061 @UML(identifier="numberType", obligation=OPTIONAL, specification=ISO_19115) 062 default TelephoneType getNumberType() { 063 return null; 064 } 065 066 /** 067 * Telephone numbers by which individuals can speak to the responsible organization or individual. 068 * 069 * @return telephone numbers by which individuals can speak to the responsible organization or individual. 070 * 071 * @deprecated As of ISO 19115:2014, replaced by a {@linkplain #getNumber() number} 072 * with {@link TelephoneType#VOICE}. 073 */ 074 @Deprecated(since="3.1") 075 @UML(identifier="voice", obligation=OPTIONAL, specification=ISO_19115, version=2003) 076 default Collection<String> getVoices() { 077 if (TelephoneType.VOICE.equals(getNumberType())) { 078 String number = getNumber(); 079 if (number != null) { 080 return Collections.singleton(number); 081 } 082 } 083 return Collections.emptySet(); // Use Set instead of List for hash-safe final classes. 084 } 085 086 /** 087 * Telephone numbers of a facsimile machine for the responsible organization or individual. 088 * 089 * @return telephone numbers of a facsimile machine for the responsible organization or individual. 090 * 091 * @deprecated As of ISO 19115:2014, replaced by a {@linkplain #getNumber() number} 092 * with {@link TelephoneType#FACSIMILE}. 093 */ 094 @Deprecated(since="3.1") 095 @UML(identifier="facsimile", obligation=OPTIONAL, specification=ISO_19115, version=2003) 096 default Collection<String> getFacsimiles() { 097 if (TelephoneType.FACSIMILE.equals(getNumberType())) { 098 String number = getNumber(); 099 if (number != null) { 100 return Collections.singleton(number); 101 } 102 } 103 return Collections.emptySet(); // Use Set instead of List for hash-safe final classes. 104 } 105}