All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.TKnudsen.ComplexDataObject.model.processors.complexDataObject.RemovingValues Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

There is a newer version: 0.2.13
Show newest version
package com.github.TKnudsen.ComplexDataObject.model.processors.complexDataObject;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.github.TKnudsen.ComplexDataObject.data.complexDataObject.ComplexDataContainer;
import com.github.TKnudsen.ComplexDataObject.data.complexDataObject.ComplexDataObject;

/**
 * Used to delete a given list of (extreme) values from each
 * {@link ComplexDataObject} in the {@link ComplexDataContainer}.
 * 
 * @author Robert Heimbach
 *
 * @param 
 */
public class RemovingValues implements IComplexDataObjectProcessor {

	private String attribute;
	private Set valuesToRemove;

	public RemovingValues(String attribute, List valuesToRemove) {
		this.attribute = attribute;
		this.valuesToRemove = new HashSet(valuesToRemove);
	}

	@Override
	public void process(ComplexDataContainer container) {
		for (ComplexDataObject complexDataObject : container)
			process(Arrays.asList(complexDataObject));
	}

	@Override
	public void process(List data) {
		for (ComplexDataObject complexDataObject : data) {

			Object value = complexDataObject.getAttribute(attribute);

			if (value != null && valuesToRemove.contains(value)) {

				complexDataObject.removeAttribute(attribute);
			}
		}
	}

	@Override
	public DataProcessingCategory getPreprocessingCategory() {
		return DataProcessingCategory.DATA_CLEANING;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy