![JAR search and dependency download from the Maven repository](/logo.png)
org.unipop.schema.property.DynamicPropertySchema Maven / Gradle / Ivy
package org.unipop.schema.property;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer;
import org.json.JSONObject;
import org.unipop.schema.property.type.PropertyType;
import org.unipop.util.ConversionUtils;
import org.unipop.query.predicates.PredicatesHolder;
import org.unipop.query.predicates.PredicatesHolderFactory;
import java.util.*;
import java.util.stream.Collectors;
public class DynamicPropertySchema implements PropertySchema {
protected final Set excludeFields;
protected final Set excludeProperties;
public DynamicPropertySchema(ArrayList otherSchemas) {
this.excludeFields = otherSchemas.stream().flatMap(schema -> schema.excludeDynamicFields().stream()).collect(Collectors.toSet());
this.excludeProperties = otherSchemas.stream().flatMap(schema -> schema.excludeDynamicProperties().stream()).collect(Collectors.toSet());
}
public DynamicPropertySchema(ArrayList otherSchemas, JSONObject config) {
this(otherSchemas);
this.excludeFields.addAll(ConversionUtils.toSet(config, "excludeFields"));
this.excludeProperties.addAll(ConversionUtils.toSet(config, "excludeProperties"));
}
@Override
public String getKey() {
return null;
}
@Override
public Map toProperties(Map source) {
return source.entrySet().stream().filter(prop -> !excludeFields.contains(prop.getKey()) && prop.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
@Override
public Map toFields(Map properties) {
return properties.entrySet().stream().filter(entry -> !excludeProperties.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
@Override
public Set toFields(Set propertyKeys) {
return propertyKeys.stream().filter(key -> !excludeProperties.contains(key))
.collect(Collectors.toSet());
}
@Override
public Set
© 2015 - 2025 Weber Informatics LLC | Privacy Policy