Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly set getter setter in interface projection for a boolean variable starting with is?

I am using interface projection . For unit testing purpose i have to add both getter and setter. In Jpa query i have a Boolean parameter named isPublic. But getter setter not working. i tried following

  Boolean isPublic();

  void setPublic(Boolean isPublic);

and this

  Boolean getIsPublic();

  void setIsPublic(Boolean isPublic);

and this

  Boolean getPublic();

  void setPublic(Boolean isPublic);

But everything works when i change variable name to public with setter setPublic and getter getPublic. How do i properly set getter setter for isPublic?

like image 488
mahfuj asif Avatar asked Oct 28 '25 06:10

mahfuj asif


2 Answers

If your variable name is "isPublic", then, your getter should be named isIsPublic.

The "is" shouldn't be in the variable name.

like image 158
BenjaminD Avatar answered Oct 30 '25 09:10

BenjaminD


import org.springframework.beans.factory.annotation.Value;

public interface MyClass {
    @Value("#{target.value == 1}")
    Boolean getValue();
}
like image 43
Xelay Avatar answered Oct 30 '25 07:10

Xelay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!