{"id":18370746,"url":"https://github.com/miho/vcollections","last_synced_at":"2025-04-06T19:31:47.373Z","repository":{"id":137158725,"uuid":"78957602","full_name":"miho/VCollections","owner":"miho","description":"Lightweight observable collections (used by VMF and VRL)","archived":false,"fork":false,"pushed_at":"2021-09-03T16:43:54.000Z","size":285,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T04:51:18.327Z","etag":null,"topics":["java","observable","observable-collections","vmf","vrl"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-01-14T18:14:31.000Z","updated_at":"2024-12-09T07:13:07.000Z","dependencies_parsed_at":"2023-06-03T00:45:36.415Z","dependency_job_id":null,"html_url":"https://github.com/miho/VCollections","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miho%2FVCollections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miho%2FVCollections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miho%2FVCollections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miho%2FVCollections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miho","download_url":"https://codeload.github.com/miho/VCollections/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247539066,"owners_count":20955233,"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":["java","observable","observable-collections","vmf","vrl"],"created_at":"2024-11-05T23:40:10.933Z","updated_at":"2025-04-06T19:31:47.363Z","avatar_url":"https://github.com/miho.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VCollections\n[![Build Status](https://travis-ci.org/miho/VCollections.svg?branch=master)](https://travis-ci.org/miho/VCollections) [![Javadocs](https://www.javadoc.io/badge/eu.mihosoft.vcollections/vcollections.svg?color=blue)](https://www.javadoc.io/doc/eu.mihosoft.vcollections/vcollections)\n\u003ca href=\"https://foojay.io/today/works-with-openjdk\"\u003e\n   \u003cimg align=\"right\" \n        src=\"https://github.com/foojayio/badges/raw/main/works_with_openjdk/Works-with-OpenJDK.png\"   \n        width=\"100\"\u003e\n\u003c/a\u003e\n\n\u003cbr\u003e\n\n\nLightweight observable collections (used by VMF and [VRL](http://vrl-studio.mihosoft.eu)).\n\n## Features\n- Observable List\n- Mapped List (keeps two lists with different element types in sync)\n- coming sooner or later: ObservableMap and ObservableSet\n\n## Code Sample\n\n### Observing Changes\n\n```java\npublic class Main {\n    public static void main(String[] args) {\n        // creates an ordinary list\n        List\u003cInteger\u003e list = new ArrayList\u003c\u003e();\n\n        // to make the list observable, we wrap it in a VList\n        VList\u003cInteger\u003e vList = VList.newInstance(list);\n\n        // to get notified, we add a change listener to the VList\n        Subscription subscription = vList.addChangeListener((evt) -\u003e {\n            // for now, we just print the changes\n            System.out.println(EventUtil.toStringWithDetails(evt));\n        });\n\n        // add individual elements (generates 3 events)\n        System.out.println(\"\u003e\u003e add 3 individual elements\");\n        vList.add(1);\n        vList.add(2);\n        vList.add(3);\n\n        // add collection of elements (generates only one event)\n        System.out.println(\"\u003e\u003e add one collection of elements\");\n        vList.addAll(Arrays.asList(4, 5, 6));\n\n        // remove individual elements (generates 3 events)\n        System.out.println(\"\u003e\u003e remove 3 individual elements\");\n        vList.remove((Integer) 1);\n        vList.remove((Integer) 2);\n        vList.remove((Integer) 3);\n\n        // remove collection of elements (generates only one event)\n        System.out.println(\"\u003e\u003e remove one collection of elements\");\n        vList.removeAll(Arrays.asList(4,5,6));\n        \n        // unsubscribe the listener from vList\n        subscription.unsubscribe();\n        \n        // add elements without generating events\n        System.out.println(\"\u003e\u003e add one collection of elements without notification\");\n        vList.addAll(Arrays.asList(4, 5, 6));\n    }\n}\n```\n\n### Observing Unmodifiable Lists\n\n```java\npublic class Main {\n    public static void main(String[] args) {\n        // creates an ordinary list\n        List\u003cInteger\u003e list = new ArrayList\u003c\u003e();\n\n        // to make the list observable, we wrap it in a VList\n        VList\u003cInteger\u003e vList = VList.newInstance(list);\n        \n        // How to make the list unmodifiable and still listen to changes?\n        // THIS DOES NOT WORK: VList.newInstance(Collections.unmodifiableList(list));\n        VList\u003cInteger\u003e vListUnmodifiable = vList.asUnmodifiable();\n\n        // to get notified, we add a change listener to the unmodifiable VList\n        Subscription subscription = vListUnmodifiable.addChangeListener((evt) -\u003e {\n            // for now, we just print the changes\n            System.out.println(EventUtil.toStringWithDetails(evt));\n        });\n\n        // add element and generate event\n        vList.add(1);\n\n        // modifying the unmodifiable list results in RuntimeException...\n        vListUnmodifiable.add(37);\n        \n    }\n}\n```\n\n## How to Build VCollections\n\n### Requirements\n\n- Java \u003e= 1.8\n- Internet connection (dependencies are downloaded automatically)\n- IDE: [Gradle](http://www.gradle.org/) Plugin (not necessary for command line usage)\n\n### IDE\n\nOpen the `VCollections` [Gradle](http://www.gradle.org/) project in your favourite IDE (tested with NetBeans 8.2) and build it\nby calling the `assemble` task.\n\n### Command Line\n\nNavigate to the [Gradle](http://www.gradle.org/) project (e.g., `path/to/VCollections`) and enter the following command\n\n#### Bash (Linux/OS X/Cygwin/other Unix-like shell)\n\n    bash gradlew assemble\n    \n#### Windows (CMD)\n\n    gradlew assemble\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiho%2Fvcollections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiho%2Fvcollections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiho%2Fvcollections/lists"}