com.googlecode.cqengine.query.simple.None Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cqengine Show documentation
Show all versions of cqengine Show documentation
Collection Query Engine: NoSQL indexing and query engine for Java collections with ultra-low latency
/**
* Copyright 2012-2015 Niall Gallagher
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.googlecode.cqengine.query.simple;
import com.googlecode.cqengine.attribute.Attribute;
import com.googlecode.cqengine.attribute.SelfAttribute;
import com.googlecode.cqengine.attribute.SimpleAttribute;
import com.googlecode.cqengine.query.option.QueryOptions;
/**
* A query which matches no objects in the collection.
*
* This is equivalent to a literal boolean 'false'.
*
* @author ngallagher
*/
public class None extends SimpleQuery {
final Class objectType;
public None(Class objectType) {
super(new SelfAttribute(objectType, "false"));
this.objectType = objectType;
}
@Override
protected boolean matchesSimpleAttribute(SimpleAttribute attribute, O object, QueryOptions queryOptions) {
return false;
}
@Override
protected boolean matchesNonSimpleAttribute(Attribute attribute, O object, QueryOptions queryOptions) {
return false;
}
@Override
protected int calcHashCode() {
return 1357656699; // chosen randomly
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof None)) return false;
None that = (None) o;
return this.objectType.equals(that.objectType);
}
@Override
public String toString() {
return "none(" + super.getAttribute().getObjectType().getSimpleName() + ".class)";
}
}