私のオーバーライドequals()
が2つのオブジェクトが同じかどうかを判断するインデックスを追加しようとしています。cqengine cant index by equals
Car.java
public static class Car {
final String id;
private String name;
public Car(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static final Attribute<Car, Car> CAR = new SimpleAttribute<Car, Car>() {
@Override
public Car getValue(Car car, QueryOptions queryOptions) {
return car;
}
};
@Override
public String toString() {
return "Car{" + "id=" + id + ", name=" + name + '}';
}
}
Fetcher.java
public static final ResultSet<Car> get(final IndexedCollection<Car> indexedCollection, final Car car) {
return indexedCollection.retrieve(QueryFactory.equal(Car.CAR, car));
}
Main.java
public static void main(String args[]) {
IndexedCollection<Car> cars = new ConcurrentIndexedCollection<>();
cars.addIndex(NavigableIndex.onAttribute(Car.CAR));
}
proble mはこの行にありますcars.addIndex(NavigableIndex.onAttribute(Car.CAR));
ここで、エラーメッセージはno suitable method found for onAttribute(Attribute<Car,Car>)
です。私はここで何か間違っているのですか、代わりに使用しなければならない別の呼び出しがありますか?
'IndexedCollectionは'車が必要cars'私が正しくあなたを理解している場合しかし...ここでは、可能な解決策であります'属性 CAR'は車ではありません。これはSimpleEntryのようなものです。 'getValue();'をコールしてみてください –
asdf
@asdf: 'getValue();'はどこで正確に呼び出しますか? – Hooli
次の例を参照してください:[Car](https://github.com/npgall/cqengine/blob/master/code/src/test/java/com/googlecode/cqengine/examples/introduction/Car.java)と[はじめに](https://github.com/npgall/cqengine/blob/master/code/src/test/java/com/googlecode/cqengine/examples/introduction/Introduction.java) – asdf