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