This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package com.bmchild.validation.constraints; | |
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | |
import static java.lang.annotation.ElementType.CONSTRUCTOR; | |
import static java.lang.annotation.ElementType.FIELD; | |
import static java.lang.annotation.ElementType.TYPE; | |
import static java.lang.annotation.ElementType.METHOD; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package com.bmchild.service.xml; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import org.dom4j.Document; | |
import org.dom4j.Node; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bmchild.pocrestclient; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.util.LinkedHashMap; | |
import java.util.Map; | |
import java.util.logging.Logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#function to zip text + encrypt, 2 params (text to encrypt, filename w/o extension) | |
function zipe() { | |
echo "$1" > $2.txt && zip -e $2.zip $2.txt && rm $2.txt | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings("rawtypes") | |
public static Class<?> getEntity(JpaRepository repo) { | |
Type clazzes = getGenericType(repo.getClass())[0]; | |
Type[] jpaClass = getGenericType(getClass(clazzes)); | |
return getClass( ((ParameterizedType)jpaClass[0]).getActualTypeArguments()[0]); | |
} | |
public static Type[] getGenericType(Class<?> target) { | |
if (target == null) | |
return new Type[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String filePath = this.getClass().getClassLoader().getResource("folder/file.txt").getFile(); | |
String fileContent = new String(Files.readAllBytes(Paths.get(filePath)), StandardCharsets.UTF_8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* creates a list of lists where each list.size() <= <code>length</code> | |
* @param list | |
* @param length | |
* @return | |
*/ | |
public static <T> List<List<T>> split(List<T> list, final int length) { | |
List<List<T>> parts = new ArrayList<List<T>>(); | |
final int size = list.size(); | |
for (int i = 0; i < size; i += length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Business logic service | |
*/ | |
public class MyBusinessService { | |
private SomeService someService; | |
public void executeSomeLogic(MyLogicOperator input) { | |
Something thing = new Something(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Business logic service | |
*/ | |
public class MyBusinessService { | |
private SomeService someService; | |
public void executeSomeLogic(String input) { | |
Something thing = new Something(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Business Logic Test | |
*/ | |
@RunWith(MockitoJUnitRunner.class) | |
public class MyBusinessServiceTest { | |
@Mock | |
private AnotherService anotherService; | |
@Mock |