{"id":18051606,"url":"https://github.com/kenta-shimizu/property","last_synced_at":"2025-04-05T07:12:47.893Z","repository":{"id":85174193,"uuid":"451055096","full_name":"kenta-shimizu/property","owner":"kenta-shimizu","description":"Like JavaFX Property. Includes Getter/Setter/Observer, Number/Comparative/Logical compution and blocking methods to wait until condition is true.","archived":false,"fork":false,"pushed_at":"2024-05-08T16:03:27.000Z","size":1499,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-10T14:52:53.787Z","etag":null,"topics":["beans","java","java8","javafx","property"],"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/kenta-shimizu.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":"2022-01-23T09:16:14.000Z","updated_at":"2024-01-12T18:26:28.000Z","dependencies_parsed_at":"2024-10-30T22:51:19.945Z","dependency_job_id":"ce5cccd8-612d-4cc0-8092-ec9b99b855aa","html_url":"https://github.com/kenta-shimizu/property","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenta-shimizu%2Fproperty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenta-shimizu%2Fproperty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenta-shimizu%2Fproperty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenta-shimizu%2Fproperty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenta-shimizu","download_url":"https://codeload.github.com/kenta-shimizu/property/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299850,"owners_count":20916193,"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","java","java8","javafx","property"],"created_at":"2024-10-30T22:51:06.746Z","updated_at":"2025-04-05T07:12:47.876Z","avatar_url":"https://github.com/kenta-shimizu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# property\n\nThis library is similar to JavaFX \"javafx.beans.property\".  \nIncludes Setter/Getter/Observer, Number/Comparative/Logical compution and blocking methods to wait until condition is true.  \nRequires Java8 or later.\n\n[Javadoc](https://kenta-shimizu.github.io/property/index.html)\n\n## Build new instance\n\n```java\n/* Primitive */\nIntegerProperty intProp    = IntegerProperty.newInstsance(0);\nLongProperty    longProp   = LongProperty.newInstance(0L);\nFloatProperty   floatProp  = FloatProperty.newInstance(0.0F);\nDoubleProperty  doubleProp = DoubleProperty.newInstance(0.0D);\nBooleanProperty boolProp   = BooleanProperty.newInstance(false);\n\n/* Object */\nObjectProperty\u003cString\u003e objProp = ObjectProperty.newInstance(null);\n\n/* String */\nStringProperty strProp = StringProperty.newInstance(\"string\");\n\n/* Collection */\nListProperty\u003cString\u003e listProp = ListProperty.newInstance();\nSetProperty\u003cInteger\u003e setProp  = SetProperty.newInstance();\nMapProperty\u003cString, Integer\u003e mapProp = MapProperty.newInstance();\n```\n\nSee also  \n[\"/examples/example/IntegerPropertyExample.java\"](/examples/example/IntegerPropertyExample.java)  \n[\"/examples/example/BooleanPropertyExample.java\"](/examples/example/BooleanPropertyExample.java)  \n[\"/examples/example/ObjectPropertyExample.java\"](/examples/example/ObjectPropertyExample.java)  \n[\"/examples/example/StringPropertyExample.java\"](/examples/example/StringPropertyExample.java)  \n[\"/examples/example/ListPropertyExample.java\"](/examples/example/ListPropertyExample.java)  \n[\"/examples/example/SetPropertyExample.java\"](/examples/example/SetPropertyExample.java)  \n[\"/examples/example/MapPropertyExample.java\"](/examples/example/MapPropertyExample.java)  \n\n## Set value\n\n```java\n/* Primitive */\nintProp.set(10);\nlongProp.set(20L);\nfloatProp.set(30.0F);\ndoubleProp.set(40.0D);\nboolProp.set(true);\n\n/* Object */\nobjProp.set(\"STRING\");\nobjProp.set(null);\n\n/* String */\nstrProp.set(\"STRING\");\n\n/* Collection */\n/* ListProperty\u003cE\u003e implements 'java.util.List\u003cE\u003e' */\nlistProp.add(\"STRING\");\n\n/* SetProperty\u003cE\u003e implements 'java.util.Set\u003cE\u003e' */\nsetProp.add(Integer.valurOf(1));\n\n/* MapProperty\u003cK, V\u003e implements 'java.util.Map\u003cK, V\u003e' */\nmapProp.put(\"KEY\", Integer.valurOf(1));\n```\n\n## Get value\n\n```java\n/* Primitive */\nint i     = intProp.intValue();\nlong l    = longProp.longValue();\nfloat f   = floatProp.floatValue();\ndouble d  = doubleProp.doubleValue();\nboolean b = boolProp.booleanValue();\n\n/* Object */\nString o = objProp.get();\n\n/* String */\nString s = strProp.toString();\n\n/* Collection */\n/* ListProperty\u003cE\u003e implements 'java.util.List\u003cE\u003e' */\nString e = listProp.get(0);\n\n/* SetProperty\u003cE\u003e implements 'java.util.Set\u003cE\u003e' */\nint size = setProp.size();\n\n/* MapProperty\u003cK, V\u003e implements 'java.util.Map\u003cK, V\u003e' */\nInteger v = mapProp.get(\"STRING\");\n```\n\n## Compution\n\n### Number Compution\n\n`NumberProperty` can compute `#add(+)`, `#negate(-)`, `#subtract(-)`, `#multiply(*)`, `#sum`, `#max`, `#min`.  \n`NumberCompution` can also compute.\n\n```java\n/* build instance */\nIntegerProperty a = IntegerProperty.newInstance(1);\nIntegerProperty b = IntegerProperty.newInstance(2);\nIntegerProperty c = IntegerProperty.newInstance(3);\n\nNumberCompution addA2 = a.add(2);       /* a + 2 */\nSystem.out.println(addA2.intValue());   /* \"3\"   */\n\nNumberCompution addBC = b.add(c);       /* b + c */\nSystem.out.println(addBC.intValue());   /* \"5\"   */\n\nNumberCompution mulBC = b.multiply(c);  /* b * c */\nSystem.out.println(mulBC.intValue());   /* \"6\"   */\n\nNumberCompution negateA = a.negate();   /* -a    */\nSystem.out.println(negateA);            /* \"-1\"  */\n\nNumberCompution sumABC = NumberCompution.sum(a, b, c);\nSystem.out.println(sumABC.intValue());  /* \"6\" */\n\nNumberCompution maxABC = NumberCompution.max(a, b, c);\nSystem.out.println(maxABC.intValue());  /* \"3\" */\n\nNumberCompution minABC = NumberCompution.min(a, b, c);\nSystem.out.println(minABC.intValue());  /* \"1\" */\n\na.set(4);   /* a change to 4 */\n\n/* NumberCompution change automatically */\nSystem.out.println(sumABC.intValue());  /* \"9\" */\nSystem.out.println(maxABC.intValue());  /* \"4\" */\nSystem.out.println(minABC.intValue());  /* \"2\" */\n```\n\nSee also [\"/examples/example/NumberComputionExample.java\"](/examples/example/NumberComputionExample.java)\n\n### Comparative Compution\n\n`NumberProperty` can compute `#computeIsEqualTo(==)`, `#computeIsNotEqualTo(!=)`, `#computeIsLessThan(\u003c)`, `#computeIsLessThanOrEqualTo(\u003c=)`, `#computeIsGreaterThan(\u003e)`, `#computeIsGreaterThanOrEqualTo(\u003e=)`.  \n`NumberCompution` can also compute.\n\n```java\n/* build instance */\nIntegerProperty a = IntegerProperty.newInstance(3);\nIntegerProperty b = IntegerProperty.newInstance(4);\n\nBooleanCompution aGT3 = a.computeIsGreaterThan(3);\nSystem.out.println(aGT3.booleanValue());  /* a \u003e  3, \"false\" */\n\nBooleanCompution aEQ5 = a.computeIsEqualTo(5);\nSystem.out.println(aEQ5.booleanValue());  /* a == 5, \"false\" */\n\nBooleanCompution aLTb = a.computeIsLessThan(b);\nSystem.out.println(aLTb.booleanValue());  /* a \u003c  b, \"true\"  */\n\na.set(5);  /* a change to 5 */\n\n/* ComparaiveCompution change automatically */\nSystem.out.println(aGT3.booleanValue());  /* a \u003e  3, \"true\"  */\nSystem.out.println(aEQ5.booleanValue());  /* a == 5, \"true\"  */\nSystem.out.println(aLTb.booleanValue());  /* a \u003c  b, \"false\" */\n```\n\nSee also [\"/examples/example/ComparativeComputionExample.java\"](/examples/example/ComparativeComputionExample.java)\n\n### Logical Compution\n\n`BooleanProperty` can compute `#and(\u0026\u0026)`, `#or(||)`, `#not(!)`, `#xor(^)`, `#nand`, `#nor`.  \n`BooleanCompution` can also compute.\n\n```java\n/* build instance */\nBooleanProperty a = BooleanProperty.newInstance(false);\nBooleanProperty b = BooleanProperty.newInstance(true);\n\nBooleanCompution and = a.and(b);         /* a \u0026\u0026 b  */\nSystem.out.println(and.booleanValue());  /* \"false\" */\n\nBooleanCompution or = a.or(b);           /* a || b  */\nSystem.out.println(or.booleanValue());   /* \"true\"  */\n\nBooleanCompution not = a.not();          /* ! a     */\nSystem.out.println(not.booleanValue());  /* \"true\"  */\n\nBooleanCompution xor = a.xor(b);         /* a ^ b   */\nSystem.out.println(xor.booleanValue());  /* \"true\"  */\n\na.set(true);  /* a change to true */\n\n/* LogicalCompution change automatically */\nSystem.out.println(and.booleanValue());  /* \"true\"  */\nSystem.out.println(or.booleanValue());   /* \"true\"  */\nSystem.out.println(not.booleanValue());  /* \"false\" */\nSystem.out.println(xor.booleanValue());  /* \"false\" */\n```\n\nSee also [\"/examples/example/LogicalComputionExample.java\"](/examples/example/LogicalComputionExample.java)\n\n### Others\n\n```java\n/* Object */\nObjectProperty\u003cString\u003e objProp = ObjectProperty.newInstance(\"STRING\");\n\nBooleanCompution isNullCompution  = objProp.computeIsNull();\nBooleanCompution notNullCompution = objProp.computeIsNotNull();\nBooleanCompution equalCompution   = objProp.computeIsEqualTo(\"STRING\");\n\n/* String */\nStringProperty a = StringProperty.newInstance(\"A\");\nStringProperty b = StringProperty.newInstance(\"B\");\nStringProperty c = StringProperty.newInstance(\"C\");\n\nStringCompution joinCompution = StringCompution.join(\",\", a, b, c);\n\nStringCompution trimCompution        = a.computeTrim();\nStringCompution toLowerCaseCompution = a.computeToLowerCase();\nStringCompution toUpperCaseCompution = a.computeToUpperCase();\nBooleanCompution isEmptyCompution    = a.computeIsEmpty();\nBooleanCompution containsCompution   = a.computeContains(\"A\");\nIntegerCompution lengthCompution     = a.computeLength();\n\n/* List */\nListProperty\u003cString\u003e listProp = ListProperty.newInstance();\n\nBooleanCompution isEmptyCompution  = listProp.computeIsEmpty();\nBooleanCompution containsCompution = listProp.computeContains(\"CONTAINS\");\nIntegerCompution sizeCompution     = listProp.computeSize();\n\n/* Set */\nSetProperty\u003cString\u003e setProp = SetProperty.newInstance();\n\nBooleanCompution isEmptyCompution  = setProp.computeIsEmpty();\nBooleanCompution containsCompution = setProp.computeContains(\"CONTAINS\");\nIntegerCompution sizeCompution     = setProp.computeSize();\n\n/* Map */\nMapProperty\u003cString, Integer\u003e mapProp = MapProperty.newInstance();\n\nBooleanCompution isEmptyCompution     = mapProp.computeIsEmpty();\nBooleanCompution containsKeyCompution = mapProp.computeContainsKey(\"KEY\");\nIntegerCompution sizeCompution        = mapProp.computeSize();\nSetCompution\u003cString\u003e keySetCompution  = mapProp.computeKeySet();\n```\n\n## Observer\n\nAll `Property` and `Compution` can observe changed value by `#addChangeListener`.\n\n```java\n/* build instance */\nIntegerProperty a = IntegerProperty.newInstance(1);\nIntegerProperty b = IntegerProperty.newInstance(2);\nIntegerProperty c = IntegerProperty.newInstance(3);\n\nNumberCompution sum = NumberCompution.sum(a, b, c);\n\n/* Add ChangeListener */\nsum.addChangeListener(n -\u003e {\n\tSystem.out.println(n.intValue());\n});\n\n           /*  \"6\", (1+2+3), initial   */\na.set(4);  /*  \"9\", (4+2+3), a changed */\nb.set(5);  /* \"12\", (4+5+3), b changed */\nc.set(6);  /* \"15\", (4+5+6), c changed */\n```\n\nSee also [\"/examples/example/NumberComputionExample.java\"](/examples/example/NumberComputionExample.java)\n\n## Wait Until Methods\n\nWaiting until condition is true. (blocking methods)  \nIf set timeout and over, throw `java.util.concurrent.TimeoutException`.\n\n```java\n/* build instance */\nfinal BooleanProperty boolProp = BooleanProperty.newInstance(false);\nfinal IntegerProperty intProp = IntegerProperty.newInstance(0);\nfinal ObjectProperty\u003cString\u003e objProp = ObjectProperty.newInstance(null);\nfinal MapProperty\u003cString, String\u003e mapProp = MapProperty.newInstance();\n\nnew Thread(() -\u003e {\n\ttry {\n\t\tThread.sleep(1000L);\n\t\tboolProp.set(true);\n\t\t\n\t\tThread.sleep(1000L);\n\t\tintProp.set(10);\n\t\t\n\t\tThread.sleep(1000L);\n\t\tobjProp.set(\"STRING\");\n\t\t\n\t\tThread.sleep(1000L);\n\t\tmapProp.put(\"KEY\", \"VALUE\");\n\t}\n\tcatch ( InterruptedException ignore ) {\n\t}\n}).start();\n\nSystem.out.println(\"Waiting until boolProp is true.\");\nboolProp.waitUntilTrue();\nSystem.out.println(\"boolProp is true.\");\n\nSystem.out.println(\"Waiting until intProp is \u003e0.\");\nintProp.waitUntilGreaterThan(0);\nSystem.out.println(\"inrProp is \u003e0.\");\n\nSystem.out.println(\"Waiting until objProp is not null.\");\nString objv = objProp.waitUntilNotNullAndGet();\nSystem.out.println(\"objProp is \" + objv);\n\nSystem.out.println(\"Waiting until mapProp containsKey(\\\"KEY\\\").\");\nString mapv = mapProp.waitUntilContainsKeyAndGet(\"KEY\");\nSystem.out.println(\"mapProp get(\\\"KEY\\\") is \" + mapv);\n```\n\n- Integer/Long/Float/Double/Number Property/Compution\n  + `#waitUntilEqualTo` (==)\n  + `#waitUntilNotEqualTo` (!=)\n  + `#waitUntilLessThan` (\u003c)\n  + `#waitUntilLessThanOrEqualTo` (\u003c=)\n  + `#waitUntilGreaterThan` (\u003e)\n  + `#waitUntilGreaterThanOrEqualTo` (\u003e=)\n  + `#waitUntilEqualToZero` (==0)\n  + `#waitUntilNotEqualToZero` (!=0)\n  + `#waitUntilLessThanZero` (\u003c0)\n  + `#waitUntilLessThanOrEqualToZero` (\u003c=0)\n  + `#waitUntilGreaterThanZero` (\u003e0)\n  + `#waitUntilGreaterThanOrEqualToZero` (\u003e=0)\n- Boolean Property/Compution\n  + `#waitUntil`\n  + `#waitUntilTrue`\n  + `#waitUntilFalse`\n- Object Property/Compution\n  + `#waitUntilEqualTo`\n  + `#waitUntilNotEqualTo`\n  + `#waitUntilNull`\n  + `#waitUntilNotNullAndGet`\n- String Property/Compution\n  + `#waitUntilIsEmpty`\n  + `#waitUntilIsNotEmptyAndGet`\n  + `#waitUntilContainsAndGet`\n  + `#waitUntilNotContainsAndGet`\n  + `#waitUntilStartsWithAndGet`\n  + `#waitUntilEndsWithAndGet`\n  + `#waitUntilMatchesAndGet`\n  + `#waitUntilContentEqualToAndGet`\n  + `#waitUntilNotContentEqualToAndGet`\n  + `#waitUntilEqualTo`\n  + `#waitUntilNotEqualTo`\n  + `#waitUntilLessThan` (compareTo \u003c0)\n  + `#waitUntilLessThanOrEqualTo` (compareTo \u003c=0)\n  + `#waitUntilGreaterThan` (compareTo \u003e0)\n  + `#waitUntilGreaterThanOrEqualTo` (compareTo \u003e=0)\n  + `#waitUntilEqualToIgnoreCase`\n  + `#waitUntilNotEqualToIgnoreCase`\n- List/Set Property/Compution\n  + `#waitUntilIsEmpty`\n  + `#waitUntilIsNotEmpty`\n  + `#waitUntilContains`\n  + `#waitUntilNotContains`\n  + `#waitUntilContainsAll`\n  + `#waitUntilNotContainsAll`\n- Map Property/Compution\n  + `#waitUntilIsEmpty`\n  + `#waitUntilIsNotEmpty`\n  + `#waitUntilContainsKeyAndGet`\n  + `#waitUntilNotContainsKey`\n\n## TimeoutProperty\n\n`TimeoutProperty` is utility class instance.  \nIncludes `timeout(long)` and `java.util.concurrent.TimeUnit`.  \nCan set to `waitUntil` methods as timeout.\n\n```java\n/* build instance */\nTimeoutProperty timeProp = TimeoutProperty.newInstance(10L, TimeUnit.SECONDS);  /* set 10 seconds */\nTimeoutProperty timeProp = TimeoutProperty.newInstance(10.0F);  /* set 10.0 seconds */\n\n/* Setter */\ntimeProp.set(5.0F);  /* set 5.0 seconds */\n\n/* Utilities */\ntimeProp.sleep();  /* TimeUnit#sleep(timeout); */\ntimeProp.wait(syncObj);  /* TimeUnit#timedWait(syncObj, timeout); */\nT v = timeProp.futureGet(future);  /* Future\u003cT\u003e#get(timeout, TimeUnit); */\nT v = timeProp.blockingQueuePoll(blockingQueue);  /* BlokingQueue\u003cT\u003e#poll(timeout, TimeUnit); */\n\n/* set to #waitUntil methods as timeout */\nboolProp.waitUntilTrue(timeProp);\n```\n\nSee also [\"/examples/example/TimeoutPropertyExample.java\"](/examples/example/TimeoutPropertyExample.java)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenta-shimizu%2Fproperty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenta-shimizu%2Fproperty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenta-shimizu%2Fproperty/lists"}