Java tutorial
/* * Copyright (C) 2008-2013 Dario Scoppelletti, <http://www.scoppelletti.it/>. * * Licensed 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 it.scoppelletti.mobilepower.types; import org.apache.commons.lang3.*; /** * Funzioni di utilità sulle stringhe. * * @since 1.0 */ public final class StringTools { /** * Costruttore privato per classe statica. */ private StringTools() { } /** * Verifica se due stringhe sono uguali. * * <P>Il metodo {@code equals} della classe statica {@code Strings} * può essere più comodo da usare della coppia di metodi * {@code equals} e {@code equalsIgnoreCase} della classe {@code String} * quando l’indicatore per ignorare o meno la differenza tra i * caratteri maiuscoli e minuscoli è un parametro variabile.</P> * * @param s1 Prima stringa. Può essere {@code null}. * @param s2 Seconda stringa. Può essere {@code null}. * @param ignoreCase Indica se ignorare la differenza tra caratteri * maiuscoli e minuscoli. * @return Esito della verifica. */ public static boolean equals(String s1, String s2, boolean ignoreCase) { if (ignoreCase) { return StringUtils.equalsIgnoreCase(s1, s2); } return StringUtils.equals(s1, s2); } }