Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class can be record class #432

Closed
punkratz312 opened this issue Jan 8, 2025 · 1 comment
Closed

Class can be record class #432

punkratz312 opened this issue Jan 8, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@punkratz312
Copy link
Contributor

punkratz312 commented Jan 8, 2025

easy as intelliJ already recognize: https://github.com/quarkusio/quarkus/pull/45423/files

https://github.com/quarkusio/quarkus/blob/25e8bfd9d5c24e079111f5aaf874bda30d957a8f/extensions/smallrye-metrics/runtime/src/main/java/io/quarkus/smallrye/metrics/runtime/SmallRyeMetricsFactory.java#L200

tricky that can be done as well: https://github.com/quarkusio/quarkus/pull/45450/files

image

pojo:

    private static class SmallRyeFunctionGauge<T, R extends Number> implements Gauge<R> {
        final T obj;
        final Function<T, R> f;

        SmallRyeFunctionGauge(T obj, Function<T, R> f) {
            this.obj = obj;
            this.f = f;
        }

        @Override
        public R getValue() {
            return f.apply(obj);
        }
    }

record:

    private record SmallRyeFunctionGauge<T, R extends Number>(T obj, Function<T, R> f) implements Gauge<R> {

        @Override
        public R getValue() {
            return f.apply(obj);
        }
    }
@punkratz312 punkratz312 added the enhancement New feature or request label Jan 8, 2025
@timtebeek
Copy link
Contributor

Hi @punkratz312 ; this appears to be a duplicate of this earlier issue

Feel free to chime in there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants