Lombok - mandatory field in builder using builderMethodName

by GarciaPL on Saturday, 24 August 2019

@Builder(builderMethodName = "mandatoryBuilder")
@ToString
public class MyClass {

    private String name;
    private String identifier;

    public String getName() {
        return name;
    }

    public String getIdentifier() {
        return identifier;
    }

    public static MyClassBuilder builder(String identifier) {
        return mandatoryBuilder().identifier(identifier);
    }

}

Tooltip does not show up for disabled button - ExtJS

by GarciaPL on Wednesday, 26 June 2019

If you are going to define tooltip for component in ExtJS (especially within version 6.7 and higher as I had chance to work with it) which might be disabled, unfortunately you will not be able to see. This component needs to be enabled that you might see your tooltip. Hopefully there is a way to fix it.

Just enrich your component (button in this case) with pointerEvents: 'all'

var button = {
    xtype: 'button',
    tooltip: 'Your tooltip',
    text: 'Your Text',
    style: {
        pointerEvents: 'all'
    }
};

IntelliJ - Command line is too long

by GarciaPL on Monday, 1 April 2019



Inside your .idea folder, change workspace.xml file add below property

<property name="dynamic.classpath" value="true" />

to

<component name="PropertiesComponent">

Conda - use python package from pypi

by GarciaPL on Friday, 4 January 2019

Have you ever tried to install package available in pypi, but not in official anaconda repository? There is a way to install it using Anaconda terminal.

  1. conda skeleton pypi PACKAGE
  2. conda build PACKAGE

Python rstrip in Java

by GarciaPL on Friday, 13 July 2018

Last time I was working on migration of some code from Python into Java and I was trying to find a corresponding code in Java for a function called rstrip in Python. So, below you can see a code written in Python and solution written in Java produced of course using Guava.

icb_code.rstrip("0")


CharMatcher trailingZeroMatcher = CharMatcher.is('0');
String trimmedInput = trailingZeroMatcher.trimTrailingFrom(input);

Case Insensitive Map in Java

by GarciaPL on Wednesday, 11 July 2018

I needed recently to create a case-insensitive map in Java to query it with keys which might be uppercase or lowercase. I thought that it should be somewhere some kind of solution already available for developers. I found a class called CaseInsensitiveMap in Apache Commons Collections package (https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/CaseInsensitiveMap.html) but unfortunately, I found later on that it does not support generics which was needed in my case, that's why I decided to go with a custom solution for that problem which might be found below.

Map<String, String> record = getRecord();

TreeMap<String, String> caseInsensitiveMap = new TreeMap<>getCaseInsensitiveComparator());

caseInsensitiveMap.putAll(record);

protected Comparator<String> getCaseInsensitiveComparator() {
    return Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER);
}