{"id":35109601,"url":"https://github.com/ezylang/evalex","last_synced_at":"2026-04-18T10:13:28.661Z","repository":{"id":5960495,"uuid":"7181768","full_name":"ezylang/EvalEx","owner":"ezylang","description":"EvalEx is a handy expression evaluator for Java, that allows to evaluate simple mathematical and boolean expressions.","archived":false,"fork":false,"pushed_at":"2026-01-26T21:47:35.000Z","size":873,"stargazers_count":1095,"open_issues_count":8,"forks_count":288,"subscribers_count":44,"default_branch":"main","last_synced_at":"2026-04-02T09:32:23.082Z","etag":null,"topics":["expression-evaluator","expression-parser","java"],"latest_commit_sha":null,"homepage":"https://ezylang.github.io/EvalEx/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ezylang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-12-15T17:08:00.000Z","updated_at":"2026-04-01T07:48:52.000Z","dependencies_parsed_at":"2022-07-16T03:00:30.290Z","dependency_job_id":"19174d89-b6bd-472a-98c8-8406fbca8b1a","html_url":"https://github.com/ezylang/EvalEx","commit_stats":{"total_commits":238,"total_committers":41,"mean_commits":5.804878048780488,"dds":0.5546218487394958,"last_synced_commit":"27d831adc4e658932656e6530d15fdb898095740"},"previous_names":["uklimaschewski/evalex"],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/ezylang/EvalEx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezylang%2FEvalEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezylang%2FEvalEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezylang%2FEvalEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezylang%2FEvalEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezylang","download_url":"https://codeload.github.com/ezylang/EvalEx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezylang%2FEvalEx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31964740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expression-evaluator","expression-parser","java"],"created_at":"2025-12-27T19:24:26.665Z","updated_at":"2026-04-18T10:13:28.655Z","avatar_url":"https://github.com/ezylang.png","language":"Java","readme":"EvalEx - Java Expression Evaluator\n==========\n\n[![Build](https://github.com/ezylang/EvalEx/actions/workflows/build.yml/badge.svg)](https://github.com/ezylang/EvalEx/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ezylang_EvalEx\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ezylang_EvalEx)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ezylang_EvalEx\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=ezylang_EvalEx)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=ezylang_EvalEx\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=ezylang_EvalEx)\n[![Maven Central](https://img.shields.io/maven-central/v/com.ezylang/EvalEx.svg?label=Maven%20Central)](https://search.maven.org/search?q=a:%22EvalEx%22)\n\n| For a complete documentation, see [the documentation site](https://ezylang.github.io/EvalEx/). |\n|------------------------------------------------------------------------------------------------|\n\nEvalEx is a handy expression evaluator for Java, that allows to parse and evaluate expression strings.\n\n## Key Features:\n\n- Supports numerical, boolean, string, date time, duration, array and structure expressions, operations and variables.\n- Array and structure support: Arrays and structures can be mixed, building arbitrary data\n  structures.\n- Supports the NULL datatype.\n- Uses BigDecimal for numerical calculations.\n- MathContext and number of decimal places can be configured, with optional automatic rounding.\n- No dependencies to external libraries.\n- Easy integration into existing systems to access data.\n- Predefined boolean and mathematical operators.\n- Predefined mathematical, boolean and string functions.\n- Custom functions and operators can be added.\n- Functions can be defined with a variable number of arguments (see MIN, MAX and SUM functions).\n- Supports hexadecimal and scientific notations of numbers.\n- Supports implicit multiplication, e.g. 2x, 2sin(x), (a+b)(a-b) or 2(x-y) which equals to (a+b)\\*(a-b) or 2\\*(\n  x-y)\n- Lazy evaluation of function parameters (see the IF function) and support of sub-expressions.\n- Requires minimum Java version 11.\n\n## Documentation\n\nThe full documentation for EvalEx can be found\non [GitHub Pages](https://ezylang.github.io/EvalEx/)\n\n## Discussion\n\nFor announcements, questions and ideas visit\nthe [Discussions area](https://github.com/ezylang/EvalEx/discussions).\n\n## Download / Including\n\nYou can download the binaries, source code and JavaDoc jars from\n[Maven Central](https://central.sonatype.com/artifact/com.ezylang/EvalEx).\\\nYou will find there also copy/paste templates for including EvalEx in your project with build\nsystems like Maven or Gradle.\n\n### Maven\n\nTo include it in your Maven project, add the dependency to your pom. For example:\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.ezylang\u003c/groupId\u003e\n      \u003cartifactId\u003eEvalEx\u003c/artifactId\u003e\n      \u003cversion\u003e3.6.1\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Gradle\n\nIf you're using gradle add the dependencies to your project's app build.gradle:\n\n```gradle\ndependencies {\n    compile 'com.ezylang:EvalEx:3.6.1'\n}\n```\n\n## Examples\n\n### A simple example, that shows how it works in general:\n\n```java\nExpression expression = new Expression(\"1 + 2 / (4 * SQRT(4))\");\n\nEvaluationValue result = expression.evaluate();\n\nSystem.out.println(result.getNumberValue()); // prints 1.25\n```\n\n### Variables can be specified in the expression and their values can be passed for evaluation:\n\n```java\nExpression expression = new Expression(\"(a + b) * (a - b)\");\n\nEvaluationValue result = expression\n    .with(\"a\", 3.5)\n    .and(\"b\", 2.5)\n    .evaluate();\n\nSystem.out.println(result.getNumberValue()); // prints 6.00\n```\n\n### Expression can be copied and evaluated with a different set of values:\n\nUsing a copy of the expression allows a thread-safe evaluation of that copy, without parsing the expression again.\nThe copy uses the same expression string, configuration and syntax tree.\nThe existing expression will be parsed to populate the syntax tree.\n\nMake sure each thread has its own copy of the original expression.\n```java\nExpression expression = new Expression(\"a + b\").with(\"a\", 1).and(\"b\", 2);\nExpression copiedExpression = expression.copy().with(\"a\", 3).and(\"b\", 4);\n\nEvaluationValue result = expression.evaluate();\nEvaluationValue copiedResult = copiedExpression.evaluate();\n\nSystem.out.println(result.getNumberValue()); // prints 3\nSystem.out.println(copiedResult.getNumberValue()); // prints 7\n```\n\n### Values can be passed in a map\n\nInstead of specifying the variable values one  by one, they can be set by defining a map with names and values and then\npassing it to the _withValues()_ method:\n\nThe data conversion of the passed values will automatically be performed through a customizable converter.\n\nIt is also possible to configure a custom data accessor to read and write values.\n\n```java\nExpression expression = new Expression(\"a+b+c\");\n\nMap\u003cString, Object\u003e values = new HashMap\u003c\u003e();\nvalues.put(\"a\", true);\nvalues.put(\"b\", \" : \");\nvalues.put(\"c\", 24.7);\n\nEvaluationValue result = expression.withValues(values).evaluate();\n\nSystem.out.println(result.getStringValue()); // prints \"true : 24.7\"\n```\n\nSee chapter [Data Types](https://ezylang.github.io/EvalEx/concepts/datatypes.html) for details on the conversion.\n\nAnother option to have EvalEx use your data is to define a custom data accessor.\n\nSee chapter [Data Access](https://ezylang.github.io/EvalEx/customization/data_access.html) for details.\n\n\n### Boolean expressions produce a boolean result:\n\n```java\nExpression expression = new Expression(\"level \u003e 2 || level \u003c= 0\");\n\nEvaluationValue result = expression\n    .with(\"level\", 3.5)\n    .evaluate();\n\nSystem.out.println(result.getBooleanValue()); // prints true\n```\n\n### Like in Java, strings and text can be mixed:\n\n```java\nExpression expression = new Expression(\"\\\"Hello \\\" + name + \\\", you are \\\" + age\")\n    .with(\"name\",\"Frank\")\n    .and(\"age\",38);\n\nSystem.out.println(expression.evaluate().getStringValue()); // prints Hello Frank, you are 38\n```\n\n### Arrays (also multidimensional) are supported and can be passed as Java _Lists_ or instances of Java arrays.\n\nSee the [Documentation](https://ezylang.github.io/EvalEx/concepts/datatypes.html#array)\nfor more details.\n\n```java\nExpression expression = new Expression(\"values[i-1] * factors[i-1]\");\n\nEvaluationValue result = expression\n    .with(\"values\", List.of(2, 3, 4))\n    .and(\"factors\", new Object[] {2, 4, 6})\n    .and(\"i\", 1)\n    .evaluate();\n\nSystem.out.println(result.getNumberValue()); // prints 4\n```\n\n### Structures are supported and can be passed as Java _Maps_.\n\nArrays and Structures can be combined to build arbitrary data structures. See\nthe [Documentation](https://ezylang.github.io/EvalEx/concepts/datatypes.html#structure)\nfor more details.\n\n```java\nMap\u003cString, Object\u003e order = new HashMap\u003c\u003e();\norder.put(\"id\", 12345);\norder.put(\"name\", \"Mary\");\n\nMap\u003cString, Object\u003e position = new HashMap\u003c\u003e();\nposition.put(\"article\", 3114);\nposition.put(\"amount\", 3);\nposition.put(\"price\", new BigDecimal(\"14.95\"));\n\norder.put(\"positions\", List.of(position));\n\nExpression expression = new Expression(\"order.positions[x].amount * order.positions[x].price\")\n    .with(\"order\", order)\n    .and(\"x\", 0);\n\nBigDecimal result = expression.evaluate().getNumberValue();\n\nSystem.out.println(result); // prints 44.85\n```\n\n### Calculating with date-time and duration\n\nDate-tme and duration values are supported. There are functions to create, parse and format these values.\nAdditionally, the plus and minus operators can be used to e.g. add or subtract durations, or to calculate the\ndifference between two dates:\n\n```java\nInstant start = Instant.parse(\"2023-12-05T11:20:00.00Z\");\nInstant end = Instant.parse(\"2023-12-04T23:15:30.00Z\");\n\nExpression expression = new Expression(\"start - end\");\nEvaluationValue result = expression\n        .with(\"start\", start)\n        .and(\"end\", end)\n        .evaluate();\nSystem.out.println(result); // will print \"EvaluationValue(value=PT12H4M30S, dataType=DURATION)\"\n```\nSee the [Documentation](https://ezylang.github.io/EvalEx/concepts/date_time_duration.html) for more details.\n\n## EvalEx-big-math\n\n[Big-math](https://github.com/eobermuhlner/big-math) is a library by Eric Obermühlner. It provides\nadvanced Java BigDecimal math functions using an arbitrary precision.\n\n[EvalEx-big-math](https://github.com/ezylang/EvalEx-big-math) adds the advanced math functions from\nbig-math to EvalEx.\n\n## Author and License\n\nCopyright 2012-2023 by Udo Klimaschewski\n\n**Thanks to all who contributed to this\nproject: [Contributors](https://github.com/ezylang/EvalEx/graphs/contributors)**\n\nThe software is licensed under the Apache License, Version 2.0 (\nsee [LICENSE](https://raw.githubusercontent.com/ezylang/EvalEx/main/LICENSE) file).\n\n* The *power of* operator (^) implementation was copied\n  from [Stack Overflow](http://stackoverflow.com/questions/3579779/how-to-do-a-fractional-power-on-bigdecimal-in-java)\n  Thanks to Gene Marin\n* The SQRT() function implementation was taken from the\n  book [The Java Programmers Guide To numerical Computing](http://www.amazon.de/Java-Number-Cruncher-Programmers-Numerical/dp/0130460419) (\n  Ronald Mak, 2002)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezylang%2Fevalex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezylang%2Fevalex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezylang%2Fevalex/lists"}