Assert 제거

master
mjkhan21 2 months ago
parent 000ea153d1
commit 9e2e1f8b4d

@ -16,7 +16,6 @@ import java.util.stream.Stream;
import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.AbstractEntity; import cokr.xit.foundation.AbstractEntity;
import cokr.xit.foundation.Assert;
/** /**
* @author mjkhan * @author mjkhan
@ -35,11 +34,11 @@ public class FileInfo extends AbstractEntity {
* @return infoKey * @return infoKey
*/ */
public static String InfoKey(Object... objs) { public static String InfoKey(Object... objs) {
if (Assert.isEmpty(objs)) if (isEmpty(objs))
return ""; return "";
return Stream.of(objs) return Stream.of(objs)
.filter(obj -> !Assert.isEmpty(obj)) .filter(obj -> !isEmpty(obj))
.map(obj -> obj.toString()) .map(obj -> obj.toString())
.collect(Collectors.joining("-")); .collect(Collectors.joining("-"));
} }
@ -96,9 +95,9 @@ public class FileInfo extends AbstractEntity {
* @param fileInfo FileInfo * @param fileInfo FileInfo
*/ */
public void setInfo(FileInfo fileInfo) { public void setInfo(FileInfo fileInfo) {
fileInfo.setInfoType(Assert.notEmpty(infoType, "infoType")); fileInfo.setInfoType(notEmpty(infoType, "infoType"));
fileInfo.setInfoKey(Assert.notEmpty(infoKey, "infoKey")); fileInfo.setInfoKey(notEmpty(infoKey, "infoKey"));
if (!Assert.isEmpty(subType)) if (!isEmpty(subType))
fileInfo.setSubType(subType); fileInfo.setSubType(subType);
} }
} }
@ -128,7 +127,7 @@ public class FileInfo extends AbstractEntity {
* @param data * @param data
*/ */
public DataHolder(Relation relation, String filename, String data) { public DataHolder(Relation relation, String filename, String data) {
this(relation, filename, !Assert.isEmpty(data) ? Base64.getDecoder().decode(data.getBytes()) : null); this(relation, filename, !FileInfo.isEmpty(data) ? Base64.getDecoder().decode(data.getBytes()) : null);
} }
/** . /** .
@ -447,7 +446,7 @@ public class FileInfo extends AbstractEntity {
* @return mime type * @return mime type
*/ */
public String getMimeType() { public String getMimeType() {
return Assert.ifEmpty(mimeType, () -> mimeType = "application/octet-stream"); return ifEmpty(mimeType, () -> mimeType = "application/octet-stream");
} }
/**mime type . /**mime type .
@ -461,7 +460,7 @@ public class FileInfo extends AbstractEntity {
* @return * @return
*/ */
public String getExtension() { public String getExtension() {
return Assert.ifEmpty(extension, () -> extension = extension(name)); return ifEmpty(extension, () -> extension = extension(name));
} }
/** . /** .
@ -535,12 +534,12 @@ public class FileInfo extends AbstractEntity {
public InputStream getInputStream() { public InputStream getInputStream() {
if (input != null) return input; if (input != null) return input;
if (Assert.isEmpty(path)) return null; if (isEmpty(path)) return null;
try { try {
return new FileInputStream(path); return new FileInputStream(path);
} catch (Exception e) { } catch (Exception e) {
throw Assert.runtimeException(e); throw runtimeException(e);
} }
} }
@ -569,7 +568,7 @@ public class FileInfo extends AbstractEntity {
in.transferTo(out); in.transferTo(out);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
throw Assert.runtimeException(e); throw runtimeException(e);
} }
} }
@ -583,7 +582,7 @@ public class FileInfo extends AbstractEntity {
try (FileOutputStream out = new FileOutputStream(path)) { try (FileOutputStream out = new FileOutputStream(path)) {
return write(out); return write(out);
} catch(Exception e) { } catch(Exception e) {
throw Assert.runtimeException(e); throw runtimeException(e);
} }
} }
@ -594,7 +593,7 @@ public class FileInfo extends AbstractEntity {
* </ul> * </ul>
*/ */
public boolean delete() { public boolean delete() {
if (Assert.isEmpty(path)) return false; if (isEmpty(path)) return false;
File file = new File(path); File file = new File(path);
return file.exists() ? file.delete() : false; return file.exists() ? file.delete() : false;
@ -610,13 +609,13 @@ public class FileInfo extends AbstractEntity {
input = null; input = null;
return this; return this;
} catch (Exception e) { } catch (Exception e) {
throw Assert.runtimeException(e); throw runtimeException(e);
} }
} }
@Override @Override
public String toString() { public String toString() {
String path = getPath(); String path = getPath();
return getName() + (Assert.isEmpty(path) ? "" : " -> " + path); return getName() + (isEmpty(path) ? "" : " -> " + path);
} }
} }
Loading…
Cancel
Save