001/*- 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.context.phonetic; 021 022import ca.uhn.fhir.util.PhoneticEncoderUtil; 023import org.apache.commons.codec.language.Caverphone1; 024import org.apache.commons.codec.language.Caverphone2; 025import org.apache.commons.codec.language.ColognePhonetic; 026import org.apache.commons.codec.language.DoubleMetaphone; 027import org.apache.commons.codec.language.MatchRatingApproachEncoder; 028import org.apache.commons.codec.language.Metaphone; 029import org.apache.commons.codec.language.Nysiis; 030import org.apache.commons.codec.language.RefinedSoundex; 031import org.apache.commons.codec.language.Soundex; 032 033public enum PhoneticEncoderEnum { 034 CAVERPHONE1(new ApacheEncoder("CAVERPHONE1", new Caverphone1())), 035 CAVERPHONE2(new ApacheEncoder("CAVERPHONE2", new Caverphone2())), 036 COLOGNE(new ApacheEncoder("COLOGNE", new ColognePhonetic())), 037 DOUBLE_METAPHONE(new ApacheEncoder("DOUBLE_METAPHONE", new DoubleMetaphone())), 038 MATCH_RATING_APPROACH(new ApacheEncoder("MATCH_RATING_APPROACH", new MatchRatingApproachEncoder())), 039 METAPHONE(new ApacheEncoder("METAPHONE", new Metaphone())), 040 NYSIIS(new ApacheEncoder("NYSIIS", new Nysiis())), 041 NYSIIS_LONG(new ApacheEncoder("NYSIIS_LONG", new Nysiis(false))), 042 REFINED_SOUNDEX(new ApacheEncoder("REFINED_SOUNDEX", new RefinedSoundex())), 043 SOUNDEX(new ApacheEncoder("SOUNDEX", new Soundex())), 044 NUMERIC(new NumericEncoder()); 045 046 private final IPhoneticEncoder myPhoneticEncoder; 047 048 /** 049 * Do not construct this enum via constructor. 050 * 051 * Use {@link PhoneticEncoderUtil} instead. 052 */ 053 @Deprecated 054 PhoneticEncoderEnum(IPhoneticEncoder thePhoneticEncoder) { 055 myPhoneticEncoder = thePhoneticEncoder; 056 } 057 058 /** 059 * Use PhoneticEncoderWrapper.getEncoderWrapper(PhoneticEncoderEnum.name()) 060 * 061 * This is a deprecated method of getting the encoder (as they 062 * are static across the server and non-configurable). 063 */ 064 @Deprecated 065 public IPhoneticEncoder getPhoneticEncoder() { 066 return myPhoneticEncoder; 067 } 068}