    @Override
    public void setupQuery(GenericQueryConfiguration configuration) throws Exception {

        super.setupQuery(configuration);

        /**
         * A few required components for document serialization and deserialization to be used later
         */
        final Query myQuery = ((ShardQueryConfiguration) configuration).getQuery();

        final DocumentDeserializer deserializer = DocumentSerialization.getDocumentDeserializer(myQuery);

        final DocumentSerializer serializer = DocumentSerialization.getDocumentSerializer(myQuery);

        List<Function<Entry<Key,Document>,Entry<Key,Document>>> functionList = Lists.newArrayList();

        functionList.add(new FacetedGrouping(facetedConfig));

        EmptyValueFunction filter = new EmptyValueFunction(deserializer);

        List<Predicate<Entry<Key,Value>>> filterList = Lists.newArrayList();

        filterList.add(filter);

        Iterator<Entry<Key,Value>> returnIter = new MergedReadAhead<>(facetedConfig, iterator, new FacetedFunction(deserializer, serializer, functionList),
                        filterList);

        iterator = returnIter;

    }

    @Override
    public void setupQuery(GenericQueryConfiguration configuration) throws Exception {

        super.setupQuery(configuration);

        /**
         * A few required components for document serialization and deserialization to be used later
         */
        final Query myQuery = ((ShardQueryConfiguration) configuration).getQuery();

        final DocumentDeserializer deserializer = DocumentSerialization.getDocumentDeserializer(myQuery);

        final DocumentSerializer serializer = DocumentSerialization.getDocumentSerializer(myQuery);

        List<Function<Entry<Key,Document>,Entry<Key,Document>>> functionList = Lists.newArrayList();

        functionList.add(new FacetedGrouping(facetedConfig));

        EmptyValueFunction filter = new EmptyValueFunction(deserializer);

        List<Predicate<Entry<Key,Value>>> filterList = Lists.newArrayList();

        filterList.add(filter);

        Iterator<Entry<Key,Value>> returnIter = new MergedReadAhead<Entry<Key,Value>>(facetedConfig, iterator, new FacetedFunction(deserializer, serializer,
                        functionList), filterList);

        iterator = returnIter;

    }

Replace Generic With Diamond MergedReadAhead<Entry<Key,Value>> with MergedReadAhead<> in method public setupQuery(configuration GenericQueryConfiguration) : void from class datawave.query.tables.facets.FacetedQueryLogic


        public ColumnVisibility getColumnVisibility() {
            try {
                Set<ColumnVisibility> columnVisibilities = new HashSet<>();
                for (Text t : this.uniqueVisibilities) {
                    columnVisibilities.add(new ColumnVisibility(t));
                }
                return tupleMarkingFunctions.combine(columnVisibilities);

            } catch (MarkingFunctions.Exception e) {
                logger.error("Could not create combined column visibility for the count", e);
                return null;
            }
        }

        public ColumnVisibility getColumnVisibility() {
            try {
                Set<ColumnVisibility> columnVisibilities = new HashSet<ColumnVisibility>();
                for (Text t : this.uniqueVisibilities) {
                    columnVisibilities.add(new ColumnVisibility(t));
                }
                return tupleMarkingFunctions.combine(columnVisibilities);

            } catch (MarkingFunctions.Exception e) {
                logger.error("Could not create combined column visibility for the count", e);
                return null;
            }
        }

