{"id":15044047,"url":"https://github.com/link-intersystems/lis-commons","last_synced_at":"2026-01-04T06:06:37.321Z","repository":{"id":25144826,"uuid":"28567154","full_name":"link-intersystems/lis-commons","owner":"link-intersystems","description":"Reusable Java components for library and framework developers based on pure Java.","archived":false,"fork":false,"pushed_at":"2024-05-22T05:03:43.000Z","size":15467,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T06:45:19.316Z","etag":null,"topics":["beans","events","extendible","java","java-11","library"],"latest_commit_sha":null,"homepage":"","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/link-intersystems.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}},"created_at":"2014-12-28T17:16:44.000Z","updated_at":"2024-04-21T18:36:28.000Z","dependencies_parsed_at":"2023-01-14T10:01:10.744Z","dependency_job_id":"d3de5a97-bed3-4903-afc4-84755ebe57cf","html_url":"https://github.com/link-intersystems/lis-commons","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-intersystems%2Flis-commons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-intersystems%2Flis-commons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-intersystems%2Flis-commons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-intersystems%2Flis-commons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/link-intersystems","download_url":"https://codeload.github.com/link-intersystems/lis-commons/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244099301,"owners_count":20397936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["beans","events","extendible","java","java-11","library"],"created_at":"2024-09-24T20:50:00.108Z","updated_at":"2026-01-04T06:06:37.259Z","avatar_url":"https://github.com/link-intersystems.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"lis-commons\r\n=============\r\n\r\n![Java CI with Maven](https://github.com/link-intersystems/lis-commons/workflows/Java%20CI%20with%20Maven/badge.svg) \r\n[![Coverage Status](https://coveralls.io/repos/github/link-intersystems/lis-commons/badge.svg?branch=master)](https://coveralls.io/github/link-intersystems/lis-commons?branch=master)\r\n[![Maven Central](https://img.shields.io/maven-central/v/com.link-intersystems.commons/lis-commons)](https://mvnrepository.com/artifact/com.link-intersystems.commons)\r\n\r\nA collection of reusable Java components for library and framework developers.\r\n\r\nIn order to make them as reusable as possible I try to minimize the dependencies the\r\nmodules have down to zero. I task hard to ensure that the libraries only depend on pure Java \r\nand also minimize the dependencies between the modules themselves.\r\n\r\nHere is an overview of the module dependencies:\r\n\r\n    lis-commons-util (0 deps)\r\n\r\n    lis-commons-jdbc (0 deps)\r\n\r\n    lis-commons-sql (0 deps)\r\n\r\n    lis-commons-sql-hibernate (1 deps)\r\n\r\n    lis-commons-net (0 deps)\r\n\r\n    lis-commons-events (0 deps)\r\n\r\n    lis-commons-graph (0 deps)\r\n\r\n    lis-commons-math (0 deps)\r\n\r\n    lis-commons-lang (0 dep)\r\n\r\n    lis-commons-test (1 deps)\r\n    +- org.junit.jupiter:junit-jupiter-api\r\n\r\n    lis-commons-beans (0 deps)\r\n\r\n    lis-commons-beans-record (1 deps)\r\n    +- lis-commons-beans\r\n\r\n    lis-commons-lang-criteria (3 deps)\r\n    +- lis-commons-lang\r\n    +- lis-commons-util\r\n    +- lis-commons-graph\r\n\r\n# Maven Dependencies\r\n\r\nYou can browse all libs and versions under [mvnrepository.com](https://mvnrepository.com/artifact/com.link-intersystems.commons)\r\nor in the [central maven repository](https://repo.maven.apache.org/maven2/com/link-intersystems/commons/).\r\n\r\nMaven project sites are available at [link-intersystems.github.io/lis-commons/](https://link-intersystems.github.io/lis-commons/)\r\n\r\n# lis-commons-beans\r\n\r\nProvides a more easy api to handle Java bean related issues. The lis-commons-beans is shipped with\r\nsupport for the Java beans specification, but can be extended to any kind of beans (like JPA beans).\r\n\r\n    BeansFactory factory = BeansFactory.getDefault();\r\n    Bean\u003cDefaultButtonModel\u003e buttonModelBean = factory.createBean(new DefaultButtonModel());\r\n\r\n    ChangeListener changeListener = ce -\u003e System.out.println(\"button model changed.\");\r\n    ActionListener actionListener = ae -\u003e System.out.println(\"action performed.\");\r\n  \r\n    buttonModelBean.addListener(changeListener);\r\n    buttonModelBean.addListener(actionListener);\r\n\r\n    DefaultButtonModel buttonModel = buttonModelBean.getBeanObject();\r\n\r\n    buttonModel.setPressed(true);\r\n    buttonModel.setArmed(true);\r\n    buttonModel.setPressed(false);\r\n\r\n    PropertyList properties = buttonModelBean.getProperties();\r\n    Property armedProperty = properties.getByName(\"armed\");\r\n    System.out.println(\"button model armed: \" + armedProperty.getValue());\r\n\r\nwill output\r\n\r\n    button model changed.\r\n    button model changed.\r\n    action performed.\r\n    button model changed.\r\n    button model armed: true\r\n\r\n# [lis-commons-beans-records](lis-commons-beans-records/README.md)\r\n\r\nBeans support for Java records.\r\n\r\n    public record PersonRecord(String firstname, String lastname) {}\r\n\r\n       \r\n    BeansFactory beansFactory = BeansFactory.getInstance(\"record\");\r\n    Bean\u003cPerson\u003e bean = beansFactory.createBean(new PersonRecord(\"René\", \"Link\"));\r\n    PropertyList properties = bean.getProperties();\r\n\r\n    assertEquals(\"René\", properties.getByName(\"firstname\").getValue());\r\n    assertEquals(\"Link\", properties.getByName(\"lastname\").getValue());\r\n\r\nDetails at [lis-commons-beans-records](lis-commons-beans-records/README.md).\r\n\r\n\r\n# lis-commons-jdbc\r\n\r\nProvides a convenient api to access the meta-data of a jdbc connection\r\n\r\n\r\n    Connection jdbcConnection = ...;\r\n    ConnectionMetaData metaData = new ConnectionMetaData(jdbcConnection);\r\n    \r\n    ForeignKeyList foreignKeys = metaData.getImportedKeys(\"film_actor\");\r\n    \r\n    ColumnMetaDataList filmActorColumns = metaData.getColumnMetaDataList(\"film_actor\");\r\n    ForeignKey foreignKey = foreignKeys.getByFkColumnDescription(filmActorColumns.getByName(\"actor_id\"));\r\n    assertNotNull(foreignKey);\r\n    assertEquals(\"fk_film_actor_actor\", foreignKey.getName());\r\n    \r\n    ColumnMetaDataList actorColumns = metaData.getColumnMetaDataList(\"actor\");\r\n    foreignKey = foreignKeys.getByPkColumnDescription(actorColumns.getByName(\"actor_id\"));\r\n    assertNotNull(foreignKey);\r\n    assertEquals(\"fk_film_actor_actor\", foreignKey.getName());\r\n\r\n# lis-commons-sql\r\n\r\nProvides support for sql related tasks like statement creation. This module provides\r\na simple support for creating sql statements. At the moment it only supports insert statements.\r\nIt is primarily made for the H2 dialect, but might also task for some other dialects. You\r\ncan extend the DefaultSqlDialect to adapt the module to your needs. If you do so please make\r\na pull request to let me integrate the dialect into this library.\r\n\r\n    SqlDialect sqlDialect = new DefaultSqlDialect();\r\n    \r\n    InsertSql insertSql = sqlDialect.createInsertSql(\"actor\");\r\n    \r\n    LiteralFormat idFormat = sqlDialect.getLiteralFormat(Types.BIGINT);\r\n    insertSql.addColumn(\"id\", idFormat.format(1L));\r\n    \r\n    LiteralFormat firstNameFormat = sqlDialect.getLiteralFormat(Types.VARCHAR);\r\n    insertSql.addColumn(\"first_name\", firstNameFormat.format(\"PENELOPE\"));\r\n    \r\n    LiteralFormat lastNameFormat = sqlDialect.getLiteralFormat(Types.VARCHAR);\r\n    insertSql.addColumn(\"last_name\", lastNameFormat.format(\"GUINESS\"));\r\n    \r\n    LiteralFormat lastUpdateFormat = sqlDialect.getLiteralFormat(Types.TIMESTAMP);\r\n    insertSql.addColumn(\"last_update\", lastUpdateFormat.format(new Date(106, 1, 15, 4, 34, 33)));\r\n    \r\n    String sql = insertSql.toSqlString();\r\n    assertEquals(\"insert into actor (id, first_name, last_name, last_update) values (1, 'PENELOPE', 'GUINESS', '2006-02-15 04:34:33')\", sql);\r\n\r\n\u003e If you want support for more dialects you might want to take a look at the `lis-commons-sql-hibernate`\r\nmodule that uses hibernates capabilities.\r\n\r\n    H2Dialect dialect = new H2Dialect();\r\n    SqlDialect sqlDialect = new HibernateSqlDialect(dialect);\r\n    \r\n    InsertSql insertSql = sqlDialect.createInsertSql(\"actor\");\r\n    // ...\r\n\r\n# [lis-commons-events](lis-commons-events/README.md)\r\n\r\nProvides support for Java event handling, e.g. it provides easy listener adapter creation using method references.\r\n\r\n    ListSelectionListener selectionListener = ListSelectionEventMethod.VALUE_CHANGED.listener(this::printEventFired);\r\n\r\n    private void printEventFired(ListSelectionEvent e) {\r\n        int firstIndex = e.getFirstIndex();\r\n        int lastIndex = e.getLastIndex();\r\n        boolean isAdjusting = e.getValueIsAdjusting();\r\n        System.out.println(\"Selection model event fired:\" +\r\n                            \" firstIndex= \" + firstIndex +\r\n                            \" lastIndex= \" + lastIndex +\r\n                            \" isAdjusting= \" + isAdjusting);\r\n    }\r\n\r\n    ListSelectionModel selectionModel = new DefaultListSelectionModel();\r\n    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r\n    selectionModel.addListSelectionListener(selectionListener);\r\n\r\n    selectionModel.setSelection(3); // fires the selection event and it is delegates to \r\n                                    // the method reference this::printEventFired\r\n\r\n\r\n# lis-commons-test-db\r\nThe lis-commons-test-db library provides support for setting up test databases\r\nand also includes the sakila sample databases that is ready to use.\r\n\r\n## Sakila Sample Database\r\n\r\nThe sakila sample database is provided by oracle's mysql database\r\nand published under the [BSD license](https://en.wikipedia.org/wiki/BSD_licenses).\r\n\r\nFor details take a look at [lis-commons-test-db](lis-commons-test-db/README.md)\r\n\r\n    @ExtendWith(SakilaTestDBExtension.class)\r\n    class DatabaseTest { \r\n        @Test\r\n        void selectSakilaDatabase(Connection connection) {\r\n            try (Statement stmt = connection.createStatement()) {\r\n                if (stmt.execute(\"select * from actor where actor_id = 1\")) {\r\n                    ResultSet rs = stmt.getResultSet();\r\n    \r\n                    assertTrue(rs.next(), \"result set should not be empty\");\r\n    \r\n                    assertEquals(1L, rs.getLong(\"actor_id\"), \"actor_id\");\r\n                    assertEquals(\"PENELOPE\", rs.getString(\"first_name\"), \"first_name\");\r\n                    assertEquals(\"GUINESS\", rs.getString(\"last_name\"), \"last_name\");\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n# lis-commons-net\r\n\r\nNetworking tools based on pure Java.\r\n\r\n    JavaHttpRequestFactory requestFactory = new JavaHttpRequestFactory();\r\n    requestFactory.setConnectTimeout(Duration.of(5, ChronoUnit.SECONDS));\r\n    requestFactory.setReadTimeout(Duration.of(10, ChronoUnit.SECONDS));\r\n\r\n    // GET google.com\r\n    HttpRequest httpRequest = requestFactory.get(new URL(\"https://www.google.com\"));\r\n    httpRequest.addHeader(\"Accept\", \"text/html\");\r\n    HttpResponse httpResponse = httpRequest.prepare().close();\r\n    System.out.println(httpResponse.getContentAsString(StandardCharsets.UTF_8));\r\n\r\n    HttpRequest httpRequest = requestFactory.post(new URL(\"http://localhost:8080));\r\n    PreparedRequest preparedRequest = httpRequest.prepare();\r\n    OutputStream postOut = preparedRequest.getOutputStream()\r\n    postOut.write(\"Hello World\".getBytes(StandardCharsets.UTF_8));\r\n    HttpResponse httpResponse = preparedRequest.close();\r\n    System.out.println(httpResponse.getResponseCode());\r\n\r\n# lis-commons-util\r\n\r\nProvides utility classes that I sometimes miss in standard Java. The library started when Java 1.8 was the current version.\r\nNowadays, some utility classes might already be supported by the Java version you use.\r\n\r\n# lis-commons-math\r\n\r\nA library that contains utility classes for simple common math issues like aggregating values or working with linear\r\nfunctions. This library is not expected to be a sophisticated math library. It is only for simple use cases when high\r\naccuracy is not an issue.\r\n\r\nIt contains support for simple linear equations.\r\n\r\n    // E.g. when you want to calculate the progress of operations\r\n    // you map one coordinate (the tasks) into another coordinate (the progress).\r\n    // The following example shows how to provide progress in values of\r\n    // 0 to 100 for 25 tasks.\r\n\r\n    TwoPointLinearEquation linearEquation1 = new TwoPointLinearEquation(50, 100);\r\n\r\n    double y = linearEquation1.fX(5); // 5 tasks are 10%\r\n    System.out.println(y);\r\n\r\nThere is also support for aggregate functions. E.g. the BigIncrementalAverage\r\ncan be used when you have to constantly calculate the average of a values, because\r\nit applies the next value to the previous average value. Can be useful for\r\ntime measurements of service calls, etc.\r\n\r\n    Average\u003cBigDecimal\u003e average = new BigIncrementalAverage();\r\n\r\n    Random r = new Random();\r\n    int samples = 10000000;\r\n  \r\n    while(samples-- \u003e 0){\r\n        average.addValue(r.nextInt(100));\r\n    }\r\n  \r\n    System.out.println(average.getValue());\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-intersystems%2Flis-commons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flink-intersystems%2Flis-commons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-intersystems%2Flis-commons/lists"}