Add project parent module

This commit is contained in:
2020-07-03 10:26:09 +07:00
parent bef533b9b5
commit b33a6830cb
22 changed files with 696 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package com.cubetiqs;
/**
* Static Constants variable global use in sub-modules
*
* @author sombochea
* @since 1.0
*/
public class Constants {
public static final String __$ = "CONSTANTS";
}

View File

@@ -0,0 +1,130 @@
package com.cubetiqs.assertion;
/**
* Assertion and Tests
* This class used for check and validation and throwable error
*
* @author sombochea
* @since 1.0
*/
public final class Tests {
public static void isTrue(boolean val) throws TestsException {
assert val;
}
public static void isTrue(boolean val, String message) throws TestsException {
try {
isTrue(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isNotTrue(boolean val) throws TestsException {
assert !val;
}
public static void isNotTrue(boolean val, String message) throws TestsException {
try {
isNotTrue(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isNull(Object val) throws TestsException {
assert val == null;
}
public static void isNull(Object val, String message) throws TestsException {
try {
isNull(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isNotNull(Object val) throws TestsException {
assert val != null;
}
public static void isNotNull(Object val, String message) throws TestsException {
try {
isNotNull(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isEmpty(String val) throws TestsException {
assert val.isEmpty();
}
public static void isEmpty(String val, String message) throws TestsException {
try {
isEmpty(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isNotEmpty(String val) throws TestsException {
assert !val.isEmpty();
}
public static void isNotEmpty(String val, String message) throws TestsException {
try {
isNotEmpty(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isBlank(String val) throws TestsException {
assert val.trim().isEmpty();
}
public static void isBlank(String val, String message) throws TestsException {
try {
isBlank(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isNotBlank(String val) throws TestsException {
assert !val.trim().isEmpty();
}
public static void isNotBlank(String val, String message) throws TestsException {
try {
isNotBlank(val);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isEquals(Object val1, Object val2) throws TestsException {
assert val1 == val2;
}
public static void isEquals(Object val1, Object val2, String message) throws TestsException {
try {
isEquals(val1, val2);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
public static void isNotEquals(Object val1, Object val2) throws TestsException {
assert val1 != val2;
}
public static void isNotEquals(Object val1, Object val2, String message) throws TestsException {
try {
isNotEquals(val1, val2);
} catch (AssertionError error) {
throw new TestsException(message);
}
}
}

View File

@@ -0,0 +1,24 @@
package com.cubetiqs.assertion;
/**
* Default Assertion/Tests Exception
*
* @author sombochea
* @see AssertionError
* @see Error
* @see Throwable
* @since 1.0
*/
public class TestsException extends AssertionError {
public TestsException() {
super("tests failed");
}
public TestsException(String message) {
super(message);
}
public TestsException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,8 @@
package com.cubetiqs.event;
/**
* @author sombochea
* @since 1.0
*/
public interface EventContext {
}

View File

@@ -0,0 +1,21 @@
package com.cubetiqs.exception;
/**
* File not found exception
*
* @author sombochea
* @since 1.0
*/
public class FileNotFoundException extends RIOException {
public FileNotFoundException() {
super("File not found!");
}
public FileNotFoundException(String message) {
super(message);
}
public FileNotFoundException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,29 @@
package com.cubetiqs.exception;
/**
* Runtime Exception
*
* @author sombochea
* @see RuntimeException
* @since 1.0
*/
public class RException extends RuntimeException {
public RException() {
}
public RException(String message) {
super(message);
}
public RException(String message, Throwable cause) {
super(message, cause);
}
public RException(Throwable cause) {
super(cause);
}
public RException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@@ -0,0 +1,26 @@
package com.cubetiqs.exception;
import java.io.IOException;
/**
* IO Exception
*
* @author sombochea
* @since 1.0
*/
public class RIOException extends IOException {
public RIOException() {
}
public RIOException(String message) {
super(message);
}
public RIOException(String message, Throwable cause) {
super(message, cause);
}
public RIOException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,24 @@
package com.cubetiqs.exception;
/**
* Null Exception
*
* @author sombochea
* @since 1.0
*/
public class RNullException extends RException {
public RNullException() {
}
public RNullException(String message) {
super(message);
}
public RNullException(String message, Throwable cause) {
super(message, cause);
}
public RNullException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,4 @@
package com.cubetiqs.exception.json;
public class RJsonParseException {
}

View File

@@ -0,0 +1,14 @@
package com.cubetiqs.lang;
import java.lang.annotation.*;
/**
* @author sombochea
* @since 1.0
*/
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NonNull {
}

View File

@@ -0,0 +1,14 @@
package com.cubetiqs.lang;
import java.lang.annotation.*;
/**
* @author sombochea
* @since 1.0
*/
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Nullable {
}

View File

@@ -0,0 +1,12 @@
package com.cubetiqs.test;
import com.cubetiqs.assertion.Tests;
import org.junit.Test;
public class AssertionTests {
@Test
public void equalsTests() {
Tests.isEquals("1", "1", "values are not equals");
Tests.isNotEquals("1", "2", "values are equals");
}
}

View File

@@ -0,0 +1,11 @@
package com.cubetiqs.test;
import org.junit.Assert;
import org.junit.Test;
public class MainTests {
@Test
public void test() {
Assert.assertTrue("this is true", true);
}
}