apache commons lang3 string utils model (#1346)
Summary: Small model for a couple of StringUtils functions Pull Request resolved: https://github.com/facebook/infer/pull/1346 Reviewed By: ngorogiannis Differential Revision: D25638009 Pulled By: jvillard fbshipit-source-id: 01db6d09emaster
parent
c5a0593be3
commit
366ca37ff9
@ -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/).
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue