Git Product home page Git Product logo

antlr-test's Introduction

antlr-test

This example project demonstrates how to use ANTLR-based expression parser and how to filter collection of entries using SQL-like predicate.

List<Trade> trades = new ArrayList<>();
trades.add(new Trade("New", "Open", "42", "CLIENT42", "Option", 42.0, "EURUSD", 1.0, 11.0, 1.1, 2.1));
trades.add(new Trade("New", "Open", "43", "CLIENT42", "Option", 43.0, "EURUSD", 2.0, 12.0, 1.2, 2.2));
trades.add(new Trade("New", "Closed", "44", "CLIENT42", "Option", 44.0, "EURUSD", 3.0, 13.0, 1.3, 2.3));
trades.add(new Trade("New", "Closed", "45", "CLIENT42", "Option", 45.0, "EURUSD", 4.0, 14.0, 1.4, 2.4));
trades.add(new Trade("New", "Closed", "46", "CLIENT42", "Option", 46.0, "EURUSD", 5.0, 15.0, 1.5, 2.5));

trades.stream()
    .filter(TradeFilterFactory.parseExpression("spot >= 2.2 and (strike < 1.3 or strike > 1.4)"))
    .forEach(trade -> System.out.println("Trade " + trade.getTradeId()));

The result of this code execution will be:

Trade 43
Trade 46

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.