IceSpringRealOptional
Real Optional type in python, not @Nullable annotation.
Official sites
- Home: https://baijifeilong.github.io/2022/01/09/ice-spring-real-optional/index.html
- Github: https://github.com/baijifeilong/IceSpringRealOptional
- PyPI: https://pypi.org/project/IceSpringRealOptional
Features
- All
Java 8styleOptionalAPI support - All
Generic Typeannotation support
Install
- PyPI:
pip install IceSpringRealOptional
Usage
from IceSpringRealOptional.maybe import Maybe
maybe = Maybe.ofNullable("CommonSense")
print("{}: isPresent={}".format(maybe, maybe.isPresent()))
print("{}: value={}".format(maybe, maybe.get()))
maybe.ifPresent(lambda x: print(f"{x} exist"))
print("{}'s length: {}".format(maybe, maybe.map(len)))
empty = Maybe.empty()
print(empty.orElse("{} is empty".format(empty)))
print(empty.orElseGet(lambda: "{} is empty again".format(empty)))
try:
Maybe.empty().orElseThrow(lambda: RuntimeError("Unlucky"))
except RuntimeError as e:
print("Runtime error caught: {}".format(e))
Example Output
<Maybe:CommonSense>: isPresent=True
<Maybe:CommonSense>: value=CommonSense
CommonSense exist
<Maybe:CommonSense>'s length: <Maybe:11>
<Maybe:None> is empty
<Maybe:None> is empty again
Runtime error caught: Unlucky
License
MIT
Metadata
Release files for IceSpringRealOptional 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| IceSpringRealOptional-1.2.4.tar.gz | 2.7 kB | Without provenance | Details for IceSpringRealOptional-1.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| IceSpringRealOptional-1.2.4-py3-none-any.whl | Python 3 | none | any | Details for IceSpringRealOptional-1.2.4-py3-none-any.whl |
Total release size: 8.7 kB
Release files / IceSpringRealOptional-1.2.4.tar.gz
| Download URL | IceSpringRealOptional-1.2.4.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41d79e1a33f4391af9a551ab5265fa2da2fee948219f68c719a0854fcce364a0
|
|
BLAKE2b-256 checksum How to use checksums |
93fcac6d76672a22d82896177189dbe083af5c03c5b8103990dc27901609a065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / IceSpringRealOptional-1.2.4-py3-none-any.whl
| Download URL | IceSpringRealOptional-1.2.4-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
700b4f9873c8ec2841979dac6a7b244ab2941c6d47d3f27c16817d204f1a1ade
|
|
BLAKE2b-256 checksum How to use checksums |
ccd6a148f5e530bf7d554cbdc1286505ea264fb4e026669d2c6b62eb8bb7a244
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for IceSpringRealOptional 1.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.