Replace Generic With Diamond HashSet<ColumnVisibility> with HashSet<> in method public getColumnVisibility() : ColumnVisibility from class datawave.query.tables.shard.FieldIndexCountQueryLogic.Tuple


    @Override
    public GenericQueryConfiguration initialize(Connector connection, Query settings, Set<Authorizations> auths) throws Exception {

        if (logger.isTraceEnabled()) {
            logger.trace("initialize");
        }

        this.scannerFactory = new ScannerFactory(connection);
        MetadataHelper metadataHelper = prepareMetadataHelper(connection, this.getMetadataTableName(), auths);
        String modelName = this.getModelName();
        String modelTableName = this.getModelTableName();
        // Check if the default modelName and modelTableNames have been overriden by custom parameters.
        if (null != settings.findParameter(QueryParameters.PARAMETER_MODEL_NAME)
                        && !settings.findParameter(QueryParameters.PARAMETER_MODEL_NAME).getParameterValue().trim().isEmpty()) {
            modelName = settings.findParameter(QueryParameters.PARAMETER_MODEL_NAME).getParameterValue().trim();
        }
        if (null != settings.findParameter(QueryParameters.PARAMETER_MODEL_TABLE_NAME)
                        && !settings.findParameter(QueryParameters.PARAMETER_MODEL_TABLE_NAME).getParameterValue().trim().isEmpty()) {
            modelTableName = settings.findParameter(QueryParameters.PARAMETER_MODEL_TABLE_NAME).getParameterValue().trim();
        }

        if (null != modelName && null == modelTableName) {
            throw new IllegalArgumentException(QueryParameters.PARAMETER_MODEL_NAME + " has been specified but " + QueryParameters.PARAMETER_MODEL_TABLE_NAME
                            + " is missing. Both are required to use a model");
        }

        if (null != modelName && null != modelTableName) {
            this.queryModel = metadataHelper.getQueryModel(modelTableName, modelName, this.getUnevaluatedFields());
        }

        // I'm using this config object in a pinch, we should probably create a custom one.
        ShardQueryConfiguration config = ShardQueryConfigurationFactory.createShardQueryConfigurationFromConfiguredLogic(this, settings);
        config.setConnector(connection);
        config.setAuthorizations(auths);

        // the following throw IllegalArgumentExceptions if validation fails.
        parseQuery(config, settings);
        configDate(config, settings);
        configTypeFilter(config, settings);

        Set<String> normalizedFieldValues = null;
        Iterator<String> fieldNameIter = fieldNames.iterator();
        while (fieldNameIter.hasNext()) {
            String fieldName = fieldNameIter.next();
            // check that the field name is actually an indexed field
            Set<Type<?>> normalizerSet = metadataHelper.getDatatypesForField(fieldName, config.getDatatypeFilter());
            if (null != normalizerSet && !normalizerSet.isEmpty()) {
                if (null != this.fieldValues && !this.fieldValues.isEmpty()) {
                    for (Type<?> norm : normalizerSet) {
                        if (null == normalizedFieldValues) {
                            normalizedFieldValues = new HashSet<>();
                        }
                        for (String val : this.fieldValues) {
                            try {
                                String normVal = norm.normalize(val);
                                if (null != normVal && !normVal.isEmpty()) {
                                    normalizedFieldValues.add(normVal);
                                }
                            } catch (Exception e) {
                                logger.debug(norm + " failed to normalize value: " + val);
                            }
                        }
                    }
                }
            } else {
                if (logger.isTraceEnabled()) {
                    logger.trace("dropping fieldname " + fieldName + " because it's not indexed.");
                }
                // drop fieldName since it isn't indexed.
                fieldNameIter.remove();
            }
        }
        this.fieldValues = normalizedFieldValues;

        if (this.fieldNames.isEmpty()) {
            throw new IllegalArgumentException("Need at least 1 indexed field to query with.");
        }

        // Generate & set the query ranges
        this.ranges = generateRanges(config);

        // Find out if we need to list unique data types.
        if (null != settings.findParameter(Constants.UNIQ_DATATYPE)) {
            this.uniqueByDataType = Boolean.parseBoolean(settings.findParameter(Constants.UNIQ_DATATYPE).getParameterValue());
            if (logger.isTraceEnabled()) {
                logger.trace("uniqueByDataType: " + uniqueByDataType);
            }
        }

        // Find out if we need to list unique visibilities.
        if (null != settings.findParameter(Constants.UNIQ_VISIBILITY)) {
            this.uniqueByVisibility = Boolean.parseBoolean(settings.findParameter(Constants.UNIQ_VISIBILITY).getParameterValue());
            if (logger.isTraceEnabled()) {
                logger.trace("uniqueByVisibility: " + uniqueByVisibility);
            }
        }

        if (logger.isTraceEnabled()) {
            logger.trace("FieldNames: ");
            for (String f : this.fieldNames) {
                logger.trace("\t" + f);
            }
            logger.trace("FieldValues: ");
            if (null == this.fieldValues) {
                logger.trace("\tnone");
            } else {
                for (String f : this.fieldValues) {
                    logger.trace("\t" + f);
                }
            }
            logger.trace("uniqueByDataType: " + uniqueByDataType);
            logger.trace("uniqueByVisibility: " + uniqueByVisibility);
        }
        return config;
    }

    @Override
    public GenericQueryConfiguration initialize(Connector connection, Query settings, Set<Authorizations> auths) throws Exception {

        if (logger.isTraceEnabled()) {
            logger.trace("initialize");
        }

        this.scannerFactory = new ScannerFactory(connection);
        MetadataHelper metadataHelper = prepareMetadataHelper(connection, this.getMetadataTableName(), auths);
        String modelName = this.getModelName();
        String modelTableName = this.getModelTableName();
        // Check if the default modelName and modelTableNames have been overriden by custom parameters.
        if (null != settings.findParameter(QueryParameters.PARAMETER_MODEL_NAME)
                        && !settings.findParameter(QueryParameters.PARAMETER_MODEL_NAME).getParameterValue().trim().isEmpty()) {
            modelName = settings.findParameter(QueryParameters.PARAMETER_MODEL_NAME).getParameterValue().trim();
        }
        if (null != settings.findParameter(QueryParameters.PARAMETER_MODEL_TABLE_NAME)
                        && !settings.findParameter(QueryParameters.PARAMETER_MODEL_TABLE_NAME).getParameterValue().trim().isEmpty()) {
            modelTableName = settings.findParameter(QueryParameters.PARAMETER_MODEL_TABLE_NAME).getParameterValue().trim();
        }

        if (null != modelName && null == modelTableName) {
            throw new IllegalArgumentException(QueryParameters.PARAMETER_MODEL_NAME + " has been specified but " + QueryParameters.PARAMETER_MODEL_TABLE_NAME
                            + " is missing. Both are required to use a model");
        }

        if (null != modelName && null != modelTableName) {
            this.queryModel = metadataHelper.getQueryModel(modelTableName, modelName, this.getUnevaluatedFields());
        }

        // I'm using this config object in a pinch, we should probably create a custom one.
        ShardQueryConfiguration config = ShardQueryConfigurationFactory.createShardQueryConfigurationFromConfiguredLogic(this, settings);
        config.setConnector(connection);
        config.setAuthorizations(auths);

        // the following throw IllegalArgumentExceptions if validation fails.
        parseQuery(config, settings);
        configDate(config, settings);
        configTypeFilter(config, settings);

        Set<String> normalizedFieldValues = null;
        Iterator<String> fieldNameIter = fieldNames.iterator();
        while (fieldNameIter.hasNext()) {
            String fieldName = fieldNameIter.next();
            // check that the field name is actually an indexed field
            Set<Type<?>> normalizerSet = metadataHelper.getDatatypesForField(fieldName, config.getDatatypeFilter());
            if (null != normalizerSet && !normalizerSet.isEmpty()) {
                if (null != this.fieldValues && !this.fieldValues.isEmpty()) {
                    for (Type<?> norm : normalizerSet) {
                        if (null == normalizedFieldValues) {
                            normalizedFieldValues = new HashSet<String>();
                        }
                        for (String val : this.fieldValues) {
                            try {
                                String normVal = norm.normalize(val);
                                if (null != normVal && !normVal.isEmpty()) {
                                    normalizedFieldValues.add(normVal);
                                }
                            } catch (Exception e) {
                                logger.debug(norm + " failed to normalize value: " + val);
                            }
                        }
                    }
                }
            } else {
                if (logger.isTraceEnabled()) {
                    logger.trace("dropping fieldname " + fieldName + " because it's not indexed.");
                }
                // drop fieldName since it isn't indexed.
                fieldNameIter.remove();
            }
        }
        this.fieldValues = normalizedFieldValues;

        if (this.fieldNames.isEmpty()) {
            throw new IllegalArgumentException("Need at least 1 indexed field to query with.");
        }

        // Generate & set the query ranges
        this.ranges = generateRanges(config);

        // Find out if we need to list unique data types.
        if (null != settings.findParameter(Constants.UNIQ_DATATYPE)) {
            this.uniqueByDataType = Boolean.parseBoolean(settings.findParameter(Constants.UNIQ_DATATYPE).getParameterValue());
            if (logger.isTraceEnabled()) {
                logger.trace("uniqueByDataType: " + uniqueByDataType);
            }
        }

        // Find out if we need to list unique visibilities.
        if (null != settings.findParameter(Constants.UNIQ_VISIBILITY)) {
            this.uniqueByVisibility = Boolean.parseBoolean(settings.findParameter(Constants.UNIQ_VISIBILITY).getParameterValue());
            if (logger.isTraceEnabled()) {
                logger.trace("uniqueByVisibility: " + uniqueByVisibility);
            }
        }

        if (logger.isTraceEnabled()) {
            logger.trace("FieldNames: ");
            for (String f : this.fieldNames) {
                logger.trace("\t" + f);
            }
            logger.trace("FieldValues: ");
            if (null == this.fieldValues) {
                logger.trace("\tnone");
            } else {
                for (String f : this.fieldValues) {
                    logger.trace("\t" + f);
                }
            }
            logger.trace("uniqueByDataType: " + uniqueByDataType);
            logger.trace("uniqueByVisibility: " + uniqueByVisibility);
        }
        return config;
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public initialize(connection Connector, settings Query, auths Set<Authorizations>) : GenericQueryConfiguration from class datawave.query.tables.shard.FieldIndexCountQueryLogic


    public Map buildSummary(Iterator iter, long maxValues) {
        if (logger.isTraceEnabled()) {
            logger.trace("buildSummary");
        }
        Map<String,Tuple> summary = new HashMap<>();
        String cf;
        StringBuilder mapKeyBuilder = new StringBuilder();
        String mapKey;
        while (iter.hasNext()) {
            Object input = iter.next();

            if (input instanceof Entry<?,?>) {
                @SuppressWarnings("unchecked")
                Entry<Key,Value> entry = (Entry<Key,Value>) input;

                if (entry.getKey() == null && entry.getValue() == null) {
                    break;
                }

                if (null == entry.getKey() || null == entry.getValue()) {
                    throw new IllegalArgumentException("Null key or value. Key:" + entry.getKey() + ", Value: " + entry.getValue());
                }

                Key key = entry.getKey();
                Value val = entry.getValue();
                mapKeyBuilder.delete(0, mapKeyBuilder.length());

                // build out the map key
                cf = key.getColumnFamily().toString().substring(3); // strip off fi\x00
                if (queryModel != null) {
                    String aliasReverseName = queryModel.aliasFieldNameReverseModel(cf);
                    if (null == aliasReverseName || aliasReverseName.isEmpty()) {
                        mapKeyBuilder.append(cf);
                    } else {
                        mapKeyBuilder.append(aliasReverseName);
                    }
                } else {
                    mapKeyBuilder.append(cf);
                }

                mapKeyBuilder.append(Constants.NULL_BYTE_STRING);
                mapKeyBuilder.append(key.getColumnQualifier().toString());
                mapKey = mapKeyBuilder.toString();

                // if we are over our threshold for unique values skip it.
                if (!summary.containsKey(mapKey) && summary.size() == maxValues) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("hit maxValues for unique field values");
                    }
                    continue;
                }

                Tuple tuple = summary.containsKey(mapKey) ? summary.get(mapKey) : new Tuple(super.getMarkingFunctions());
                tuple.aggregate(key, val);
                summary.put(mapKey, tuple);
            } else {
                throw new IllegalArgumentException("Invalid input type: " + input.getClass());
            }
        }
        if (logger.isDebugEnabled()) {
            logger.debug("finished building summary, map has size: " + summary.size());
        }
        return summary;
    }

    public Map buildSummary(Iterator iter, long maxValues) {
        if (logger.isTraceEnabled()) {
            logger.trace("buildSummary");
        }
        Map<String,Tuple> summary = new HashMap<String,Tuple>();
        String cf;
        StringBuilder mapKeyBuilder = new StringBuilder();
        String mapKey;
        while (iter.hasNext()) {
            Object input = iter.next();

            if (input instanceof Entry<?,?>) {
                @SuppressWarnings("unchecked")
                Entry<Key,Value> entry = (Entry<Key,Value>) input;

                if (entry.getKey() == null && entry.getValue() == null) {
                    break;
                }

                if (null == entry.getKey() || null == entry.getValue()) {
                    throw new IllegalArgumentException("Null key or value. Key:" + entry.getKey() + ", Value: " + entry.getValue());
                }

                Key key = entry.getKey();
                Value val = entry.getValue();
                mapKeyBuilder.delete(0, mapKeyBuilder.length());

                // build out the map key
                cf = key.getColumnFamily().toString().substring(3); // strip off fi\x00
                if (queryModel != null) {
                    String aliasReverseName = queryModel.aliasFieldNameReverseModel(cf);
                    if (null == aliasReverseName || aliasReverseName.isEmpty()) {
                        mapKeyBuilder.append(cf);
                    } else {
                        mapKeyBuilder.append(aliasReverseName);
                    }
                } else {
                    mapKeyBuilder.append(cf);
                }

                mapKeyBuilder.append(Constants.NULL_BYTE_STRING);
                mapKeyBuilder.append(key.getColumnQualifier().toString());
                mapKey = mapKeyBuilder.toString();

                // if we are over our threshold for unique values skip it.
                if (!summary.containsKey(mapKey) && summary.size() == maxValues) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("hit maxValues for unique field values");
                    }
                    continue;
                }

                Tuple tuple = summary.containsKey(mapKey) ? summary.get(mapKey) : new Tuple(super.getMarkingFunctions());
                tuple.aggregate(key, val);
                summary.put(mapKey, tuple);
            } else {
                throw new IllegalArgumentException("Invalid input type: " + input.getClass());
            }
        }
        if (logger.isDebugEnabled()) {
            logger.debug("finished building summary, map has size: " + summary.size());
        }
        return summary;
    }

Replace Generic With Diamond HashMap<String,Tuple> with HashMap<> in method public buildSummary(iter Iterator, maxValues long) : Map from class datawave.query.tables.shard.FieldIndexCountQueryLogic


    @Override
    public Set<String> getOptionalQueryParameters() {
        Set<String> params = new TreeSet<>();
        params.add(QueryParameters.PARAMETER_MODEL_NAME);
        params.add(QueryParameters.PARAMETER_MODEL_TABLE_NAME);
        params.add(QueryParameters.DATATYPE_FILTER_SET);
        return params;
    }

    @Override
    public Set<String> getOptionalQueryParameters() {
        Set<String> params = new TreeSet<String>();
        params.add(QueryParameters.PARAMETER_MODEL_NAME);
        params.add(QueryParameters.PARAMETER_MODEL_TABLE_NAME);
        params.add(QueryParameters.DATATYPE_FILTER_SET);
        return params;
    }

Replace Generic With Diamond TreeSet<String> with TreeSet<> in method public getOptionalQueryParameters() : Set<String> from class datawave.query.tables.shard.FieldIndexCountQueryLogic


    @Override
    public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
        if (log.isTraceEnabled()) {
            log.trace("TLDQueryIterator init()");
        }

        // extract SeekingQueryPlanner fields if available
        if (options.get(SeekingQueryPlanner.MAX_FIELD_HITS_BEFORE_SEEK) != null) {
            maxFieldHitsBeforeSeek = Integer.parseInt(options.get(SeekingQueryPlanner.MAX_FIELD_HITS_BEFORE_SEEK));
        }

        if (options.get(SeekingQueryPlanner.MAX_KEYS_BEFORE_SEEK) != null) {
            maxKeysBeforeSeek = Integer.parseInt(options.get(SeekingQueryPlanner.MAX_KEYS_BEFORE_SEEK));
        }

        super.init(source, options, env);

        super.fiAggregator = new TLDFieldIndexAggregator(getAllIndexOnlyFields(), getEvaluationFilter(), maxKeysBeforeSeek);

        // Replace the fieldIndexKeyDataTypeFilter with a chain of "anded" index-filtering predicates.
        // If no other predicates are configured via the indexfiltering.classes property, the method
        // simply returns the existing fieldIndexKeyDataTypeFilter value. Otherwise, the returned value
        // contains an "anded" chain of newly configured predicates following the existing
        // fieldIndexKeyDataTypeFilter value (assuming it is defined with something other than the default
        // "ALWAYS_TRUE" KeyIdentity.Function).
        fieldIndexKeyDataTypeFilter = parseIndexFilteringChain(new SourcedOptions<>(source, env, options));

        disableIndexOnlyDocuments = false;
    }

    @Override
    public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
        if (log.isTraceEnabled()) {
            log.trace("TLDQueryIterator init()");
        }

        // extract SeekingQueryPlanner fields if available
        if (options.get(SeekingQueryPlanner.MAX_FIELD_HITS_BEFORE_SEEK) != null) {
            maxFieldHitsBeforeSeek = Integer.parseInt(options.get(SeekingQueryPlanner.MAX_FIELD_HITS_BEFORE_SEEK));
        }

        if (options.get(SeekingQueryPlanner.MAX_KEYS_BEFORE_SEEK) != null) {
            maxKeysBeforeSeek = Integer.parseInt(options.get(SeekingQueryPlanner.MAX_KEYS_BEFORE_SEEK));
        }

        super.init(source, options, env);

        super.fiAggregator = new TLDFieldIndexAggregator(getAllIndexOnlyFields(), getEvaluationFilter(), maxKeysBeforeSeek);

        // Replace the fieldIndexKeyDataTypeFilter with a chain of "anded" index-filtering predicates.
        // If no other predicates are configured via the indexfiltering.classes property, the method
        // simply returns the existing fieldIndexKeyDataTypeFilter value. Otherwise, the returned value
        // contains an "anded" chain of newly configured predicates following the existing
        // fieldIndexKeyDataTypeFilter value (assuming it is defined with something other than the default
        // "ALWAYS_TRUE" KeyIdentity.Function).
        fieldIndexKeyDataTypeFilter = parseIndexFilteringChain(new SourcedOptions<String,String>(source, env, options));

        disableIndexOnlyDocuments = false;
    }

Replace Generic With Diamond SourcedOptions<String,String> with SourcedOptions<> in method public init(source SortedKeyValueIterator<Key,Value>, options Map<String,String>, env IteratorEnvironment) : void from class datawave.query.tld.TLDQueryIterator


    @Override
    public DefaultEvent transform(Entry<Key,Value> entry) {

        if (entry.getKey() == null && entry.getValue() == null)
            return null;

        if (null == entry.getKey() || null == entry.getValue()) {
            throw new IllegalArgumentException("Null key or value. Key:" + entry.getKey() + ", Value: " + entry.getValue());
        }

        ContentKeyValue ckv;
        try {
            ckv = ContentKeyValueFactory.parse(entry.getKey(), entry.getValue(), auths, markingFunctions);
        } catch (Exception e1) {
            throw new IllegalArgumentException("Unable to parse visibility", e1);
        }

        DefaultEvent e = new DefaultEvent();
        DefaultField field = new DefaultField();

        e.setMarkings(ckv.getMarkings());

        Metadata m = new Metadata();
        m.setRow(ckv.getShardId());
        m.setDataType(ckv.getDatatype());
        m.setInternalId(ckv.getUid());
        e.setMetadata(m);

        field.setMarkings(ckv.getMarkings());
        field.setName(ckv.getViewName());
        field.setTimestamp(entry.getKey().getTimestamp());
        field.setValue(ckv.getContents());

        List<DefaultField> fields = new ArrayList<>();
        fields.add(field);
        e.setFields(fields);

        return e;

    }

    @Override
    public DefaultEvent transform(Entry<Key,Value> entry) {

        if (entry.getKey() == null && entry.getValue() == null)
            return null;

        if (null == entry.getKey() || null == entry.getValue()) {
            throw new IllegalArgumentException("Null key or value. Key:" + entry.getKey() + ", Value: " + entry.getValue());
        }

        ContentKeyValue ckv;
        try {
            ckv = ContentKeyValueFactory.parse(entry.getKey(), entry.getValue(), auths, markingFunctions);
        } catch (Exception e1) {
            throw new IllegalArgumentException("Unable to parse visibility", e1);
        }

        DefaultEvent e = new DefaultEvent();
        DefaultField field = new DefaultField();

        e.setMarkings(ckv.getMarkings());

        Metadata m = new Metadata();
        m.setRow(ckv.getShardId());
        m.setDataType(ckv.getDatatype());
        m.setInternalId(ckv.getUid());
        e.setMetadata(m);

        field.setMarkings(ckv.getMarkings());
        field.setName(ckv.getViewName());
        field.setTimestamp(entry.getKey().getTimestamp());
        field.setValue(ckv.getContents());

        List<DefaultField> fields = new ArrayList<DefaultField>();
        fields.add(field);
        e.setFields(fields);

        return e;

    }

