Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Lombok's setter can't be called

package com.example.marketing.semantics.entities;


import com.example.marketing.general.entities.BaseEntity;
import com.example.marketing.general.interfaces.Phraseable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "extra_phrases",
        uniqueConstraints = {@UniqueConstraint(name = "unique_extra_phrase",
                columnNames = {"phrase"})})
public class ExtraPhraseEntity extends BaseEntity implements Phraseable {
    @NotNull
    @NotEmpty
    @Column(nullable = false,
            columnDefinition = "varchar(1000) default ''")
    private String phrase;

    @NotNull
    @Column(nullable = false,
            columnDefinition = "INTEGER DEFAULT 0")
    Integer frequency;
}

How I use it:

(ExtraPhraseEntity) phraseEntity.setPhrequency(frequency);

Result: my IDE signals: Cannot resolve method 'setPhrequency' in 'Phraseable'.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I cast type because if was Phraseable.
So, I hoped that Lombok will help me with this setter method. But it doesn’t.

Could you help me understand why it doesn’t and how to cope with this problem?

>Solution :

Try ((ExtraPhraseEntity) phraseEntity).setPhrequency(frequency);

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading