* . *
  • About
  • Advertise
  • Privacy & Policy
  • Contact
Saturday, November 15, 2025
Earth-News
  • Home
  • Business
  • Entertainment
    We’re looking to further trim this drug stock and exit this entertainment giant – CNBC

    We’re looking to further trim this drug stock and exit this entertainment giant – CNBC

    Entertainment | ATL Hosts – Atlanta Hawks – NBA

    Inside ATL Hosts: Behind the Scenes with the Atlanta Hawks

    Blue Lights Season 3 Premiere Recap: An Elusive Threat Hints At A Bigger Danger In Belfast — Plus, Grade It! – Yahoo

    Blue Lights Season 3 Premiere Recap: A Shadowy Threat Reveals a Greater Danger in Belfast – Our Verdict Inside!

    Lancaster County’s 2026 quilt shows will have big changes; here’s what you need to know – LancasterOnline

    Exciting Changes Coming to Lancaster County’s 2026 Quilt Shows – Here’s What You Need to Know

    ‘The Price Is Right’ Contestant Said She ‘Manifested’ Her $100,000 Win – CBS 19 News

    ‘The Price Is Right’ Contestant Said She ‘Manifested’ Her $100,000 Win – CBS 19 News

    Billy Bob Thornton says Hollywood told him he ‘wasn’t southern enough’: ‘I am just off the turnip truck’ – Yahoo

    Billy Bob Thornton says Hollywood told him he ‘wasn’t southern enough’: ‘I am just off the turnip truck’ – Yahoo

  • General
  • Health
  • News

    Cracking the Code: Why China’s Economic Challenges Aren’t Shaking Markets, Unlike America’s” – Bloomberg

    Trump’s Narrow Window to Spread the Truth About Harris

    Trump’s Narrow Window to Spread the Truth About Harris

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Science
  • Sports
  • Technology
    Hang Pin Living Technology Issues Profit Warning for 2025 – TipRanks

    Hang Pin Living Technology Issues Stark Profit Warning for 2025

    Figure Technology stock spikes after Q3 revenue surpasses consensus (FIGR:NASDAQ) – Seeking Alpha

    Figure Technology stock spikes after Q3 revenue surpasses consensus (FIGR:NASDAQ) – Seeking Alpha

    Predictive Technology Is Improving Warehouse Safety – ohsonline.com

    Predictive Technology Is Improving Warehouse Safety – ohsonline.com

    mPower Technology opens automated solar module line for space – pv magazine USA

    MPower Technology Launches Cutting-Edge Automated Solar Module Line for Space Applications

    Two Tigers land Liberty League All-Conference honors – Rochester Institute of Technology Athletics

    Two Tigers land Liberty League All-Conference honors – Rochester Institute of Technology Athletics

    Green Technology Book: Solutions for confronting climate disasters – Part 1: Water-related disasters – WIPO – World Intellectual Property Organization

    Green Technology Book: Solutions for confronting climate disasters – Part 1: Water-related disasters – WIPO – World Intellectual Property Organization

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
No Result
View All Result
  • Home
  • Business
  • Entertainment
    We’re looking to further trim this drug stock and exit this entertainment giant – CNBC

    We’re looking to further trim this drug stock and exit this entertainment giant – CNBC

    Entertainment | ATL Hosts – Atlanta Hawks – NBA

    Inside ATL Hosts: Behind the Scenes with the Atlanta Hawks

    Blue Lights Season 3 Premiere Recap: An Elusive Threat Hints At A Bigger Danger In Belfast — Plus, Grade It! – Yahoo

    Blue Lights Season 3 Premiere Recap: A Shadowy Threat Reveals a Greater Danger in Belfast – Our Verdict Inside!

    Lancaster County’s 2026 quilt shows will have big changes; here’s what you need to know – LancasterOnline

    Exciting Changes Coming to Lancaster County’s 2026 Quilt Shows – Here’s What You Need to Know

    ‘The Price Is Right’ Contestant Said She ‘Manifested’ Her $100,000 Win – CBS 19 News

    ‘The Price Is Right’ Contestant Said She ‘Manifested’ Her $100,000 Win – CBS 19 News

    Billy Bob Thornton says Hollywood told him he ‘wasn’t southern enough’: ‘I am just off the turnip truck’ – Yahoo

    Billy Bob Thornton says Hollywood told him he ‘wasn’t southern enough’: ‘I am just off the turnip truck’ – Yahoo

  • General
  • Health
  • News

    Cracking the Code: Why China’s Economic Challenges Aren’t Shaking Markets, Unlike America’s” – Bloomberg

    Trump’s Narrow Window to Spread the Truth About Harris

    Trump’s Narrow Window to Spread the Truth About Harris

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Science
  • Sports
  • Technology
    Hang Pin Living Technology Issues Profit Warning for 2025 – TipRanks

    Hang Pin Living Technology Issues Stark Profit Warning for 2025

    Figure Technology stock spikes after Q3 revenue surpasses consensus (FIGR:NASDAQ) – Seeking Alpha

    Figure Technology stock spikes after Q3 revenue surpasses consensus (FIGR:NASDAQ) – Seeking Alpha

    Predictive Technology Is Improving Warehouse Safety – ohsonline.com

    Predictive Technology Is Improving Warehouse Safety – ohsonline.com

    mPower Technology opens automated solar module line for space – pv magazine USA

    MPower Technology Launches Cutting-Edge Automated Solar Module Line for Space Applications

    Two Tigers land Liberty League All-Conference honors – Rochester Institute of Technology Athletics

    Two Tigers land Liberty League All-Conference honors – Rochester Institute of Technology Athletics

    Green Technology Book: Solutions for confronting climate disasters – Part 1: Water-related disasters – WIPO – World Intellectual Property Organization

    Green Technology Book: Solutions for confronting climate disasters – Part 1: Water-related disasters – WIPO – World Intellectual Property Organization

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
No Result
View All Result
Earth-News
No Result
View All Result
Home Technology

