Assert.equals(..), AbstractObject 추가
parent
a24cde0327
commit
cc21084d89
@ -0,0 +1,122 @@
|
||||
package cokr.xit.foundation;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import cokr.xit.foundation.data.Convert;
|
||||
|
||||
/**베이스 클래스.
|
||||
* <p>AbstractObject를 상속받는 클래스는
|
||||
* <ul><li>{@link Assert}</li>
|
||||
* <li>{@link Convert}</li>
|
||||
* </ul>
|
||||
* 등의 기능을 사용할 수 있다.
|
||||
* @author mjkhan
|
||||
*/
|
||||
public class AbstractObject {
|
||||
/**{@link Assert#equals(Object, Object)} 참고
|
||||
*/
|
||||
protected static final boolean equals(Object lv, Object rv) {
|
||||
return Assert.equals(lv, rv);
|
||||
}
|
||||
|
||||
/**{@link Assert#isEmpty(Object)} 참고
|
||||
*/
|
||||
protected static final boolean isEmpty(Object obj) {
|
||||
return Assert.isEmpty(obj);
|
||||
}
|
||||
|
||||
/**{@link Assert#ifEmpty(Object, Supplier)} 참고*/
|
||||
protected static final <T> T ifEmpty(T t, Supplier<T> nt) {
|
||||
return Assert.ifEmpty(t, nt);
|
||||
}
|
||||
|
||||
/**{@link Assert#ifEmpty(Object, Object)} 참고.
|
||||
*/
|
||||
protected static final <T> T ifEmpty(T t, T nt) {
|
||||
return Assert.ifEmpty(t, nt);
|
||||
}
|
||||
|
||||
/**obj가 빈 값이면 공백문자("")를 반환한다. 빈 값이 아니면 obj를 String으로 캐스팅하여 반환한다.
|
||||
* @param obj 객체
|
||||
* @return
|
||||
* <ul><li>obj가 빈 값이면 공백문자("")</li>
|
||||
* <li>빈 값이 아니면 String으로 캐스팅한 obj</li>
|
||||
* </ul>
|
||||
*/
|
||||
protected static final String blankIfEmpty(Object obj) {
|
||||
return ifEmpty((String)obj, "");
|
||||
}
|
||||
|
||||
/**{@link Assert#notEmpty(Object, String)} 참고.
|
||||
*/
|
||||
protected static final <T> T notEmpty(T t, String name) {
|
||||
return Assert.notEmpty(t, name);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toString(Object)}.*/
|
||||
protected static final String toString(Object obj) {
|
||||
return Convert.toString(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toShort(Object)}.*/
|
||||
protected static final short toShort(Object obj) {
|
||||
return Convert.toShort(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toInt(Object)}.*/
|
||||
protected static final int toInt(Object obj) {
|
||||
return Convert.toInt(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toLong(Object)}.*/
|
||||
protected static final long toLong(Object obj) {
|
||||
return Convert.toLong(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toDouble(Object)}.*/
|
||||
protected static final double toDouble(Object obj) {
|
||||
return Convert.toDouble(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toFloat(Object)}.*/
|
||||
protected static final float toFloat(Object obj) {
|
||||
return Convert.toFloat(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toByte(Object)}.*/
|
||||
protected static final byte toByte(Object obj) {
|
||||
return Convert.toByte(obj);
|
||||
}
|
||||
|
||||
/**See {@link Convert#toBoolean(Object)}.*/
|
||||
protected static final boolean toBoolean(Object obj) {
|
||||
return Convert.toBoolean(obj);
|
||||
}
|
||||
|
||||
/**{@link Assert#rootCause(Throwable)} 참고
|
||||
*/
|
||||
protected static final Throwable rootCause(Throwable t) {
|
||||
return Assert.rootCause(t);
|
||||
}
|
||||
|
||||
/**{@link ApplicationException#get(Throwable)} 참고
|
||||
*/
|
||||
protected static final ApplicationException applicationException(Throwable t) {
|
||||
return ApplicationException.get(t);
|
||||
}
|
||||
|
||||
/**{@link Assert#runtimeException(Throwable)} 참고
|
||||
*/
|
||||
protected static final RuntimeException runtimeException(Throwable t) {
|
||||
return Assert.runtimeException(t);
|
||||
}
|
||||
|
||||
/**현재 객체를 반환한다.
|
||||
* @param <T> AbstractComponent 유형
|
||||
* @return 현재 객체
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends AbstractObject> T self() {
|
||||
return (T)this;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue