Good day lovely readers,
I have not worked extensively with inner anonymous classes but I am trying to simplify the following lines of code in someone's package examples.introduction.novice.simpler.model;
So to unpack the above & make it easier to read I rewrote it so (please correct me if I am wrong):
And ofcourse I created the Name class so :
public class Name<O, A> extends SimpleAttribute<O, A> {
public Name(String attributeName) {
super(attributeName);
// TODO Auto-generated constructor stub
}
public String getValue(Person person, QueryOptions queryOptions) { return person.name; }
@Override
public A getValue(O arg0, QueryOptions arg1) {
// TODO Auto-generated method stub
return null;
}
}
However, I am getting an error so :
Exception in thread "main" java.lang.ExceptionInInitializerError at examples.introduction.novice.simpler.model.Introduction.main(Introduction.java:17) Caused by: java.lang.IllegalStateException: Attribute 'name' (class examples.introduction.novice.simpler.model.Name) is invalid, cannot read generic type information from it. Attributes should typically EITHER be declared in code with generic type information as a (possibly anonymous) subclass of one of the provided attribute types, OR you can use a constructor of the attribute which allows the types to be specified manually. at com.googlecode.cqengine.attribute.support.AbstractAttribute.readGenericObjectType(AbstractAttribute.java:139) at com.googlecode.cqengine.attribute.support.AbstractAttribute.<init>(AbstractAttribute.java:43) at com.googlecode.cqengine.attribute.SimpleAttribute.<init>(SimpleAttribute.java:55) at examples.introduction.novice.simpler.model.Name.<init>(Name.java:11) at examples.introduction.novice.simpler.model.Person.<clinit>(Person.java:23) ... 1 moreThe sandbox link is :
The link to the main program running it is:
Apologies, but unsure how to format code in google groups.
Any help would be appreciated.
Thanks in advance.