Replace Generic With Diamond ArrayList<DefaultField> with ArrayList<> in method public transform(entry Entry<Key,Value>) : DefaultEvent from class datawave.query.transformer.ContentQueryTransformer


    @Override
    public BaseQueryResponse createResponse(List<Object> resultList) {
        FacetQueryResponseBase response = responseObjectFactory.getFacetQueryResponse();
        Set<ColumnVisibility> combinedColumnVisibility = new HashSet<>();

        for (Object result : resultList) {
            FacetsBase facet = (FacetsBase) result;
            response.addFacet(facet);

            // Turns out that the column visibility is not set on the key returned & not added to markings map
            // so loop through the fields instead

            for (FieldCardinalityBase fcb : facet.getFields()) {
                if (StringUtils.isNotBlank(fcb.getColumnVisibility())) {
                    combinedColumnVisibility.add(new ColumnVisibility(fcb.getColumnVisibility()));
                }
            }
        }

        try {
            ColumnVisibility columnVisibility = this.markingFunctions.combine(combinedColumnVisibility);
            response.setMarkings(this.markingFunctions.translateFromColumnVisibility(columnVisibility));

        } catch (MarkingFunctions.Exception e) {
            log.warn(e);
            // original ignored these exceptions
        }

        return response;
    }

    @Override
    public BaseQueryResponse createResponse(List<Object> resultList) {
        FacetQueryResponseBase response = responseObjectFactory.getFacetQueryResponse();
        Set<ColumnVisibility> combinedColumnVisibility = new HashSet<ColumnVisibility>();

        for (Object result : resultList) {
            FacetsBase facet = (FacetsBase) result;
            response.addFacet(facet);

            // Turns out that the column visibility is not set on the key returned & not added to markings map
            // so loop through the fields instead

            for (FieldCardinalityBase fcb : facet.getFields()) {
                if (StringUtils.isNotBlank(fcb.getColumnVisibility())) {
                    combinedColumnVisibility.add(new ColumnVisibility(fcb.getColumnVisibility()));
                }
            }
        }

        try {
            ColumnVisibility columnVisibility = this.markingFunctions.combine(combinedColumnVisibility);
            response.setMarkings(this.markingFunctions.translateFromColumnVisibility(columnVisibility));

        } catch (MarkingFunctions.Exception e) {
            log.warn(e);
            // original ignored these exceptions
        }

        return response;
    }