Fluent: Static Extension Methods for Java

July 3, 2023
in Technology
Fluent: Static Extension Methods for Java
Share on FacebookShare on Twitter

Fluent allows you to call static Java methods as if they were object methods. For example, instead of writing:

assertNotEmpty(getHttpContent(createSharedUrl(website, “styles.css”)));

you would write:

website.createSharedUrl(“styles.css”).getHttpContent().assertNotEmpty();

Fluent works by transforming the abstract syntax tree during compilation. If a method can’t be resolved using Java’s normal rules, Fluent will rewrite it as such:

object.method(params…) -> method(object, params…)

and then give it back to the compiler. Now, the compiler will look for a static method taking the object as it’s first parameter. Any static methods that are in scope can be used. i.e, those you’ve written or imported. If you are importing them from another class, you will need to use import static so they can be resolved. No annotations are required.

In the above example, the extension method signatures would be:

public static URL createSharedUrl(Website website, String path) {}
public static String getHttpContent(URL url) {}
public static void assertNotEmpty(String string) {}

Extension methods are useful when you can’t (or don’t want to) add methods to a class or subclass, or you are working with an interface. Commonly, such methods are called “utility methods”, but in most other programming languages, you would just call them “functions”.

Fluent is implemented as a javac compiler plugin and has no runtime dependencies. The resulting class files are identical to code compiled with regular static method calls.

Fluent supports JDK 9 and above.

Quick Start

Download the jar, place it on your classpath, and run javac using -Xplugin:fluent:

wget https://github.com/rogerkeays/fluent/raw/main/fluent.jar
javac -cp fluent.jar -Xplugin:fluent File.java

Install Using Maven

Fluent is not yet available on Maven Central, however you can install it locally like this:

wget https://github.com/rogerkeays/fluent/raw/main/fluent.jar
mvn install:install-file -DgroupId=jamaica -DartifactId=fluent -Dversion=0.1.0 -Dpackaging=jar -Dfile=fluent.jar

Next, add the dependency to your pom.xml:

jamaica
fluent
0.1.0
compile

And configure the compiler plugin:

org.apache.maven.plugins
maven-compiler-plugin
3.11.0

-Xplugin:fluent

…

Note, older versions of the compiler plugin use a different syntax. Refer to the Maven Compiler Plugin docs for more details.

Build It Yourself

Fluent is built using a POSIX shell script:

git clone https://github.com/rogerkeays/fluent.git
cd fluent
./build.sh

If your operating system doesn’t include sh it shouldn’t be too hard to convert to whatever shell you are using. I mean, we’re talking about one java file and a text file here.

JDK Support

Fluent is tested with the following JDKs:

jdk-09.0.4
jdk-10.0.2
jdk-11.0.8
jdk-12.0.2
jdk-13.0.2
jdk-14.0.2
jdk-15.0.2
jdk-16.0.2
jdk-17.0.2
jdk-18.0.2.1
jdk-19.0.2
jdk-20.0.1
jdk-21 (early access)
jdk-22 (early access)

IDE Support

There is currently no IDE support for Fluent. Contributions are welcome. It may be possible to get your IDE to load the Fluent plugin into it’s compiler. If you get it working, please post something to github so we can all benefit.

Known Issues

you must use parentheses around numeric primitives when calling an extension method: e.g. (0).inc()
Fluent may not be compatible with other javac plugins, though so far it seems to play nice with Lombok, at least.
Fluent will make you a more productive programmer, which may go against corporate policy.

Related Resources

kotlin: a JVM language which supports extension methods out of the box.
Project Lombok: the grand-daddy of javac hacks.
unchecked: evade the checked exceptions mafia in Java.
Java Operator Overloading: a javac plugin using similar ideas.
racket-fluent: fluent syntax for Racket.
more stuff you never knew you wanted

>>> Read full article>>>
Copyright for syndicated content belongs to the linked Source : Hacker News – https://github.com/rogerkeays/fluent

Tags: FluentSTATICtechnology
Previous Post

Nvidia’s H100: Funny L2, and Tons of Bandwidth

Next Post

Tesla gives UK owners grabbing stick after forcing them to get left-hand-drive

Jemimah Rodrigues to Celebrate Cricket World Cup Win on ‘Two Much’ – Variety

Jemimah Rodrigues to Celebrate Cricket World Cup Victory on ‘Two Much

November 15, 2025
Charting the Global Economy: Disparity Tests a Resilient Europe – Bloomberg.com

Navigating the Global Economy: Europe’s Resilience Challenged by Widening Disparities

November 15, 2025
We’re looking to further trim this drug stock and exit this entertainment giant – CNBC

We’re looking to further trim this drug stock and exit this entertainment giant – CNBC

November 15, 2025
Southwick Board of Health appoints interim health director – MassLive

Southwick Board of Health appoints interim health director – MassLive

November 15, 2025
Georgia’s 2020 election interference case against Trump revived with a new prosecutor – CNN

Georgia’s 2020 election interference case against Trump revived with a new prosecutor – CNN

November 15, 2025
Conservation abandonment is a policy blind spot – Nature

The Hidden Dangers of Abandoning Conservation: Uncovering a Critical Policy Blind Spot

November 15, 2025
The 19 best Christmas gifts for science lovers (and nerds) – New Scientist

The 19 best Christmas gifts for science lovers (and nerds) – New Scientist

November 15, 2025
Mammoth RNA sequenced for the first time, marking a giant leap toward understanding prehistoric life – Live Science

Scientists Decode Mammoth RNA for the First Time, Unveiling Secrets of Prehistoric Life

November 15, 2025
Sweet Golden Retriever Sleeps Through All His Alarms and Has Zero Regrets – Yahoo

Adorable Golden Retriever Snoozes Through Every Alarm Without a Care in the World

November 15, 2025
Figure Technology Stock Is Soaring: What’s Going On? – Benzinga

Here’s Why Figure Technology Stock Is Skyrocketing Today

November 15, 2025

Categories

Archives

November 2025
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
« Oct    
Earth-News.info

The Earth News is an independent English-language daily published Website from all around the World News

Browse by Category

  • Business (20,132)
  • Ecology (920)
  • Economy (941)
  • Entertainment (21,814)
  • General (18,190)
  • Health (9,980)
  • Lifestyle (950)
  • News (22,149)
  • People (943)
  • Politics (952)
  • Science (16,152)
  • Sports (21,439)
  • Technology (15,919)
  • World (926)

Recent News

Jemimah Rodrigues to Celebrate Cricket World Cup Win on ‘Two Much’ – Variety

Jemimah Rodrigues to Celebrate Cricket World Cup Victory on ‘Two Much

November 15, 2025
Charting the Global Economy: Disparity Tests a Resilient Europe – Bloomberg.com

Navigating the Global Economy: Europe’s Resilience Challenged by Widening Disparities

November 15, 2025
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2023 earth-news.info

No Result
View All Result

© 2023 earth-news.info

No Result
View All Result

© 2023 earth-news.info

Go to mobile version