io.ebeaninternal.dbmigration.ddlgeneration.platform.util.VowelRemover Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean-ddlgen Show documentation
Show all versions of ebean-ddlgen Show documentation
DDL and DB Migration generation
The newest version!
package io.ebeaninternal.dbmigration.ddlgeneration.platform.util;
/**
* Utility to remove vowels (from constraint names primarily for Oracle and DB2).
*/
public class VowelRemover {
/**
* Trim a word by removing vowels skipping some initial characters.
*/
public static String trim(String word, int skipChars) {
if (word.length() < skipChars) {
return word;
}
StringBuilder res = new StringBuilder();
res.append(word.substring(0, skipChars));
for (int i = skipChars; i < word.length(); i++) {
char ch = word.charAt(i);
if (!isVowel(ch)) {
res.append(ch);
}
}
return res.toString();
}
private static boolean isVowel(char ch) {
ch = Character.toLowerCase(ch);
return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
}
}