Skip to content

Instantly share code, notes, and snippets.

View LeoHeo's full-sized avatar

JinHan LeoHeo

View GitHub Profile
@Documented
@Retention(RetentionPolicy.CLASS) // default CLASS -> SOURCE, RUNTIME으로 변경할 필요 없음
@Target(ElementType.METHOD)
public @interface PerformaceLogging {
}
long begin = Sytem.currentTimeMillis();
// do something....
// 기존코드
System.out.println(Sytem.currentTimeMillis() - begin);
@LeoHeo
LeoHeo / axios_file_download.js
Created September 20, 2018 04:13
axios로 excel 다운로드 할려고 할때 location.href가 아닌 progress bar 뜰 수 있게 하는 방식
axios.get(url, {
responseType: 'arraybuffer'
}).then(function (response) {
var blob = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
var blobURL = window.URL.createObjectURL(blob);
var tempLink = document.createElement('a');
tempLink.style.display = 'none';
tempLink.href = blobURL;
tempLink.setAttribute('download', 'test.xlsx');
document.body.appendChild(tempLink);
@Override
public int hashCode() {
return Objects.hash(getId());
}
public V put(K key, V value) {
return putVal(hash(key), key, value, false, true);
}
static final int hash(Object key) {
int h;
return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
}
public class HashSet<E>
extends AbstractSet<E>
implements Set<E>, Cloneable, java.io.Serializable
{
private transient HashMap<E,Object> map;
/**
* Constructs a new, empty set; the backing <tt>HashMap</tt> instance has
* default initial capacity (16) and load factor (0.75).
*/
Set<Student> studentSet = new HashSet<>();
studentSet.add(leo1);
studentSet.add(new Student(1L, "Leo"));
System.out.println("studentSet size => " + studentSet.size()); // studentSet size => 2
List<Student> students = new ArrayList<>();
students.add(leo1);
System.out.println("students contains Leo => " + students.contains(new Student(1L, "Leo"))); // true
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Student)) {
return false;
}
Student student = (Student) o;
return Objects.equals(getId(), student.getId()); // Java7+ 부터 사용할 수 있는 `Objects.equals`를 사용해봤다.
package io.github.leoheo.equals;
/**
* @author Heo, Jin Han
* @since 2018-06-10
*/
public class Student {
private Long id;
private String name;