eclipse being eclipse

 since 2006 I am using eclipse on and off, I am using intellij more in work but I dont have license for home so I decided to check eclipse back. I am trying to write some aspectj and installed the editor to latest eclipse and exception is

“AJCompilationUnit tried to access private field org.eclipse.jdt.internal.core.JavaElement.parent (org.eclipse.ajdt.core.javaelements.AJCompilationUnit is in unnamed module of loader “

 

decided to get latest from https://github.com/eclipse/org.aspectj/blob/master/docs/developer/IDE.md#eclipse

 

 and finally aj editor works

finding an electrician is hard in glasgow

 took me 1 month to find a decent electrician in Glasgow and this morning they came 3 guys 🙂 I had only 3 light switches problem, I think one guy was like trainer and other 2 were interns 🙂 anyway they worked 20 minutes and find out my problem is about old fueses. I did not know I have new fuses for heaters and old fuses for other appliences.

anyway he wired the old fuse and switches started working. now waiting for bill. he said next week they can replace this old box and do the ICR test. probably that will take 600. and today bill I am expecting 80. being a electrician in glasgow is very good job, they are hard to find.

reorder an int as big as possible

 I found https://www.codewars.com/ and solving a algorithm question, reorder given number as big as possible, example given 123, ordered biggest version is 321, so we just need to order digits separately and concatenate them, I wrote 2 approaches

public void testStreamCode() {
int num = 123;
AtomicReference<String> str = new AtomicReference<>();
String.valueOf(num).chars().boxed().sorted(Collections.reverseOrder()).forEach(c -> str.updateAndGet(v -> v + (c - 48)));
int parseInt = Integer.parseInt(str.get().replaceAll("null", ""));
assert parseInt == 321;
}

public void testArraysSortCode() {
int num = 7657585;
char[] c = String.valueOf(num).toCharArray();
Arrays.sort(c);
String s = "";
for (int i = c.length - 1; i >= 0; i--)
s += c[i];
Integer integer = Integer.valueOf(s);
assert integer == 8776555;
}
then CW gave another solution
public void cw() {
int num = 7657585;
int i1 = Integer.parseInt(String.valueOf(num)
.chars()
.mapToObj(i -> String.valueOf(Character.getNumericValue(i)))
.sorted(Comparator.reverseOrder())
.collect(Collectors.joining()));
assert i1 == 8776555;
}

I know java stream api looks cool and I decided to benchmark this. here is the result
Benchmark                                Mode  Cnt  Score   Error  Units
DemoApplicationTests.cw avgt 2 0.808 us/op
DemoApplicationTests.testArraysSortCode avgt 2 0.194 us/op
DemoApplicationTests.testStreamCode avgt 2 0.884 us/op
 
fastest is using arrays.sort(0.194) second is CW and last one is "testStreamCode".