Skip to main content

IceSpringRealOptional

Real Optional type in python, not @Nullable annotation.

Official sites

Features

  • All Java 8 style Optional API support
  • All Generic Type annotation 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

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)

Source distribution for IceSpringRealOptional 1.2.4
File Size Uploaded
IceSpringRealOptional-1.2.4.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for IceSpringRealOptional 1.2.4
File Interpreter ABI Platform
IceSpringRealOptional-1.2.4-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.2.4 This release

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page