![JAR search and dependency download from the Maven repository](/logo.png)
org.neo4j.internal.schema.SchemaDescriptorPredicates Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neo4j-schema Show documentation
Show all versions of neo4j-schema Show documentation
Schema descriptors and interfaces in Neo4j.
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [https://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package org.neo4j.internal.schema;
import static org.apache.commons.lang3.ArrayUtils.contains;
import java.util.function.Predicate;
import org.neo4j.common.EntityType;
public class SchemaDescriptorPredicates {
private SchemaDescriptorPredicates() {}
public static Predicate hasLabel(int labelId) {
return supplier -> {
SchemaDescriptor schema = supplier.schema();
return schema.entityType() == EntityType.NODE && contains(schema.getEntityTokenIds(), labelId);
};
}
public static Predicate hasRelType(int relTypeId) {
return supplier -> {
SchemaDescriptor schema = supplier.schema();
return schema.entityType() == EntityType.RELATIONSHIP && contains(schema.getEntityTokenIds(), relTypeId);
};
}
public static Predicate hasProperty(int propertyId) {
return supplier -> hasProperty(supplier, propertyId);
}
public static boolean hasLabel(SchemaDescriptorSupplier supplier, int labelId) {
SchemaDescriptor schema = supplier.schema();
return schema.entityType() == EntityType.NODE && contains(schema.getEntityTokenIds(), labelId);
}
public static boolean hasProperty(SchemaDescriptorSupplier supplier, int propertyId) {
int[] schemaProperties = supplier.schema().getPropertyIds();
for (int schemaProp : schemaProperties) {
if (schemaProp == propertyId) {
return true;
}
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy