com.github.TKnudsen.ComplexDataObject.model.processors.complexDataObject.RemovingValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
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;
}
}