diff --git a/infer/models/java/src/org/apache/commons/lang3/NOTICE.txt b/infer/models/java/src/org/apache/commons/lang3/NOTICE.txt new file mode 100644 index 000000000..72eb0990a --- /dev/null +++ b/infer/models/java/src/org/apache/commons/lang3/NOTICE.txt @@ -0,0 +1,5 @@ +Apache Commons Lang +Copyright 2001-2020 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (https://www.apache.org/). diff --git a/infer/models/java/src/org/apache/commons/lang3/StringUtils.java b/infer/models/java/src/org/apache/commons/lang3/StringUtils.java new file mode 100644 index 000000000..38a7c5212 --- /dev/null +++ b/infer/models/java/src/org/apache/commons/lang3/StringUtils.java @@ -0,0 +1,53 @@ +/* + * 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. + */ + +/* + * The method below are copied verbatim from: + * https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/StringUtils.java + * to provide a model for biabduction analysis + */ + +package org.apache.commons.lang3; + +public final class StringUtils { + + public static boolean isNotEmpty(final CharSequence cs) { + return !isEmpty(cs); + } + + public static boolean isEmpty(final CharSequence cs) { + return cs == null || cs.length() == 0; + } + + public static boolean isBlank(final CharSequence cs) { + final int strLen = length(cs); + if (strLen == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (!Character.isWhitespace(cs.charAt(i))) { + return false; + } + } + return true; + } + + public static int length(final CharSequence cs) { + return cs == null ? 0 : cs.length(); + } + +}