Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:12:21+00:00 2026-05-26T08:12:21+00:00

I am working on a data loader, implemented using Spring Batch i.e. reading multiple

  • 0

I am working on a data loader, implemented using Spring Batch i.e. reading multiple flat files, processing and writing the list of pojo at commit interval of 1000 to database.
Each line read from file is converted to a pojo object containing property that needs to be set on the outcome of processing.

I have a lookup table that contains three columns with 180 rows. I keep each column values in a separate lists and iterate the list in a predicate to match with the each POJO item property.if a match is found in all the lists , then a property will be set.The following is the predicates i use,

public class LogicProcessor<I, O> implements ItemProcessor<I, O> {

    private Map[] params ;

    public void setParams( Map[] params )
    {
        this.params = params;
    }

    public O process(I item) throws Exception 
    {
        System.out.println(params  );

        List container      =  (List) params[1].get("SRVC");
        final List callInd      =  (List) container.get(0);
        final List totaltype        =  (List) container.get(1);
        final List servicetype  =   (List) container.get(2);

        Predicate<I> callIndipredicate = new Predicate<I>() {
            public boolean apply(I input) 
            {
                boolean flag=false;
                for (int i=0;i<callInd.size();i++)
                {
                    if ( "*".equals(callInd.get(i)))
                    {
                        flag= true;
                        break;
                    } else
                    {
                        try 
                        {
                            if (BeanUtils.getProperty(input,"CALLINDICATOR").equals(callInd.get(i)))
                            {
                                flag = true;
                                break;
                            } else
                            {
                                flag= false;
                                break;
                            }
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        } catch (InvocationTargetException e) {
                            e.printStackTrace();
                        } catch (NoSuchMethodException e) {
                            e.printStackTrace();
                        }

                    }
                }
                return flag;
            }
        };

        Predicate<I> totaltyppredicate = new Predicate<I>() {
            public boolean apply(I input) 
            {
                boolean flag=false;
                for (int i=0;i<totaltype.size();i++)
                {
                    try 
                    {
                        if (BeanUtils.getProperty(input,"TOTALTYPE").equals(totaltype.get(i)))
                        {
                            flag = true;
                            break;
                        } else
                        {
                            flag= false;
                            break;
                        }
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    }
                }
                return flag; 
            }
        };

        Predicate<I>srvctypepredicate = new Predicate<I>() {
            public boolean apply(I input) 
            {
                boolean flag=false;
                for (int i=0;i<servicetype.size();i++)
                {
                    try 
                    {
                        if (BeanUtils.getProperty(input,"SERVICETYPE").equals(servicetype.get(i)))
                        {
                            flag = true;
                            break;
                        } else
                        {
                            flag= false;
                            break;
                        }
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    }
                }
                return flag;                
            }
        };

        Predicate<I> isFound = Predicates.and(callIndipredicate,totaltyppredicate,srvctypepredicate);
        int preorPost=  Iterables.indexOf(Arrays.asList(item), isFound) ;
        System.out.println(preorPost);
        if (preorPost >=0)
        {
            BeanUtils.setProperty(item, "PREPOST", '0');
        } else
        {
            BeanUtils.setProperty(item, "PREPOST", 'X');
        }
        return (O) item;
    }

}

Is there a better way to filter the items and modify using guava.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:12:22+00:00Added an answer on May 26, 2026 at 8:12 am

    Guava: Use Iterables.find with a Predicate that does the DB lookup. Apply transform to the result with a Function.

    Commons: Use a FilterListIterator (or FilterIterator) combined with a Predicate, then a TransformIterator with a Transformer.

    Don’t know about LambdaJ.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with the spring batch data loader . I have 15000 files
I'm working on a google maps loader (using the google maps javascript API). I
I'm working on creating a grouped table view. The data is being loaded alright,
The following is the data I am working on: __DATA__ Node 1: 98 debug
I always seem to use Get when working with data (strongly typed or otherwise)
I'm working through the Data Binding chapter in Pro WPF in C# 2008. They
I'm working on a Data Warehouse which, in the end, will require me to
I'm working on a data warehouse project and would like to know how to
I'm working on a data distribution application which receives data from a source and
I'm working with XML data from an application where we get XML like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.