com.u2apple.rt.filter.ExcludeFilter.java Source code

Java tutorial

Introduction

Here is the source code for com.u2apple.rt.filter.ExcludeFilter.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.u2apple.rt.filter;

import com.u2apple.rt.model.AndroidDeviceRanking;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

/**
 *
 * @author Adam
 */
public class ExcludeFilter implements Filter {

    @Override
    public List<AndroidDeviceRanking> filter(List<AndroidDeviceRanking> androidDevices) {
        List<AndroidDeviceRanking> newDevices = new ArrayList<>();
        if (androidDevices != null && !androidDevices.isEmpty()) {
            for (AndroidDeviceRanking device : androidDevices) {
                if (!StringUtils.equalsIgnoreCase(device.getRoProductBrand(), device.getRoProductModel())
                        && StringUtils.isNotBlank(device.getRoProductModel())) {
                    newDevices.add(device);
                }
            }
        }
        return newDevices;
    }

}