mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
简化代码
This commit is contained in:
parent
049e54d023
commit
19d67fd1a8
@ -29,10 +29,10 @@ import java.lang.annotation.Target;
|
||||
* <p>
|
||||
* 举例:
|
||||
* <ul>
|
||||
* <li>去掉3长度的后缀并且大写 Ognl#classInfo.className.substring(0, classInfo.className.length() - 3).toUpperCase() </li>
|
||||
* <li>以“APT”结尾 Ognl#classInfo.className + 'APT'</li>
|
||||
* <li>全大写并且以“APT”结尾 Ognl#classInfo.className.toUpperCase() + 'APT' </li>
|
||||
* <li>"PO"结尾替换为“APT”且全大写 Ognl#stringHelper.replaceSuffix(classInfo.className, 'PO', 'APT').toUpperCase() </li>
|
||||
* <li>去掉3长度的后缀并且大写 Ognl#className.substring(0, className.length() - 3).toUpperCase() </li>
|
||||
* <li>以“APT”结尾 Ognl#className + 'APT'</li>
|
||||
* <li>全大写并且以“APT”结尾 Ognl#className.toUpperCase() + 'APT' </li>
|
||||
* <li>"PO"结尾替换为“APT”且全大写 Ognl#util.replaceSuffix(className, 'PO', 'APT').toUpperCase() </li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* 支持 三元运算 String所有方法 如lastIndexOf subString toUpperCase等 Ognl语法<p>
|
||||
|
@ -13,8 +13,14 @@ import java.util.Objects;
|
||||
@Getter
|
||||
public class OgnlRoot {
|
||||
|
||||
/**
|
||||
* 类名
|
||||
*/
|
||||
private final String className;
|
||||
|
||||
/**
|
||||
* 包名
|
||||
*/
|
||||
private final String classPackage;
|
||||
|
||||
private final StringHelper util = new StringHelper();
|
||||
@ -26,6 +32,22 @@ public class OgnlRoot {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final class StringHelper {
|
||||
/**
|
||||
* 移除后缀
|
||||
*
|
||||
* @param str 原字符串
|
||||
* @param suffix 指定后缀
|
||||
*/
|
||||
public String removeSuffix(String str, String suffix) {
|
||||
if (isBlank(str) || isBlank(suffix)) {
|
||||
return str;
|
||||
}
|
||||
if (str.endsWith(suffix)) {
|
||||
return str.substring(0, str.length() - suffix.length());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换后缀
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user