Skip to content

Instantly share code, notes, and snippets.

View slmanju's full-sized avatar
💭
Whatever you are be a good one

Manjula Jayawardana slmanju

💭
Whatever you are be a good one
View GitHub Profile
@slmanju
slmanju / HelloWorld1.vue
Created August 2, 2018 03:36
View with VueJs
<template>
<div class="hello">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data() {
@slmanju
slmanju / Chain.java
Last active February 14, 2018 03:55
Chain of responsibility demonstration
public abstract class Chain {
protected Chain next;
public Chain() {
}
public void setNext(Chain next) {
this.next = next;
@slmanju
slmanju / AttributeConverter.java
Last active February 9, 2018 17:13
creating a JPA attribute converter
package com.manjula.starter.model.converter;
import javax.persistence.AttributeConverter;
import java.util.Arrays;
import java.util.List;
import static java.util.stream.Collectors.toList;
/**
* @author Manjula Jayawardana
@slmanju
slmanju / Component.java
Created January 26, 2018 11:00
Decorator design pattern with Java
interface Component {
void doSomething();
}
@slmanju
slmanju / AbstractTemplate.java
Created January 26, 2018 09:58
Template Method design pattern
public abstract class AbstractTemplate {
public final void execute() {
operationInitialize();
operation1();
if (hook()) {
operation2();
}
System.out.println("we are done..");
@slmanju
slmanju / Algorithm.java
Created January 25, 2018 12:01
Strategy design pattern with Java
public interface Algorithm {
void execute();
}
@slmanju
slmanju / ConcreteSubject.java
Created January 25, 2018 06:25
Observer design pattern with Java
import java.util.ArrayList;
import java.util.List;
public class ConcreteSubject implements Subject {
private List<Observer> observers = new ArrayList<>();
private String message;
public ConcreteSubject() {
}
@slmanju
slmanju / RestTemplateHelper.java
Created January 25, 2018 05:46
Generic RestTemplate wrapper
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@slmanju
slmanju / SingletonEager.java
Created January 25, 2018 03:51
Singleton design pattern with Java
public class SingletonEager {
private static final SingletonEager INSTANCE = new SingletonEager();
private SingletonEager() {
System.out.println("in the constructor"); // this will print first
}
public static SingletonEager getInstance() {
return INSTANCE;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>EMS</title>