Langsung ke konten utama

Postingan

Menampilkan postingan dari Desember, 2022

Velocity Apache inject value otomatis

Description Velocity Apache adalah template engine yang berguna untuk meng inject file atau data seperti XML, HTML, SQL, dll Maven <dependency> <groupId> org.apache.velocity </groupId> <artifactId> velocity </artifactId> <version> 1.7 </version> </dependency> <dependency> <groupId> org.apache.velocity </groupId> <artifactId> velocity-tools </artifactId> <version> 2.0 </version> </dependency> Java Class public interface TemplateEngine { String generate (String template , Map<String , Object> params) ; } public class VelocityTemplateEngine implements TemplateEngine{ @Override public String generate (String template , Map<String , Object> params) { try { if (params == null ) params = new HashMap<>() ; RuntimeServices velocityService = RuntimeSingleton. getRuntimeServices () ; Template velocityTempl...

Init Map di Java using Guava

Contoh fungsi ImmutableMap. of ( "key1" ,  "value1" ,  "key2" ,  "value2" ) ; Contoh Program Map < String , String >  articles  =  Maps. newHashMap ( ImmutableMap. of ( "Title" ,  "My New Article" ,  "Title2" ,  "Second Article" ) ) ; source: https://www.baeldung.com/java-initialize-hashmap