use of datawave.query.attributes.AttributeBag in project datawave by NationalSecurityAgency.
the class EventDataQueryExpressionVisitor method extractTypes.
public static Set<Type> extractTypes(AttributeFactory attrFactory, String fieldName, String fieldValue, Key key) {
final Set<Type> types = new HashSet<>();
final Queue<Attribute<?>> attrQueue = new LinkedList<>();
attrQueue.add(attrFactory.create(fieldName, fieldValue, key, true));
Attribute<?> attr;
while ((attr = attrQueue.poll()) != null) {
if (TypeAttribute.class.isAssignableFrom(attr.getClass())) {
TypeAttribute dta = (TypeAttribute) attr;
Type t = dta.getType();
types.add(t);
} else if (AttributeBag.class.isAssignableFrom(attr.getClass())) {
attrQueue.addAll(((AttributeBag<?>) attr).getAttributes());
} else {
log.warn("Unexpected attribute type when extracting type: " + attr.getClass().getCanonicalName());
}
}
return types;
}
Aggregations