Replace Generic With Diamond HashSet<ColumnVisibility> with HashSet<> in method public createResponse(resultList List<Object>) : BaseQueryResponse from class datawave.query.transformer.FacetedTransformer


    /**
     * Get expansion fields using the data type filter.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getExpansionFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> expansionFields = loadExpansionFields();

        Set<String> fields = new HashSet<>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(expansionFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(expansionFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

    /**
     * Get expansion fields using the data type filter.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getExpansionFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> expansionFields = loadExpansionFields();

        Set<String> fields = new HashSet<String>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(expansionFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(expansionFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public getExpansionFields(ingestTypeFilter Set<String>) : Set<String> from class datawave.query.util.AllFieldMetadataHelper


    /**
     * Get the content fields which are those to be queried when using the content functions.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getContentFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> contentFields = loadContentFields();

        Set<String> fields = new HashSet<>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(contentFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(contentFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

    /**
     * Get the content fields which are those to be queried when using the content functions.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getContentFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> contentFields = loadContentFields();

        Set<String> fields = new HashSet<String>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(contentFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(contentFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public getContentFields(ingestTypeFilter Set<String>) : Set<String> from class datawave.query.util.AllFieldMetadataHelper


    /**
     * Get expansion fields using the data type filter.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getExpansionFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> expansionFields = this.allFieldMetadataHelper.loadExpansionFields();

        Set<String> fields = new HashSet<>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(expansionFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(expansionFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

    /**
     * Get expansion fields using the data type filter.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getExpansionFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> expansionFields = this.allFieldMetadataHelper.loadExpansionFields();

        Set<String> fields = new HashSet<String>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(expansionFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(expansionFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public getExpansionFields(ingestTypeFilter Set<String>) : Set<String> from class datawave.query.util.MetadataHelper


    /**
     * Get the content fields which are those to be queried when using the content functions.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getContentFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> contentFields = this.allFieldMetadataHelper.loadContentFields();

        Set<String> fields = new HashSet<>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(contentFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(contentFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

    /**
     * Get the content fields which are those to be queried when using the content functions.
     *
     * @param ingestTypeFilter
     * @return
     * @throws TableNotFoundException
     */
    public Set<String> getContentFields(Set<String> ingestTypeFilter) throws TableNotFoundException {

        Multimap<String,String> contentFields = this.allFieldMetadataHelper.loadContentFields();

        Set<String> fields = new HashSet<String>();
        if (ingestTypeFilter == null || ingestTypeFilter.isEmpty()) {
            fields.addAll(contentFields.values());
        } else {
            for (String datatype : ingestTypeFilter) {
                fields.addAll(contentFields.get(datatype));
            }
        }
        return Collections.unmodifiableSet(fields);
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public getContentFields(ingestTypeFilter Set<String>) : Set<String> from class datawave.query.util.MetadataHelper


    /**
     * @param connector
     * @param tableName
     * @param auths
     * @param allFields
     */
    public QueryModelLoader(Connector connector, String tableName, Set<Authorizations> auths, Set<String> allFields) {
        super(connector, tableName, auths, new ArrayList<>());

        this.allFields = allFields;

        if (log.isDebugEnabled())
            log.debug("Initializing");

    }

    /**
     * @param connector
     * @param tableName
     * @param auths
     * @param allFields
     */
    public QueryModelLoader(Connector connector, String tableName, Set<Authorizations> auths, Set<String> allFields) {
        super(connector, tableName, auths, new ArrayList<Text>());

        this.allFields = allFields;

        if (log.isDebugEnabled())
            log.debug("Initializing");

    }

Replace Generic With Diamond ArrayList<Text> with ArrayList<> in method public QueryModelLoader(connector Connector, tableName String, auths Set<Authorizations>, allFields Set<String>) from class datawave.query.util.cache.QueryModelLoader


    public void process(Connector con, ModificationRequestBase request, Map<String,Set<String>> mutableFieldList, Set<Authorizations> userAuths, String user,
                    boolean purgeIndex, boolean insertHistory) throws Exception {

        DefaultModificationRequest mr = DefaultModificationRequest.class.cast(request);

        if (null == mr.getEvents() || mr.getEvents().size() == 0) {
            throw new IllegalArgumentException("No events specified for modification");
        }

        String fieldName = mr.getFieldName();
        MetadataHelper helper = getMetadataHelper(con);
        MODE mode = mr.getMode();
        MultiTableBatchWriter writer = con.createMultiTableBatchWriter(new BatchWriterConfig().setMaxLatency(1, TimeUnit.SECONDS).setMaxMemory(1048576L)
                        .setMaxWriteThreads(4));
        try {
            for (EventIdentifier e : mr.getEvents()) {
                String shardId = e.getShardId();
                String datatype = e.getDatatype();
                Set<String> datatypeFilter = Collections.singleton(datatype);
                String eventUid = e.getEventUid();

                String oldFieldValue = null;
                Map<String,String> oldFieldMarkings = null;
                String oldColumnVisibility = null;
                List<Pair<Key,Value>> currentEntryList = null;
                int valHistoryCount = 0;

                /*
                 * Makes all fields mutable for services requiring no history.
                 */
                if (insertHistory && !isFieldMutable(mutableFieldList, datatype, fieldName))
                    throw new IllegalArgumentException("Field " + fieldName + " is not mutable");

                boolean isIndexed = helper.isIndexed(fieldName, datatypeFilter);
                boolean isReverseIndexed = helper.isReverseIndexed(fieldName, datatypeFilter);
                boolean isIndexOnly = helper.getIndexOnlyFields(datatypeFilter).contains(fieldName);
                boolean isContent = (contentFields != null && contentFields.contains(fieldName));
                Set<Type<?>> dataTypes = helper.getDatatypesForField(fieldName, Collections.singleton(datatype));

                if ((isIndexed || isReverseIndexed || isIndexOnly) && (null == dataTypes || dataTypes.size() == 0))
                    throw new IllegalStateException("Field " + fieldName + " is marked index only but has no dataTypes");

                long origTimestamp = getOriginalEventTimestamp(con, userAuths, shardId, datatype, eventUid);

                // Count the history entries if history is going to be inserted.
                if (insertHistory && (MODE.INSERT.equals(mode) || MODE.UPDATE.equals(mode))) {
                    List<Pair<Key,Value>> fieldHistoryList = getField(con, userAuths, shardId, datatype, eventUid, "HISTORY_" + fieldName, null,
                                    new HashMap<>(), null);

                    for (Pair<Key,Value> p : fieldHistoryList) {
                        if (p.getFirst().getColumnQualifier().find(mr.getFieldValue()) > -1) {
                            ++valHistoryCount;
                        }
                    }
                }

                if (MODE.UPDATE.equals(mode) || MODE.DELETE.equals(mode)) {
                    if (MODE.UPDATE.equals(mode)) {
                        oldFieldValue = mr.getOldFieldValue();
                        oldFieldMarkings = mr.getOldFieldMarkings();
                        oldColumnVisibility = mr.getOldColumnVisibility();
                        if (null == oldFieldValue)
                            throw new IllegalArgumentException("fieldValue parameter required for update");
                    } else {
                        oldFieldValue = mr.getFieldValue();
                        oldFieldMarkings = mr.getFieldMarkings();
                        oldColumnVisibility = mr.getColumnVisibility();
                        if (null == oldFieldValue)
                            throw new IllegalArgumentException("fieldValue parameter required for delete");
                    }
                    ColumnVisibility oldViz = null;
                    if (null != oldColumnVisibility) {
                        oldViz = new ColumnVisibility(oldColumnVisibility);
                    }

                    // find the current values
                    currentEntryList = getField(con, userAuths, shardId, datatype, eventUid, fieldName, oldFieldValue, oldFieldMarkings, oldViz);
                    if (oldFieldValue != null && currentEntryList.size() == 0) {
                        throw new IllegalArgumentException("Modification request rejected. Current value of " + fieldName + " does not match submitted value.");
                    }
                } else {
                    if (null == mr.getFieldValue())
                        throw new IllegalArgumentException("fieldValue parameter required for insert");
                }

                if (MODE.INSERT.equals(mode)) {
                    String fieldValue = mr.getFieldValue();
                    Map<String,String> fieldMarkings = mr.getFieldMarkings();
                    String columnVisibility = mr.getColumnVisibility();
                    ColumnVisibility colviz = null;
                    if (null != columnVisibility) {
                        colviz = new ColumnVisibility(columnVisibility);
                    }
                    insert(writer, shardId, datatype, eventUid, fieldMarkings, colviz, fieldName, fieldValue, isIndexOnly, isIndexed, isReverseIndexed,
                                    dataTypes, user, MODE.INSERT, origTimestamp + valHistoryCount, insertHistory);
                } else if (MODE.DELETE.equals(mode)) {
                    delete(writer, con, userAuths, currentEntryList, isIndexOnly, isIndexed, isReverseIndexed, isContent, dataTypes, user, MODE.DELETE,
                                    origTimestamp + valHistoryCount, purgeIndex, insertHistory);
                } else {
                    delete(writer, con, userAuths, currentEntryList, isIndexOnly, isIndexed, isReverseIndexed, isContent, dataTypes, user, MODE.UPDATE,
                                    origTimestamp + valHistoryCount, purgeIndex, insertHistory);
                    String fieldValue = mr.getFieldValue();
                    Map<String,String> fieldMarkings = mr.getFieldMarkings();
                    String columnVisibility = mr.getColumnVisibility();
                    ColumnVisibility colviz = null;
                    if (null != columnVisibility) {
                        colviz = new ColumnVisibility(columnVisibility);
                    }
                    insert(writer, shardId, datatype, eventUid, fieldMarkings, colviz, fieldName, fieldValue, isIndexOnly, isIndexed, isReverseIndexed,
                                    dataTypes, user, MODE.UPDATE, origTimestamp + valHistoryCount, insertHistory);
                }
            }
        } finally {
            writer.close();
        }
    }

    public void process(Connector con, ModificationRequestBase request, Map<String,Set<String>> mutableFieldList, Set<Authorizations> userAuths, String user,
                    boolean purgeIndex, boolean insertHistory) throws Exception {

        DefaultModificationRequest mr = DefaultModificationRequest.class.cast(request);

        if (null == mr.getEvents() || mr.getEvents().size() == 0) {
            throw new IllegalArgumentException("No events specified for modification");
        }

        String fieldName = mr.getFieldName();
        MetadataHelper helper = getMetadataHelper(con);
        MODE mode = mr.getMode();
        MultiTableBatchWriter writer = con.createMultiTableBatchWriter(new BatchWriterConfig().setMaxLatency(1, TimeUnit.SECONDS).setMaxMemory(1048576L)
                        .setMaxWriteThreads(4));
        try {
            for (EventIdentifier e : mr.getEvents()) {
                String shardId = e.getShardId();
                String datatype = e.getDatatype();
                Set<String> datatypeFilter = Collections.singleton(datatype);
                String eventUid = e.getEventUid();

                String oldFieldValue = null;
                Map<String,String> oldFieldMarkings = null;
                String oldColumnVisibility = null;
                List<Pair<Key,Value>> currentEntryList = null;
                int valHistoryCount = 0;

                /*
                 * Makes all fields mutable for services requiring no history.
                 */
                if (insertHistory && !isFieldMutable(mutableFieldList, datatype, fieldName))
                    throw new IllegalArgumentException("Field " + fieldName + " is not mutable");

                boolean isIndexed = helper.isIndexed(fieldName, datatypeFilter);
                boolean isReverseIndexed = helper.isReverseIndexed(fieldName, datatypeFilter);
                boolean isIndexOnly = helper.getIndexOnlyFields(datatypeFilter).contains(fieldName);
                boolean isContent = (contentFields != null && contentFields.contains(fieldName));
                Set<Type<?>> dataTypes = helper.getDatatypesForField(fieldName, Collections.singleton(datatype));

                if ((isIndexed || isReverseIndexed || isIndexOnly) && (null == dataTypes || dataTypes.size() == 0))
                    throw new IllegalStateException("Field " + fieldName + " is marked index only but has no dataTypes");

                long origTimestamp = getOriginalEventTimestamp(con, userAuths, shardId, datatype, eventUid);

                // Count the history entries if history is going to be inserted.
                if (insertHistory && (MODE.INSERT.equals(mode) || MODE.UPDATE.equals(mode))) {
                    List<Pair<Key,Value>> fieldHistoryList = getField(con, userAuths, shardId, datatype, eventUid, "HISTORY_" + fieldName, null,
                                    new HashMap<String,String>(), null);

                    for (Pair<Key,Value> p : fieldHistoryList) {
                        if (p.getFirst().getColumnQualifier().find(mr.getFieldValue()) > -1) {
                            ++valHistoryCount;
                        }
                    }
                }

                if (MODE.UPDATE.equals(mode) || MODE.DELETE.equals(mode)) {
                    if (MODE.UPDATE.equals(mode)) {
                        oldFieldValue = mr.getOldFieldValue();
                        oldFieldMarkings = mr.getOldFieldMarkings();
                        oldColumnVisibility = mr.getOldColumnVisibility();
                        if (null == oldFieldValue)
                            throw new IllegalArgumentException("fieldValue parameter required for update");
                    } else {
                        oldFieldValue = mr.getFieldValue();
                        oldFieldMarkings = mr.getFieldMarkings();
                        oldColumnVisibility = mr.getColumnVisibility();
                        if (null == oldFieldValue)
                            throw new IllegalArgumentException("fieldValue parameter required for delete");
                    }
                    ColumnVisibility oldViz = null;
                    if (null != oldColumnVisibility) {
                        oldViz = new ColumnVisibility(oldColumnVisibility);
                    }

                    // find the current values
                    currentEntryList = getField(con, userAuths, shardId, datatype, eventUid, fieldName, oldFieldValue, oldFieldMarkings, oldViz);
                    if (oldFieldValue != null && currentEntryList.size() == 0) {
                        throw new IllegalArgumentException("Modification request rejected. Current value of " + fieldName + " does not match submitted value.");
                    }
                } else {
                    if (null == mr.getFieldValue())
                        throw new IllegalArgumentException("fieldValue parameter required for insert");
                }

                if (MODE.INSERT.equals(mode)) {
                    String fieldValue = mr.getFieldValue();
                    Map<String,String> fieldMarkings = mr.getFieldMarkings();
                    String columnVisibility = mr.getColumnVisibility();
                    ColumnVisibility colviz = null;
                    if (null != columnVisibility) {
                        colviz = new ColumnVisibility(columnVisibility);
                    }
                    insert(writer, shardId, datatype, eventUid, fieldMarkings, colviz, fieldName, fieldValue, isIndexOnly, isIndexed, isReverseIndexed,
                                    dataTypes, user, MODE.INSERT, origTimestamp + valHistoryCount, insertHistory);
                } else if (MODE.DELETE.equals(mode)) {
                    delete(writer, con, userAuths, currentEntryList, isIndexOnly, isIndexed, isReverseIndexed, isContent, dataTypes, user, MODE.DELETE,
                                    origTimestamp + valHistoryCount, purgeIndex, insertHistory);
                } else {
                    delete(writer, con, userAuths, currentEntryList, isIndexOnly, isIndexed, isReverseIndexed, isContent, dataTypes, user, MODE.UPDATE,
                                    origTimestamp + valHistoryCount, purgeIndex, insertHistory);
                    String fieldValue = mr.getFieldValue();
                    Map<String,String> fieldMarkings = mr.getFieldMarkings();
                    String columnVisibility = mr.getColumnVisibility();
                    ColumnVisibility colviz = null;
                    if (null != columnVisibility) {
                        colviz = new ColumnVisibility(columnVisibility);
                    }
                    insert(writer, shardId, datatype, eventUid, fieldMarkings, colviz, fieldName, fieldValue, isIndexOnly, isIndexed, isReverseIndexed,
                                    dataTypes, user, MODE.UPDATE, origTimestamp + valHistoryCount, insertHistory);
                }
            }
        } finally {
            writer.close();
        }
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public process(con Connector, request ModificationRequestBase, mutableFieldList Map<String,Set<String>>, userAuths Set<Authorizations>, user String, purgeIndex boolean, insertHistory boolean) : void from class datawave.webservice.modification.MutableMetadataHandler


    /**
     * Test method for {@link datawave.core.iterators.RangeSplitter#RangeSplitter(org.apache.accumulo.core.data.Range, int)}.
     */
    @Test
    public void testSourcePoolWait() throws InterruptedException {
        final Set<SortedKeyValueIterator<Key,Value>> sources = new HashSet<>();
        final SourcePool<Key,Value> pool = new SourcePool(factory, 10);
        for (int i = 0; i < 10; i++) {
            SortedKeyValueIterator<Key,Value> source = pool.checkOut();
            sources.add(source);
        }

        for (int i = 0; i < 10; i++) {
            SortedKeyValueIterator<Key,Value> source = pool.checkOut(i + 10);
            Assert.assertNull(source);
        }

        final List<Throwable> failed = new ArrayList<>();

        final MutableBoolean waitingForCheckOut = new MutableBoolean(true);
        final SortedKeyValueIterator<Key,Value> threadSource = sources.iterator().next();
        sources.remove(threadSource);
        Thread thread = new Thread(() -> {
            try {
                SortedKeyValueIterator<Key,Value> source = pool.checkOut(-1);
                waitingForCheckOut.setValue(false);
                Assert.assertNotNull(source);
                Assert.assertFalse(sources.contains(source));
                sources.add(source);
                Assert.assertNotEquals(factory.source, source);
            } catch (Throwable e) {
                synchronized (failed) {
                    e.printStackTrace();
                    failed.add(e);
                }
            }
        });
        thread.setUncaughtExceptionHandler((t, e) -> {
            synchronized (failed) {
                e.printStackTrace();
                failed.add(e);
            }
        });

        thread.start();

        for (int i = 0; i < 10; i++) {
            Thread.sleep(100);
            Assert.assertTrue(waitingForCheckOut.booleanValue());
            Assert.assertTrue(thread.isAlive());
            Assert.assertTrue(failed.isEmpty());
        }

        pool.checkIn(threadSource);

        int count = 0;
        while (thread.isAlive()) {
            try {
                count++;
                Thread.sleep(10);
                if (count > 1000) {
                    Assert.fail("Expected thread to complete");
                    break;
                }
            } catch (InterruptedException ie) {
                // Do nothing
            }
        }

        Assert.assertFalse(waitingForCheckOut.booleanValue());
        Assert.assertTrue(failed.isEmpty());
    }

    /**
     * Test method for {@link datawave.core.iterators.RangeSplitter#RangeSplitter(org.apache.accumulo.core.data.Range, int)}.
     */
    @Test
    public void testSourcePoolWait() throws InterruptedException {
        final Set<SortedKeyValueIterator<Key,Value>> sources = new HashSet<>();
        final SourcePool<Key,Value> pool = new SourcePool(factory, 10);
        for (int i = 0; i < 10; i++) {
            SortedKeyValueIterator<Key,Value> source = pool.checkOut();
            sources.add(source);
        }

        for (int i = 0; i < 10; i++) {
            SortedKeyValueIterator<Key,Value> source = pool.checkOut(i + 10);
            Assert.assertNull(source);
        }

        final List<Throwable> failed = new ArrayList<Throwable>();

        final MutableBoolean waitingForCheckOut = new MutableBoolean(true);
        final SortedKeyValueIterator<Key,Value> threadSource = sources.iterator().next();
        sources.remove(threadSource);
        Thread thread = new Thread(() -> {
            try {
                SortedKeyValueIterator<Key,Value> source = pool.checkOut(-1);
                waitingForCheckOut.setValue(false);
                Assert.assertNotNull(source);
                Assert.assertFalse(sources.contains(source));
                sources.add(source);
                Assert.assertNotEquals(factory.source, source);
            } catch (Throwable e) {
                synchronized (failed) {
                    e.printStackTrace();
                    failed.add(e);
                }
            }
        });
        thread.setUncaughtExceptionHandler((t, e) -> {
            synchronized (failed) {
                e.printStackTrace();
                failed.add(e);
            }
        });

        thread.start();

        for (int i = 0; i < 10; i++) {
            Thread.sleep(100);
            Assert.assertTrue(waitingForCheckOut.booleanValue());
            Assert.assertTrue(thread.isAlive());
            Assert.assertTrue(failed.isEmpty());
        }

        pool.checkIn(threadSource);

        int count = 0;
        while (thread.isAlive()) {
            try {
                count++;
                Thread.sleep(10);
                if (count > 1000) {
                    Assert.fail("Expected thread to complete");
                    break;
                }
            } catch (InterruptedException ie) {
                // Do nothing
            }
        }

        Assert.assertFalse(waitingForCheckOut.booleanValue());
        Assert.assertTrue(failed.isEmpty());
    }

Replace Generic With Diamond ArrayList<Throwable> with ArrayList<> in method public testSourcePoolWait() : void from class datawave.core.iterators.SourcePoolTest


    @Test
    public void testEdgeQuerySyntax() throws Exception {
        QueryImpl q = configQuery("(SOURCE =~ 'M.*') && (SINK == 'JUPITER') && (RELATION == 'FROM-TO' || RELATION == 'TO-FROM')", auths);
        q.addParameter("stats", "true");
        DefaultExtendedEdgeQueryLogic logic = runLogic(q, auths);

        List<String> expected = new ArrayList<>();

        expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");
        expected.add("mercury STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");

        compareResults(logic, expected);
    }

    @Test
    public void testEdgeQuerySyntax() throws Exception {
        QueryImpl q = configQuery("(SOURCE =~ 'M.*') && (SINK == 'JUPITER') && (RELATION == 'FROM-TO' || RELATION == 'TO-FROM')", auths);
        q.addParameter("stats", "true");
        DefaultExtendedEdgeQueryLogic logic = runLogic(q, auths);

        List<String> expected = new ArrayList<String>();

        expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");
        expected.add("mercury STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");

        compareResults(logic, expected);
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public testEdgeQuerySyntax() : void from class datawave.query.edge.ExtendedEdgeQueryLogicTest


    @Test
    public void testEdgeQuerySyntax_WithQueryModel() throws Exception {
        QueryImpl q = configQuery("(VERTEXA =~ 'M.*') && (VERTEXB == 'JUPITER') && (RELATION == 'FROM-TO' || RELATION == 'TO-FROM')", auths);
        q.addParameter("stats", "true");
        DefaultExtendedEdgeQueryLogic logic = runLogic(q, auths);

        List<String> expected = new ArrayList<>();

        expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");
        expected.add("mercury STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");

        compareResults(logic, expected);
    }

    @Test
    public void testEdgeQuerySyntax_WithQueryModel() throws Exception {
        QueryImpl q = configQuery("(VERTEXA =~ 'M.*') && (VERTEXB == 'JUPITER') && (RELATION == 'FROM-TO' || RELATION == 'TO-FROM')", auths);
        q.addParameter("stats", "true");
        DefaultExtendedEdgeQueryLogic logic = runLogic(q, auths);

        List<String> expected = new ArrayList<String>();

        expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");
        expected.add("mercury STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");

        compareResults(logic, expected);
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public testEdgeQuerySyntax_WithQueryModel() : void from class datawave.query.edge.ExtendedEdgeQueryLogicTest


    @Test
    public void testEdgeSummaryQuerySyntax() throws Exception {
        QueryImpl q = configQuery("mars", auths);
        q.addParameter("stats", "true");
        q.addParameter("query.syntax", "LIST");
        DefaultExtendedEdgeQueryLogic logic = runLogic(q, auths);

        List<String> expected = new ArrayList<>();

        expected.add("mars%00;earth AdjacentPlanets/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars%00;asteroid_belt AdjacentCelestialBodies/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars%00;ceres AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [B]");
        expected.add("mars%00;ceres AdjacentDwarfPlanets/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [B]");
        expected.add("mars STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");

        compareResults(logic, expected);
    }

    @Test
    public void testEdgeSummaryQuerySyntax() throws Exception {
        QueryImpl q = configQuery("mars", auths);
        q.addParameter("stats", "true");
        q.addParameter("query.syntax", "LIST");
        DefaultExtendedEdgeQueryLogic logic = runLogic(q, auths);

        List<String> expected = new ArrayList<String>();

        expected.add("mars%00;earth AdjacentPlanets/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars%00;asteroid_belt AdjacentCelestialBodies/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [A]");
        expected.add("mars%00;ceres AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [B]");
        expected.add("mars%00;ceres AdjacentDwarfPlanets/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [B]");
        expected.add("mars STATS/ACTIVITY/Planets/TO:20150713/COSMOS_DATA [B]");

        compareResults(logic, expected);
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public testEdgeSummaryQuerySyntax() : void from class datawave.query.edge.ExtendedEdgeQueryLogicTest


    @Test
    public void testClear_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));

        // Set expectations, looping twice to simulate the 2 fetch sequences occurring before and after the
        // clear() invocation. Although size() is called 3 times, only the first and last should result in a
        // fetch sequence.
        for (int i = 0; i < 2; i++) {
            Iterator<Object> iterator = values.iterator();
            expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
            while (iterator.hasNext()) {
                expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
                expect(this.fetchingIterator.next()).andReturn(iterator.next());
                expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            }
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        String result1 = subject.getFieldName();
        int result2 = subject.size();
        int result3 = subject.size();
        subject.clear();
        int result4 = subject.size();
        verifyAll();

        // Verify results
        assertTrue("The field name should have been returned from the accessor", fieldName.equals(result1));

        assertEquals("Incorrect number of values fetched before the clear", values.size(), result2);

        assertEquals("Incorrect number of values fetched before the clear, which should NOT have resulted in a fetch operation", values.size(), result3);

        assertEquals("Incorrect number of values fetched after the clear", values.size(), result4);
    }

    @Test
    public void testClear_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));

        // Set expectations, looping twice to simulate the 2 fetch sequences occurring before and after the
        // clear() invocation. Although size() is called 3 times, only the first and last should result in a
        // fetch sequence.
        for (int i = 0; i < 2; i++) {
            Iterator<Object> iterator = values.iterator();
            expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
            while (iterator.hasNext()) {
                expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
                expect(this.fetchingIterator.next()).andReturn(iterator.next());
                expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            }
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        String result1 = subject.getFieldName();
        int result2 = subject.size();
        int result3 = subject.size();
        subject.clear();
        int result4 = subject.size();
        verifyAll();

        // Verify results
        assertTrue("The field name should have been returned from the accessor", fieldName.equals(result1));

        assertEquals("Incorrect number of values fetched before the clear", values.size(), result2);

        assertEquals("Incorrect number of values fetched before the clear, which should NOT have resulted in a fetch operation", values.size(), result3);

        assertEquals("Incorrect number of values fetched after the clear", values.size(), result4);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testClear_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testContains_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.contains("value3");
        boolean result2 = subject.contains("value1");
        verifyAll();

        // Verify results
        assertTrue("The subject should have contained the fetched value", result1);

        assertTrue("The subject should have contained the fetched value without forcing any more fetching", result2);
    }

    @Test
    public void testContains_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.contains("value3");
        boolean result2 = subject.contains("value1");
        verifyAll();

        // Verify results
        assertTrue("The subject should have contained the fetched value", result1);

        assertTrue("The subject should have contained the fetched value without forcing any more fetching", result2);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testContains_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testContainsAll_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.containsAll(Arrays.asList("value3", "value1"));
        verifyAll();

        // Verify results
        assertTrue("The subject should have contained the fetched values", result1);
    }

    @Test
    public void testContainsAll_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.containsAll(Arrays.asList("value3", "value1"));
        verifyAll();

        // Verify results
        assertTrue("The subject should have contained the fetched values", result1);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testContainsAll_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testIterator_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));

        // Set expectations
        for (int i = 0; i < 2; i++) {
            Iterator<Object> iterator = values.iterator();
            expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
            while (iterator.hasNext()) {
                expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
                expect(this.fetchingIterator.next()).andReturn(iterator.next());

                // hasNext() called a second time when fetched values are retained in memory
                if (i > 0) {
                    expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
                }
            }
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }

        // Run the test
        replayAll();

        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        Iterator<String> result1 = subject.iterator(); // Trigger a simulated fetch. By default, iterated values are not
        int result2 = 0; // retained in memory.
        for (; result1.hasNext(); result2++) {
            result1.next();
        }
        String result3 = subject.toString();

        subject.setKeepIteratedValuesInMemory(true); // Trigger a simulated fetch. However, allow iterated values to be
        Iterator<String> result4 = subject.iterator(); // retained in memory.
        int result5 = 0;
        for (; result4.hasNext(); result5++) {
            result4.next();
        }
        String result6 = subject.toString();

        Iterator<String> result7 = subject.iterator();
        int result8 = 0;
        for (; result7.hasNext(); result8++) {
            result7.next();
        }

        verifyAll();

        // Verify results
        assertTrue("The subject should have returned a non-null iterator", null != result1);

        assertEquals("Incorrect number of values fetched via the iterator", values.size(), result2);

        assertTrue("The subject, by default, should NOT have retained fetched values", result3.contains("unfetched"));

        assertTrue("The subject should have returned a non-null iterator", null != result4);

        assertEquals("Incorrect number of values fetched via the iterator", values.size(), result5);

        assertFalse("The subject, by setting the flag, should have retained fetched values", result6.contains("unfetched"));

        assertTrue("The subject should have returned a non-null iterator, but all fetching should have occurred using only the previous instance",
                        null != result7);

        assertEquals("Incorrect number of in-memory values obtained from the iterator", values.size(), result8);
    }

    @Test
    public void testIterator_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));

        // Set expectations
        for (int i = 0; i < 2; i++) {
            Iterator<Object> iterator = values.iterator();
            expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
            while (iterator.hasNext()) {
                expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
                expect(this.fetchingIterator.next()).andReturn(iterator.next());

                // hasNext() called a second time when fetched values are retained in memory
                if (i > 0) {
                    expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
                }
            }
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }

        // Run the test
        replayAll();

        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        Iterator<String> result1 = subject.iterator(); // Trigger a simulated fetch. By default, iterated values are not
        int result2 = 0; // retained in memory.
        for (; result1.hasNext(); result2++) {
            result1.next();
        }
        String result3 = subject.toString();

        subject.setKeepIteratedValuesInMemory(true); // Trigger a simulated fetch. However, allow iterated values to be
        Iterator<String> result4 = subject.iterator(); // retained in memory.
        int result5 = 0;
        for (; result4.hasNext(); result5++) {
            result4.next();
        }
        String result6 = subject.toString();

        Iterator<String> result7 = subject.iterator();
        int result8 = 0;
        for (; result7.hasNext(); result8++) {
            result7.next();
        }

        verifyAll();

        // Verify results
        assertTrue("The subject should have returned a non-null iterator", null != result1);

        assertEquals("Incorrect number of values fetched via the iterator", values.size(), result2);

        assertTrue("The subject, by default, should NOT have retained fetched values", result3.contains("unfetched"));

        assertTrue("The subject should have returned a non-null iterator", null != result4);

        assertEquals("Incorrect number of values fetched via the iterator", values.size(), result5);

        assertFalse("The subject, by setting the flag, should have retained fetched values", result6.contains("unfetched"));

        assertTrue("The subject should have returned a non-null iterator, but all fetching should have occurred using only the previous instance",
                        null != result7);

        assertEquals("Incorrect number of in-memory values obtained from the iterator", values.size(), result8);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testIterator_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testRemove_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.remove("value3");
        verifyAll();

        // Verify results
        assertTrue("The subject should have removed the fetched value", result1);
    }

    @Test
    public void testRemove_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.remove("value3");
        verifyAll();

        // Verify results
        assertTrue("The subject should have removed the fetched value", result1);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testRemove_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testRemoveAll_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.removeAll(Arrays.asList("value3", "value1"));
        verifyAll();

        // Verify results
        assertTrue("The subject should have removed the fetched values", result1);
    }

    @Test
    public void testRemoveAll_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.removeAll(Arrays.asList("value3", "value1"));
        verifyAll();

        // Verify results
        assertTrue("The subject should have removed the fetched values", result1);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testRemoveAll_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testRetainAll_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.retainAll(Arrays.asList("value3", "value1"));
        verifyAll();

        // Verify results
        assertTrue("The subject should have retained the fetched values", result1);
    }

    @Test
    public void testRetainAll_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        boolean result1 = subject.retainAll(Arrays.asList("value3", "value1"));
        verifyAll();

        // Verify results
        assertTrue("The subject should have retained the fetched values", result1);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testRetainAll_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testToArray_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        Object[] result1 = subject.toArray();
        Object[] result2 = subject.toArray(new Object[subject.size()]);
        verifyAll();

        // Verify results
        assertTrue("The subject should have returned a non-null array of fetched values", null != result1);

        assertTrue("The subject should have returned a non-null array of fetched values", null != result2);
    }

    @Test
    public void testToArray_HappyPath() throws Exception {
        // Create test input
        String fieldName = "HEAD";
        Collection<Object> values = new HashSet<Object>(Arrays.asList("value1", new StringBuilder("value2"), "value3"));
        Iterator<Object> iterator = values.iterator();

        // Set expectations
        expect(this.parentIterator.newLazyFetchingIterator(fieldName)).andReturn(this.fetchingIterator);
        while (iterator.hasNext()) {
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.fetchingIterator.next()).andReturn(iterator.next());
            expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());
        }
        expect(this.fetchingIterator.hasNext()).andReturn(iterator.hasNext());

        // Run the test
        replayAll();
        IndexOnlyLazyFetchingSet<String,Object> subject = new IndexOnlyLazyFetchingSet<>(fieldName, this.parentIterator);
        Object[] result1 = subject.toArray();
        Object[] result2 = subject.toArray(new Object[subject.size()]);
        verifyAll();

        // Verify results
        assertTrue("The subject should have returned a non-null array of fetched values", null != result1);

        assertTrue("The subject should have returned a non-null array of fetched values", null != result2);
    }

