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

com.github.TKnudsen.ComplexDataObject.model.processors.complexDataObject.NullAttributeValueObjectRemover 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.ArrayList;
import java.util.Iterator;
import java.util.List;

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

/**
 * 

* Title: NullAttributeValueObjectRemover *

* *

* Description: Removes ComplexDataObjects with null values for a given * Attribute. *

* *

* Copyright: Copyright (c) 2016 *

* * @author Juergen Bernard * @version 1.02 */ public class NullAttributeValueObjectRemover implements IComplexDataObjectProcessor { private String attribute; public NullAttributeValueObjectRemover(String attribute) { this.attribute = attribute; } @Override public void process(ComplexDataContainer container) { if (attribute == null) return; List removes = new ArrayList<>(); for (Iterator iterator = container.iterator(); iterator.hasNext();) { ComplexDataObject complexDataObject = iterator.next(); Object value = complexDataObject.getAttribute(attribute); if (value == null) removes.add(complexDataObject); } for (ComplexDataObject complexDataObject : removes) container.remove(complexDataObject); } @Override public void process(List data) { ComplexDataContainer container = new ComplexDataContainer(data); process(container); } public String getAttribute() { return attribute; } public void setAttribute(String attribute) { this.attribute = attribute; } @Override public DataProcessingCategory getPreprocessingCategory() { return DataProcessingCategory.DATA_CLEANING; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy