Survival recipes

  •  Home
  •  Archive
  •  About
  •  Subscribe
  • Search
  • Menu
  •  Home
  •  Archive
  •  About
  •  Subscribe

    Recent Posts

  • Create Openshift Jenkins pipelines

  • Keyset pagination

Convert standard setters to flow setters with regex

Using regex you can convert all void setters to flow or builder setters

Feb 01, 2019
Albert Lacambra BasilAlbert Lacambra Basil

Having:

public SomeClass setX(…){}

and using the regex:

public void set([\w]+.+\{(\n\s+).+)

with replace:

public SomeClass set$1$2return this;

It transforms

public void setX(int x){
    this.x;
}

to

public MyClass setX(int x){
    this.x;
    return this;
}

Tested with Intellij.

  • Twitter

  • Facebook

  • Reddit

  • LinkedIn

  • StumbleUpon

  • Email

  •   Tags:
  • java
  • Recover from a messed git rebase
Jbake Blog

Survival Recipes Blog

Easy solutions to every day problems.

    Recent Posts

  • Create Openshift Jenkins pipelines

    Nov 26, 2019
  • Keyset pagination

    Nov 08, 2019
    • View more posts

    Tags

  • cli 2
  • reflexion 1
  • mvn 1
  • thinwars 1
  • maven 1
  • openshift 2
  • testing 1
  • war 1
  • intellij 1
  • cert 1
  • mockito 1
  • docker 1
  • sql 1
  • jms 1
  • git 1
  • java 4
  • pipelines 1
  • solr 1
  • java EE 4
  • jenkins 1
  • json 1
  • wildfly 1
  • bash 1
  • crest 1

About

Easy solutions to every day problems.

  • Learn More

© Survival recipes. Design: HTML5 UP. Ported For SSG by Julio Pescador. Adapted to JBake by Manik Magar. Baked with JBake v2.6.4. Sitemap.