From 7fd4b41c88efd8a0c461824b732ea6a42874e609 Mon Sep 17 00:00:00 2001 From: qtvbwfn Date: Fri, 20 Aug 2021 11:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E7=85=A7=E9=98=BF=E9=87=8C=E5=B7=B4?= =?UTF-8?q?=E5=B7=B4Java=E8=A7=84=E7=BA=A6=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=A6=82=E4=B8=8B=EF=BC=9A=201.=E5=8A=A0@Override=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=87=86=E7=A1=AE=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E6=88=90=E5=8A=9F=E3=80=82=E5=8F=A6=E5=A4=96?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=9C=A8=E6=8A=BD=E8=B1=A1=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E5=AF=B9=E6=96=B9=E6=B3=95=E7=AD=BE=E5=90=8D=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=85=B6=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=B1=BB=E4=BC=9A=E9=A9=AC=E4=B8=8A=E7=BC=96=E8=AF=91=E6=8A=A5?= =?UTF-8?q?=E9=94=99=202.Object=20=E7=9A=84=20equals=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=AE=B9=E6=98=93=E6=8A=9B=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=EF=BC=8C=E5=BA=94=E4=BD=BF=E7=94=A8=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E6=88=96=E7=A1=AE=E5=AE=9A=E6=9C=89=E5=80=BC=E7=9A=84=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E6=9D=A5=E8=B0=83=E7=94=A8equals=203.=E5=9C=A8=20if/e?= =?UTF-8?q?lse/for/while/do=20=E8=AF=AD=E5=8F=A5=E4=B8=AD=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E4=BD=BF=E7=94=A8=E5=A4=A7=E6=8B=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DBReverseGetAllTablesListImpl.java | 1 + .../impl/DBReverseGetTableDDLImpl.java | 1 + .../chiner/java/command/impl/GenDocxImpl.java | 1 + .../java/command/impl/ParsePDMFileImpl.java | 1 + .../command/impl/PingLoadDriverClassImpl.java | 1 + .../cn/com/chiner/java/dialect/DBDialect.java | 6 +- .../java/dialect/impl/DBDialectDB2.java | 2 + .../chiner/java/dialect/impl/DBDialectDM.java | 1 + .../java/dialect/impl/DBDialectMySQL.java | 2 + .../java/dialect/impl/DBDialectOracle.java | 1 + .../java/dialect/impl/DBDialectSQLServer.java | 2 + .../cn/com/chiner/java/model/ColumnField.java | 6 +- .../cn/com/chiner/java/model/TableEntity.java | 10 +++- .../java/cn/fisok/raw/holder/DateHolder.java | 4 +- .../java/cn/fisok/raw/io/ByteInputStream.java | 18 ++++-- .../cn/fisok/raw/io/ByteOutputStream.java | 3 + src/main/java/cn/fisok/raw/kit/DateKit.java | 36 ++++++++---- src/main/java/cn/fisok/raw/kit/FileKit.java | 16 ++++-- src/main/java/cn/fisok/raw/kit/IOKit.java | 12 +++- src/main/java/cn/fisok/raw/kit/StringKit.java | 23 ++++++-- .../java/cn/fisok/raw/lang/ValueObject.java | 57 ++++++++++++++----- 21 files changed, 152 insertions(+), 52 deletions(-) diff --git a/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetAllTablesListImpl.java b/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetAllTablesListImpl.java index a1d2b41..7217f92 100644 --- a/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetAllTablesListImpl.java +++ b/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetAllTablesListImpl.java @@ -36,6 +36,7 @@ import java.util.Map; */ public class DBReverseGetAllTablesListImpl extends AbstractDBCommand { + @Override public ExecResult exec(Map params) { super.init(params); ExecResult ret = new ExecResult(); diff --git a/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetTableDDLImpl.java b/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetTableDDLImpl.java index 40bbdb9..fa28b68 100644 --- a/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetTableDDLImpl.java +++ b/src/main/java/cn/com/chiner/java/command/impl/DBReverseGetTableDDLImpl.java @@ -37,6 +37,7 @@ import java.util.stream.Collectors; * @desc : 数据库逆向,解析表清单的字段以及索引 */ public class DBReverseGetTableDDLImpl extends AbstractDBCommand { + @Override public ExecResult exec(Map params) { super.init(params); String tables = params.get("tables").toUpperCase(); diff --git a/src/main/java/cn/com/chiner/java/command/impl/GenDocxImpl.java b/src/main/java/cn/com/chiner/java/command/impl/GenDocxImpl.java index 26318d9..aea9ae8 100644 --- a/src/main/java/cn/com/chiner/java/command/impl/GenDocxImpl.java +++ b/src/main/java/cn/com/chiner/java/command/impl/GenDocxImpl.java @@ -46,6 +46,7 @@ import java.util.Map; public class GenDocxImpl implements Command { protected Logger logger = LoggerFactory.getLogger(getClass()); + @Override public ExecResult exec(Map params) { String sinerFile = params.get("sinerFile"); String docxTpl = params.get("docxTpl"); diff --git a/src/main/java/cn/com/chiner/java/command/impl/ParsePDMFileImpl.java b/src/main/java/cn/com/chiner/java/command/impl/ParsePDMFileImpl.java index 9521fd7..f32c127 100644 --- a/src/main/java/cn/com/chiner/java/command/impl/ParsePDMFileImpl.java +++ b/src/main/java/cn/com/chiner/java/command/impl/ParsePDMFileImpl.java @@ -45,6 +45,7 @@ import java.util.*; public class ParsePDMFileImpl implements Command { protected Logger logger = LoggerFactory.getLogger(getClass()); + @Override public ExecResult exec(Map params) { String pdmFile = params.get("pdmFile"); diff --git a/src/main/java/cn/com/chiner/java/command/impl/PingLoadDriverClassImpl.java b/src/main/java/cn/com/chiner/java/command/impl/PingLoadDriverClassImpl.java index d2a8db9..8e1310f 100644 --- a/src/main/java/cn/com/chiner/java/command/impl/PingLoadDriverClassImpl.java +++ b/src/main/java/cn/com/chiner/java/command/impl/PingLoadDriverClassImpl.java @@ -29,6 +29,7 @@ import java.util.Map; * @desc : 数据库驱动程序加载测试 */ public class PingLoadDriverClassImpl extends AbstractDBCommand { + @Override public ExecResult exec(Map params) { super.init(params); ExecResult ret = new ExecResult(); diff --git a/src/main/java/cn/com/chiner/java/dialect/DBDialect.java b/src/main/java/cn/com/chiner/java/dialect/DBDialect.java index 4748d13..01342fa 100644 --- a/src/main/java/cn/com/chiner/java/dialect/DBDialect.java +++ b/src/main/java/cn/com/chiner/java/dialect/DBDialect.java @@ -277,9 +277,9 @@ public class DBDialect { * SQL Server系统保留表 * trace_xe_action_map,trace_xe_event_map */ - if (!tableName.equalsIgnoreCase("PDMAN_DB_VERSION") - && !tableName.equalsIgnoreCase("trace_xe_action_map") - && !tableName.equalsIgnoreCase("trace_xe_event_map")){ + if (!"PDMAN_DB_VERSION".equalsIgnoreCase(tableName) + && !"trace_xe_action_map".equalsIgnoreCase(tableName) + && !"trace_xe_event_map".equalsIgnoreCase(tableName)){ TableEntity entity = createTableEntity(conn,rs); if(entity != null){ tableEntities.add(entity); diff --git a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDB2.java b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDB2.java index e8e37d4..c2285e4 100644 --- a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDB2.java +++ b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDB2.java @@ -26,11 +26,13 @@ import java.sql.SQLException; * @desc : DB2数据库方言 */ public class DBDialectDB2 extends DBDialect { + @Override public String getSchemaPattern(Connection conn) throws SQLException { // return conn.getMetaData().getUserName().toUpperCase(); return "jence_user"; } + @Override public String getTableNamePattern(Connection conn) throws SQLException { return "%"; } diff --git a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDM.java b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDM.java index ac90b95..c3c0d20 100644 --- a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDM.java +++ b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectDM.java @@ -27,6 +27,7 @@ import java.sql.SQLException; * @desc : 达梦数据库方言 */ public class DBDialectDM extends DBDialect { + @Override public String getSchemaPattern(Connection conn) throws SQLException { String schemaPattern = conn.getMetaData().getUserName().toUpperCase(); if (StringKit.isNotBlank(schemaPattern)) { diff --git a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectMySQL.java b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectMySQL.java index 93c9753..a51b4d3 100644 --- a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectMySQL.java +++ b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectMySQL.java @@ -28,12 +28,14 @@ import java.util.Set; */ public class DBDialectMySQL extends DBDialect { + @Override public String getSchemaPattern(Connection conn) throws SQLException { //原本应该取dbName,但是目前没有找到好的办法从URL中解析出来 //schemaPattern = dbname; return null; } + @Override public void fillColumnField(ColumnField field, Connection conn, ResultSet rs, Set pkSet) throws SQLException { super.fillColumnField(field, conn, rs, pkSet); int dataType = rs.getInt("DATA_TYPE"); diff --git a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectOracle.java b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectOracle.java index 35a751f..54314d5 100644 --- a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectOracle.java +++ b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectOracle.java @@ -28,6 +28,7 @@ import java.sql.SQLException; */ public class DBDialectOracle extends DBDialect { + @Override public String getSchemaPattern(Connection conn) throws SQLException { String schemaPattern = conn.getMetaData().getUserName().toUpperCase(); if (StringKit.isNotBlank(schemaPattern)) { diff --git a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectSQLServer.java b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectSQLServer.java index e87cec5..9fe8038 100644 --- a/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectSQLServer.java +++ b/src/main/java/cn/com/chiner/java/dialect/impl/DBDialectSQLServer.java @@ -92,6 +92,7 @@ public class DBDialectSQLServer extends DBDialect { "\ta.id,\n" + "\ta.colorder;"; + @Override public String getTableNamePattern(Connection conn) throws SQLException { return "%"; } @@ -103,6 +104,7 @@ public class DBDialectSQLServer extends DBDialect { * @return * @throws SQLException */ + @Override public Pair getColumnAndPrimaryKeyResultSetPair(Connection conn, String tableName) throws SQLException { DatabaseMetaData connMetaData = conn.getMetaData(); String schema = getSchemaPattern(conn); diff --git a/src/main/java/cn/com/chiner/java/model/ColumnField.java b/src/main/java/cn/com/chiner/java/model/ColumnField.java index e80e07f..a99ebde 100644 --- a/src/main/java/cn/com/chiner/java/model/ColumnField.java +++ b/src/main/java/cn/com/chiner/java/model/ColumnField.java @@ -221,13 +221,13 @@ public class ColumnField implements Serializable,Cloneable { } typeFullName = buffer.toString(); - if(primaryKey == Boolean.TRUE){ + if(primaryKey.equals(Boolean.TRUE)){ primaryKeyName = "√"; } - if(notNull == Boolean.TRUE){ + if(notNull.equals(Boolean.TRUE)){ notNullName = "√"; } - if(autoIncrement == Boolean.TRUE){ + if(autoIncrement.equals(Boolean.TRUE)){ autoIncrementName = "√"; } if(StringKit.isNotBlank(refDict)){ diff --git a/src/main/java/cn/com/chiner/java/model/TableEntity.java b/src/main/java/cn/com/chiner/java/model/TableEntity.java index 5c570b1..b2b3dce 100644 --- a/src/main/java/cn/com/chiner/java/model/TableEntity.java +++ b/src/main/java/cn/com/chiner/java/model/TableEntity.java @@ -136,14 +136,20 @@ public class TableEntity implements Serializable,Cloneable { } } + @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } TableEntity entity = (TableEntity) o; return Objects.equals(defKey, entity.defKey) && Objects.equals(defName, entity.defName); } + @Override public int hashCode() { return Objects.hash(defKey, defName); } diff --git a/src/main/java/cn/fisok/raw/holder/DateHolder.java b/src/main/java/cn/fisok/raw/holder/DateHolder.java index 1ebb87a..4953825 100644 --- a/src/main/java/cn/fisok/raw/holder/DateHolder.java +++ b/src/main/java/cn/fisok/raw/holder/DateHolder.java @@ -26,7 +26,9 @@ public abstract class DateHolder { private static final ThreadLocal dateHolder = new ThreadLocal(); public static Date getDate(){ Date retDate = dateHolder.get(); - if(retDate == null) retDate = new Date(); + if(retDate == null) { + retDate = new Date(); + } return retDate; } public static void setDate(Date date){ diff --git a/src/main/java/cn/fisok/raw/io/ByteInputStream.java b/src/main/java/cn/fisok/raw/io/ByteInputStream.java index 66c00c7..fe93066 100644 --- a/src/main/java/cn/fisok/raw/io/ByteInputStream.java +++ b/src/main/java/cn/fisok/raw/io/ByteInputStream.java @@ -44,41 +44,51 @@ public class ByteInputStream extends InputStream { this.count = count; } + @Override public final int available() { return count - pos; } + @Override public final int read() { return (pos < count) ? (buf[pos++] & 0xff) : -1; } + @Override public final int read(byte[] b, int off, int len) { - if (pos >= count) + if (pos >= count) { return -1; + } - if ((pos + len) > count) + if ((pos + len) > count) { len = (count - pos); + } System.arraycopy(buf, pos, b, off, len); pos += len; return len; } + @Override public final long skip(long n) { - if ((pos + n) > count) + if ((pos + n) > count) { n = count - pos; - if (n < 0) + } + if (n < 0) { return 0; + } pos += n; return n; } + @Override public void close() throws IOException { super.close(); buf = null; count = 0; } + @Override public synchronized void reset() { pos = 0; } diff --git a/src/main/java/cn/fisok/raw/io/ByteOutputStream.java b/src/main/java/cn/fisok/raw/io/ByteOutputStream.java index 198e7bf..2bfcc7c 100644 --- a/src/main/java/cn/fisok/raw/io/ByteOutputStream.java +++ b/src/main/java/cn/fisok/raw/io/ByteOutputStream.java @@ -60,18 +60,21 @@ public class ByteOutputStream extends OutputStream { return size; } + @Override public final void write(byte b[]) { verifyBufferSize(size + b.length); System.arraycopy(b, 0, buf, size, b.length); size += b.length; } + @Override public final void write(byte b[], int off, int len) { verifyBufferSize(size + len); System.arraycopy(b, off, buf, size, len); size += len; } + @Override public final void write(int b) { verifyBufferSize(size + 1); buf[size++] = (byte) b; diff --git a/src/main/java/cn/fisok/raw/kit/DateKit.java b/src/main/java/cn/fisok/raw/kit/DateKit.java index 5edcae3..c774f76 100644 --- a/src/main/java/cn/fisok/raw/kit/DateKit.java +++ b/src/main/java/cn/fisok/raw/kit/DateKit.java @@ -257,10 +257,11 @@ public abstract class DateKit { * @return boolean */ public static boolean isSameDay(Date startDate, Date endDate) { - if (getRangeDays(startDate, endDate) == 0) + if (getRangeDays(startDate, endDate) == 0) { return true; - else + } else { return false; + } } public static Date plusYears(Date startDate, int plusValue) { @@ -413,8 +414,11 @@ public abstract class DateKit { if(r == 1){ return true; }else if(r == 0){ - if(containEquals)return true; - else return false; + if(containEquals) { + return true; + } else { + return false; + } }else{ return false; } @@ -503,8 +507,9 @@ public abstract class DateKit { */ public static Date getMondayOfWeek(Date curDate) { Calendar cal = Calendar.getInstance(); - if (null != curDate) + if (null != curDate) { cal.setTime(curDate); + } cal.setTime(curDate); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == 1) { @@ -522,8 +527,9 @@ public abstract class DateKit { */ public static Date getSundayOfWeek(Date curDate) { Calendar cal = Calendar.getInstance(); - if (null != curDate) + if (null != curDate) { cal.setTime(curDate); + } cal.setTime(getMondayOfWeek(curDate)); cal.add(Calendar.DAY_OF_WEEK, 6); Date weekEndSta = cal.getTime(); @@ -538,8 +544,9 @@ public abstract class DateKit { */ public static Date getFirstDayOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); - if (null != date) + if (null != date) { calendar.setTime(date); + } calendar.set(DateKit.getYear(date), DateKit.getMonth(date) - 1, 1); return getDayStartTime(calendar.getTime()); } @@ -552,8 +559,9 @@ public abstract class DateKit { */ public static Date getLastDayOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); - if (null != date) + if (null != date) { calendar.setTime(date); + } calendar.set(DateKit.getYear(date), DateKit.getMonth(date) - 1, 1); int day = calendar.getActualMaximum(5); calendar.set(DateKit.getYear(date), DateKit.getMonth(date) - 1, day); @@ -568,8 +576,9 @@ public abstract class DateKit { */ private static Date getDayStartTime(Date date) { Calendar calendar = Calendar.getInstance(); - if (null != date) + if (null != date) { calendar.setTime(date); + } calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); @@ -585,8 +594,9 @@ public abstract class DateKit { */ private static Date getDayEndTime(Date date) { Calendar calendar = Calendar.getInstance(); - if (null != date) + if (null != date) { calendar.setTime(date); + } calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59); calendar.set(Calendar.MILLISECOND, 999); @@ -631,8 +641,9 @@ public abstract class DateKit { */ public static Date getBeginDayOfYear(Date date) { Calendar cal = Calendar.getInstance(); - if (null != date) + if (null != date) { cal.setTime(date); + } cal.set(Calendar.YEAR, DateKit.getYear(date)); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DATE, 1); @@ -647,8 +658,9 @@ public abstract class DateKit { */ public static Date getEndDayOfYear(Date date) { Calendar cal = Calendar.getInstance(); - if (null != date) + if (null != date) { cal.setTime(date); + } cal.set(Calendar.YEAR, DateKit.getYear(date)); cal.set(Calendar.MONTH, Calendar.DECEMBER); cal.set(Calendar.DATE, 31); diff --git a/src/main/java/cn/fisok/raw/kit/FileKit.java b/src/main/java/cn/fisok/raw/kit/FileKit.java index f254798..8963b48 100644 --- a/src/main/java/cn/fisok/raw/kit/FileKit.java +++ b/src/main/java/cn/fisok/raw/kit/FileKit.java @@ -96,7 +96,9 @@ public abstract class FileKit { * @return File */ public static File touchFile(File file,boolean cleanFile) throws IOException { - if(cleanFile&&file.exists()) FileKit.deleteFile(file); + if(cleanFile&&file.exists()) { + FileKit.deleteFile(file); + } if(!file.exists()){ File parentFile = file.getParentFile(); if(!parentFile.exists()){ @@ -157,7 +159,9 @@ public abstract class FileKit { if(autoCreate&&!file.exists()){ File parent = file.getParentFile(); - if(!parent.exists())parent.mkdirs(); + if(!parent.exists()) { + parent.mkdirs(); + } file.createNewFile(); } try { @@ -214,7 +218,9 @@ public abstract class FileKit { } public static String convertSizeText(Long size) { - if (size == null || size == 0) return "0K"; + if (size == null || size == 0) { + return "0K"; + } String text = ""; Double size1 = size.doubleValue(); text = decimalFormat.format(size1) + "B"; @@ -242,7 +248,9 @@ public abstract class FileKit { */ public static String getSuffix(String file){ String suffix = ""; - if(StringUtils.isBlank(file)) return suffix; + if(StringUtils.isBlank(file)) { + return suffix; + } String[] ss = file.split("\\."); if(ss.length>1){ suffix = ss[ss.length-1]; diff --git a/src/main/java/cn/fisok/raw/kit/IOKit.java b/src/main/java/cn/fisok/raw/kit/IOKit.java index 9608534..df2d4a4 100644 --- a/src/main/java/cn/fisok/raw/kit/IOKit.java +++ b/src/main/java/cn/fisok/raw/kit/IOKit.java @@ -30,7 +30,9 @@ import java.io.*; public abstract class IOKit extends IOUtils { public static void close(Closeable stream) { try { - if (stream != null) stream.close(); + if (stream != null) { + stream.close(); + } } catch (IOException e) { new RawException("close {0} error", stream.getClass().getName()); } @@ -38,7 +40,9 @@ public abstract class IOKit extends IOUtils { public static void close(AutoCloseable stream) { try { - if (stream != null) stream.close(); + if (stream != null) { + stream.close(); + } } catch (Exception e) { new RawException("close {0} error", stream.getClass().getName()); } @@ -74,7 +78,9 @@ public abstract class IOKit extends IOUtils { @SuppressWarnings("deprecation") public static byte[] convertToBytes(InputStream inputStream, boolean isClose) throws IOException { ByteOutputStream byteBuffer = convertToByteArrayBuffer(inputStream); - if (isClose) IOKit.close(inputStream); + if (isClose) { + IOKit.close(inputStream); + } // return byteBuffer.toByteArray(); return byteBuffer.toBytes(); } diff --git a/src/main/java/cn/fisok/raw/kit/StringKit.java b/src/main/java/cn/fisok/raw/kit/StringKit.java index 4118db4..7e964cd 100644 --- a/src/main/java/cn/fisok/raw/kit/StringKit.java +++ b/src/main/java/cn/fisok/raw/kit/StringKit.java @@ -51,7 +51,9 @@ public abstract class StringKit extends StringUtils { ss = String.valueOf(s); } - if (StringUtils.isEmpty(ss)) return s1; + if (StringUtils.isEmpty(ss)) { + return s1; + } return ss; } @@ -273,7 +275,9 @@ public abstract class StringKit extends StringUtils { // .collect(Collectors.toList()); // return join(strArray,"_"); - if (StringKit.isBlank(property)) return property; + if (StringKit.isBlank(property)) { + return property; + } char[] chars = property.toCharArray(); StringBuffer sb = new StringBuffer(); @@ -319,7 +323,9 @@ public abstract class StringKit extends StringUtils { // .map(s -> lowerCase(s)) // .map(s -> capitalize(s)) // .collect(Collectors.toList()); - if (StringKit.isBlank(str)) return str; + if (StringKit.isBlank(str)) { + return str; + } String[] strs = split(str, delimiter); for (int i = 0; i < strs.length; i++) { @@ -361,9 +367,14 @@ public abstract class StringKit extends StringUtils { } public static String maxLenLimit(String str,int len){ - if(StringKit.isBlank(str))return str; - if(str.length()>len)return str.substring(0,len); - else return str; + if(StringKit.isBlank(str)) { + return str; + } + if(str.length()>len) { + return str.substring(0,len); + } else { + return str; + } } /** diff --git a/src/main/java/cn/fisok/raw/lang/ValueObject.java b/src/main/java/cn/fisok/raw/lang/ValueObject.java index 592f12e..d6c0444 100644 --- a/src/main/java/cn/fisok/raw/lang/ValueObject.java +++ b/src/main/java/cn/fisok/raw/lang/ValueObject.java @@ -101,7 +101,9 @@ public class ValueObject { } public Number numberValue() { - if(value == null)return null; + if(value == null) { + return null; + } if (type == ValueType.Number) { return (Number) value; }else if (type == ValueType.Double) { @@ -128,7 +130,9 @@ public class ValueObject { } public Long longValue(Long defaultValue) { - if(numberValue()==null)return defaultValue; + if(numberValue()==null) { + return defaultValue; + } return longValue(); } @@ -137,7 +141,9 @@ public class ValueObject { return number != null ? number.intValue() : null; } public Integer intValue(Integer defaultValue) { - if(numberValue()==null)return defaultValue; + if(numberValue()==null) { + return defaultValue; + } return intValue(); } @@ -146,7 +152,9 @@ public class ValueObject { return number != null ? number.doubleValue() : null; } public Double doubleValue(Double defaultValue) { - if(numberValue()==null)return defaultValue; + if(numberValue()==null) { + return defaultValue; + } return doubleValue(); } @@ -154,7 +162,9 @@ public class ValueObject { return strValue(null); } public String strValue(String defaultValue) { - if(value == null)return defaultValue; + if(value == null) { + return defaultValue; + } try{ if (type == ValueType.Number) { @@ -215,13 +225,17 @@ public class ValueObject { } public Boolean boolValue(Boolean defaultValue){ - if(boolValue()==null)return defaultValue; + if(boolValue()==null) { + return defaultValue; + } return boolValue(); } public Object[] objectArray(){ Object[] values = null; - if(value==null)return values; + if(value==null) { + return values; + } if(value.getClass().isArray()){ return (Object[])value; }else if(value instanceof List){ @@ -239,7 +253,9 @@ public class ValueObject { public Number[] numberArray(){ Object[] values = objectArray(); - if(values==null||values.length==0)return null; + if(values==null||values.length==0) { + return null; + } Number[] ret = new Number[values.length]; for(int i=0;i