Replace Generic With Diamond HashSet<Object> with HashSet<> in method public testToArray_HappyPath() : void from class datawave.query.jexl.IndexOnlyLazyFetchingSetTest


    @Test
    public void testExtractNormalizedAttributes() {
        final Key metadata = new Key("shard", DATATYPE + "\0" + UID, "", new ColumnVisibility("U"), -1);

        String[][] testData = { {"FOO", "ABcd"}, {"abcd"}, {"FOO", "1234"}, {"1234"}, {"BAZ", "ABcd"}, {"ABcd"}, {"BAZ", "1234"}, {"+dE1.234"},
                {"BAR", "ABcd"}, {"abcd", "ABcd"}, {"BAR", "1234"}, {"1234", "+dE1.234"}};

        for (int i = 0; i < testData.length; i += 2) {
            String[] input = testData[i];
            String[] expected = testData[i + 1];
            Set<String> output = EventDataQueryExpressionVisitor.extractNormalizedAttributes(attrFactory, input[0], input[1], metadata);
            Set<String> missing = new TreeSet<>();
            for (String s : expected) {
                if (!output.remove(s)) {
                    missing.add(s);
                }
            }

            StringBuilder b = new StringBuilder();
            if (!output.isEmpty()) {
                b.append(" Unexpected entries found: " + output.toString());
            }
            if (!missing.isEmpty()) {
                b.append(" Expected entries that were not found: " + output.toString());
            }

            if (b.length() > 0) {
                fail("Output did not match expected output for '" + input[0] + ":" + input[1] + "';" + b.toString());
            }
        }
    }

    @Test
    public void testExtractNormalizedAttributes() {
        final Key metadata = new Key("shard", DATATYPE + "\0" + UID, "", new ColumnVisibility("U"), -1);

        String[][] testData = { {"FOO", "ABcd"}, {"abcd"}, {"FOO", "1234"}, {"1234"}, {"BAZ", "ABcd"}, {"ABcd"}, {"BAZ", "1234"}, {"+dE1.234"},
                {"BAR", "ABcd"}, {"abcd", "ABcd"}, {"BAR", "1234"}, {"1234", "+dE1.234"}};

        for (int i = 0; i < testData.length; i += 2) {
            String[] input = testData[i];
            String[] expected = testData[i + 1];
            Set<String> output = EventDataQueryExpressionVisitor.extractNormalizedAttributes(attrFactory, input[0], input[1], metadata);
            Set<String> missing = new TreeSet<String>();
            for (String s : expected) {
                if (!output.remove(s)) {
                    missing.add(s);
                }
            }

            StringBuilder b = new StringBuilder();
            if (!output.isEmpty()) {
                b.append(" Unexpected entries found: " + output.toString());
            }
            if (!missing.isEmpty()) {
                b.append(" Expected entries that were not found: " + output.toString());
            }

            if (b.length() > 0) {
                fail("Output did not match expected output for '" + input[0] + ":" + input[1] + "';" + b.toString());
            }
        }
    }

