0

Official document says that I can create object by using following approach:

 @Data(staticConstructor = "of")
class Foo<T> {

    private T x;
}

you can create new instances of Foo by writing: Foo.of(5); instead of having to write: new Foo(5);

This is a sample method to learn lombok.

package com.lombok.first;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.val;
@Data public class DataAnnot {
          @Getter @Setter private String name;
          private final int salary;
          
          
          
          @ToString(includeFieldNames=true)
          @Data(staticConstructor="of")
          public static class inner<T>{
          private T tally;
         }
          
          
     public static void main(String agrs[]){
     DataAnnot d= new DataAnnot(8);
     
     System.out.println(d);
   }
}

but when I add the line

 val obj= inner.of("object"); 
 System.out.println(d);

Eclipse flags error. What am I missing here? Perhaps I need to refresh my generics concepts, but how can I create an object of "inner" class?

1 Answer 1

2

Maybe you should use val obj = DataAnnot.inner.of("object");?

I cannot tell for sure since you didn't specify where you added the code snippet.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.