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.example.floatingbubble; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Calendar; | |
import java.util.EnumMap; | |
import java.util.Locale; |
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
public static <T> Collector<T, ?, Stream<T>> reverse() { | |
return Collectors.collectingAndThen(Collectors.toList(), list -> { | |
Collections.reverse(list); | |
return list.stream(); | |
}); | |
} |
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
public static <T> Collector<T, ?, Stream<T>> reverse() { | |
return Collectors.collectingAndThen(Collectors.toList(), list -> { | |
Collections.reverse(list); | |
return list.stream(); | |
}); | |
} |
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 sort hashmap by values | |
public static HashMap<String, Integer> sortByValue(HashMap<String, Integer> hm) | |
{ | |
// Create a list from elements of HashMap | |
List<Map.Entry<String, Integer> > list = | |
new LinkedList<Map.Entry<String, Integer> >(hm.entrySet()); | |
// Sort the list | |
Collections.sort(list, new Comparator<Map.Entry<String, Integer> >() { | |
public int compare(Map.Entry<String, Integer> o1, |
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
public void currying() { | |
// Create a function that adds 2 integers | |
BiFunction<Integer,Integer,Integer> adder = ( a, b ) -> a + b ; | |
// And a function that takes an integer and returns a function | |
Function<Integer,Function<Integer,Integer>> currier = a -> b -> adder.apply( a, b ) ; | |
// Call apply 4 to currier (to get a function back) | |
Function<Integer,Integer> curried = currier.apply( 4 ) ; |
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
//https://stackoverflow.com/questions/45673978/aspectj-change-value-of-method-parameter | |
@Around("execution(* *(.., @aspectjtest.ReplaceFooBar (*), ..))") | |
public Object replaceFooBar(ProceedingJoinPoint pjp) throws Throwable { | |
//get original args | |
Object[] args = pjp.getArgs(); | |
//get all annotations for arguments | |
MethodSignature signature = (MethodSignature) pjp.getSignature(); | |
String methodName = signature.getMethod().getName(); | |
Class<?>[] parameterTypes = signature.getMethod().getParameterTypes(); |