Java String Equal isEqual(String str, String str2, boolean isCaseSensitive)

Here you can find the source of isEqual(String str, String str2, boolean isCaseSensitive)

Description

is Equal

License

Open Source License

Declaration

public static boolean isEqual(String str, String str2, boolean isCaseSensitive) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Salesforce.com, inc..
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * //from  w w w  . jav a 2s  .c  o  m
 * Contributors:
 *     Salesforce.com, inc. - initial API and implementation
 ******************************************************************************/

import java.util.Collection;

import java.util.List;

import java.util.Map;

public class Main {
    public static boolean isEqual(String str, String str2, boolean isCaseSensitive) {
        return isNotEmpty(str) && isNotEmpty(str2) ? isCaseSensitive ? str.equals(str2) : str.equalsIgnoreCase(str2)
                : false;
    }

    public static boolean isEqual(String str, String compareStr) {
        return isNotEmpty(str) && isNotEmpty(compareStr) && str.equals(compareStr);
    }

    public static boolean isNotEmpty(Object obj) {
        return !isEmpty(obj);
    }

    public static boolean isNotEmpty(Object[] objs) {
        return !isEmpty(objs);
    }

    public static boolean isNotEmpty(byte[] objs) {
        return !isEmpty(objs);
    }

    public static boolean isNotEmpty(Collection<?> col) {
        return !isEmpty(col);
    }

    public static boolean isNotEmpty(List<?> col) {
        return !isEmpty(col);
    }

    public static boolean isNotEmpty(Map<?, ?> map) {
        return map != null && !map.isEmpty();
    }

    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    public static boolean isEmpty(Object obj) {
        return obj == null;
    }

    public static boolean isEmpty(Object[] objs) {
        return objs == null || objs.length == 0;
    }

    public static boolean isEmpty(byte[] objs) {
        return objs == null || objs.length == 0;
    }

    public static boolean isEmpty(Collection<?> col) {
        return col == null || col.isEmpty();
    }

    public static boolean isEmpty(List<?> col) {
        return col == null || col.isEmpty();
    }

    public static boolean isEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }
}

Related

  1. equalsCaseless(String sA_, String sB_)
  2. equalsIgnoreCase(String s1, String s2)
  3. equalsIgnoreCase(String source, String query)
  4. equalsOrExceeds(String version, String threshold)
  5. getEquality(String str1, String str2)
  6. pathEquals(String path1, String path2)
  7. pathEquals(String path1, String path2)
  8. pathEquals(String path1, String path2)