Replace Generic With Diamond TreeSet<String> with TreeSet<> in method public testExtractNormalizedAttributes() : void from class datawave.query.jexl.visitors.EventDataQueryExpressionVisitorTest


    @Test
    public void testExpandedFunctionQuery() throws Exception {
        Set<String> contentFields = new HashSet<>();
        contentFields.add("FOO");
        contentFields.add("BAR");

        helper.addTermFrequencyFields(contentFields);
        helper.setIndexedFields(contentFields);

        String originalQuery = "content:phrase(termOffsetMap, 'abc', 'def')";
        ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
        ASTJexlScript newScript = FunctionIndexQueryExpansionVisitor.expandFunctions(config, helper, helper2, script);
        String newQuery = JexlStringBuildingVisitor.buildQuery(newScript);
        // this is fragile, but captures what should be here.
        assertEquals("(content:phrase(termOffsetMap, 'abc', 'def') && ((BAR == 'def' && BAR == 'abc') || (FOO == 'def' && FOO == 'abc')))", newQuery);
    }

    @Test
    public void testExpandedFunctionQuery() throws Exception {
        Set<String> contentFields = new HashSet<String>();
        contentFields.add("FOO");
        contentFields.add("BAR");

        helper.addTermFrequencyFields(contentFields);
        helper.setIndexedFields(contentFields);

        String originalQuery = "content:phrase(termOffsetMap, 'abc', 'def')";
        ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
        ASTJexlScript newScript = FunctionIndexQueryExpansionVisitor.expandFunctions(config, helper, helper2, script);
        String newQuery = JexlStringBuildingVisitor.buildQuery(newScript);
        // this is fragile, but captures what should be here.
        assertEquals("(content:phrase(termOffsetMap, 'abc', 'def') && ((BAR == 'def' && BAR == 'abc') || (FOO == 'def' && FOO == 'abc')))", newQuery);
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public testExpandedFunctionQuery() : void from class datawave.query.jexl.visitors.EventDataQueryExpressionVisitorTest


    @Test
    public void testIncludeFilterExpansion() throws ParseException {
        parser = new JexlControlledQueryParser();
        Set<String> allowedFields = new HashSet<>();
        allowedFields.add("1337_1");
        allowedFields.add("9001_1");
        parser.setAllowedFields(allowedFields);

        Map<String,Set<String>> includedValMap = new HashMap<>();
        Set<String> includedValSet1 = new HashSet<>();
        includedValSet1.add("John");
        includedValSet1.add("Doe");
        includedValMap.put("$1337_1", includedValSet1);
        parser.setIncludedValues(includedValMap);

        String expandedQuery = parser.parse("$9001_1='dudududuu'").getOriginalQuery();
        // Note: Or clause is not order dependent and may flip between jvm impls / versions.
        Assert.assertTrue("($9001_1='dudududuu') && ((filter:includeRegex($1337_1, 'Doe') || filter:includeRegex($1337_1, 'John')))".equals(expandedQuery)
                        || "($9001_1='dudududuu') && ((filter:includeRegex($1337_1, 'John') || filter:includeRegex($1337_1, 'Doe')))".equals(expandedQuery));
    }

    @Test
    public void testIncludeFilterExpansion() throws ParseException {
        parser = new JexlControlledQueryParser();
        Set<String> allowedFields = new HashSet<>();
        allowedFields.add("1337_1");
        allowedFields.add("9001_1");
        parser.setAllowedFields(allowedFields);

        Map<String,Set<String>> includedValMap = new HashMap<String,Set<String>>();
        Set<String> includedValSet1 = new HashSet<>();
        includedValSet1.add("John");
        includedValSet1.add("Doe");
        includedValMap.put("$1337_1", includedValSet1);
        parser.setIncludedValues(includedValMap);

        String expandedQuery = parser.parse("$9001_1='dudududuu'").getOriginalQuery();
        // Note: Or clause is not order dependent and may flip between jvm impls / versions.
        Assert.assertTrue("($9001_1='dudududuu') && ((filter:includeRegex($1337_1, 'Doe') || filter:includeRegex($1337_1, 'John')))".equals(expandedQuery)
                        || "($9001_1='dudududuu') && ((filter:includeRegex($1337_1, 'John') || filter:includeRegex($1337_1, 'Doe')))".equals(expandedQuery));
    }

Replace Generic With Diamond HashMap<String,Set<String>> with HashMap<> in method public testIncludeFilterExpansion() : void from class datawave.query.language.parser.jexl.JexlControlledQueryParserTest