Initial Commit

This commit is contained in:
atravieso 2025-03-31 13:23:18 -04:00
commit 7bbab8dbfa
10 changed files with 221 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

3
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

7
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

14
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

4
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" />
</project>

36
pom.xml Normal file
View File

@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.banesco</groupId>
<artifactId>commons</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>commons</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,16 @@
package com.banesco;
import com.banesco.util.StringUtil;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args ) {
boolean value = StringUtil.isNumeric("45");
System.out.println(value);
}
}

View File

@ -0,0 +1,41 @@
package com.banesco.util;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtil {
private static final Logger LOGGER = Logger.getLogger(JsonUtil.class.getName());
private static boolean mustInit = true;
public static final ObjectMapper MAPPER = new ObjectMapper();
public static String getJsonFromObject(Object object) {
try {
return MAPPER.writeValueAsString(object);
} catch (JsonProcessingException e) {
LOGGER.log(Level.INFO, "Object To Json Exception: {}", e.getMessage());
}
return null;
}
public static <T> T getObjectFromJson(String json, Class<T> className) {
if (StringUtil.isNotEmpty(json)) {
try {
if (mustInit) {
mustInit = false;
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
return MAPPER.readValue(json, className);
} catch (JsonProcessingException | IllegalArgumentException e) {
LOGGER.log(Level.INFO, "JSON to Object Exception: {}", e.getMessage());
}
}
return null;
}
}

View File

@ -0,0 +1,24 @@
package com.banesco.util;
import org.apache.commons.lang3.StringUtils;
public class StringUtil {
public static boolean isNumeric(String value) {
try {
Integer.valueOf(value);
return true;
} catch (NumberFormatException e) {
return false;
}
}
public static boolean isNotEmpty(String value) {
return value != null && !value.trim().isEmpty();
}
public static String leftPad(String numberStr, int strLen, Character c) {
return StringUtils.leftPad(numberStr,strLen,c);
}
}

View File

@ -0,0 +1,38 @@
package com.banesco;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}