/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.github.tteofili.calabrize.impl;

import java.util.Arrays;
import java.util.Collection;

import com.github.tteofili.calabrize.CalabrianEncoder;

/**
 * An Italian to Calabrian encoder using the V2H algorithm.
 * V2H algorithm transforms each vowel into an 'h' and leaves everything else untouched.
 */
public class V2HCalabrianEncoder implements CalabrianEncoder {

    private static final Collection<Character> vowels = Arrays.asList('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U');

    public String encode(String text) {
        StringBuilder b = new StringBuilder();
        for (char c : text.toCharArray()) {
            if (vowels.contains(c)) {
                b.append('h');
            } else {
                b.append(c);
            }
        }
        return b.toString();
    }
}

@@ -867,43 +867,14 @@
 til.
-Arrays;%0Aimport java.util.Collection
+BitSet
 ;%0A%0Ai
@@ -1178,103 +1178,309 @@
 nal 
-Collection%3CCharacter%3E vowels = Arrays.asList('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U');
+BitSet vowels = new BitSet(10);%0A%0A    static %7B%0A        vowels.set('a');%0A        vowels.set('A');%0A        vowels.set('e');%0A        vowels.set('E');%0A        vowels.set('i');%0A        vowels.set('I');%0A        vowels.set('o');%0A        vowels.set('O');%0A        vowels.set('u');%0A        vowels.set('U');%0A    %7D
 %0A%0A  
@@ -1635,16 +1635,11 @@
 els.
-contains
+get
 (c))

use the biset for faster vowel checks