Nullify for null representations and assertions of objects

Related tags

Spring Boot nullify
Overview

Nullify

Maven Central Build Status Quality Gate Status Coverage Hits

Nullify for null representations and assertions of objects.

Philosophy

A semantic emptiness is a key concept used to indicate the absence of a value. Even if an object is not actually referenced as null, it can be considered null if it is semantically filled with empty values.

In the beginning there was...

You had to convert an empty value to null to persist it in a database. Also you had to convert null to an empty string to display it in a GUI or something elsewhere like Stream or Writer. If you don't want to use null at all, you had to write a code to getting default value/object. like this:

if (value != null && value.length() <= 0) {
    entity.setValue(null);
} else {
    entity.setValue(value);
}

or

entity.setValue(value == null || value.length() <= 0 ? null : value);

Okay, That's totally fine. But how about this?

entity.setValue(Nullify.of(value));

in some cases, you might want to use empty string("") instead of null:

Nullify.toString(value);

Further, checking for semantically empty

0) { isSemanticallyEmpty = false; break; } } if (isSemanticallyEmpty) { collection = Arrays.asList("default_value"); } }">
if (collection == null || collection.size() <= 0) {
    collection = Arrays.asList("default_value");
} else {
    boolean isSemanticallyEmpty = true;
    for (String value : collection) {
        if (value != null && value.length() > 0) {
            isSemanticallyEmpty = false;
            break;
        }
    }
    if (isSemanticallyEmpty) {
        collection = Arrays.asList("default_value");
    }
}

above code can also be replaced with:

Nullify.of(collection, Arrays.asList("default_value"));

Predicates

  • Nullify.isNull(object)
  • Nullify.isNotNull(object)

Maven Central

<dependency>
    <groupId>org.silentsoftgroupId>
    <artifactId>nullifyartifactId>
    <version>1.0.1version>
dependency>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please note we have a CODE_OF_CONDUCT, please follow it in all your interactions with the project.

License

Please refer to LICENSE.

You might also like...

Plugin for Spigot, PaperMC, BungeeCord and Velocity to create custom MOTDs, playercount message and playercount hover with priorities and conditions.

AdvancedServerList AdvancedServerList is a server and proxy plugin that allows you to create custom MOTDs and more in your server list with priority a

Dec 14, 2022

An Open-Source repository ๐ŸŒŽ that contains all the Data Structures and Algorithms concepts and their implementation, programming questions and Interview questions

An Open-Source repository ๐ŸŒŽ that contains all the Data Structures and Algorithms concepts and their implementation, programming questions and Interview questions

An Open-Source repository ๐ŸŒŽ that contains all the Data Structures and Algorithms concepts and their implementation, programming questions and Interview questions. The main aim of this repository is to help students who are learning Data Structures and Algorithms or preparing for an interview.

Dec 29, 2022

source code of the live coding demo for "Building resilient and scalable API backends with Apache Pulsar and Spring Reactive" talk held at ApacheCon@Home 2021

reactive-iot-backend The is the source code of the live coding demo for "Building resilient and scalable API backends with Apache Pulsar and Spring Re

Jan 13, 2022

Simple and lightweight application which is checking status of your web services and send a notification if it is down.

rose-uptimer Simple and lightweight application which is checking status of your web services and send a notification if it is down. Example configura

Sep 25, 2022

A complete and performing library to highlight text snippets (EditText, SpannableString and TextView) using Spannable with Regular Expressions (Regex) for Android.

A complete and performing library to highlight text snippets (EditText, SpannableString and TextView) using Spannable with Regular Expressions (Regex) for Android.

Highlight A complete and performing library to highlight text snippets (EditText/Editable and TextView) using Spannable with Regular Expressions (Rege

Dec 22, 2022

A distributed lock that supports the use of Redis and Zookeeper, out of the box, fast and easy to use

lock-spring-boot-starter A distributed lock that supports the use of Redis and Zookeeper, out of the box, fast and easy to use ไธ€ๆฌพๅŸบไบŽ Redis ๅ’Œ Zookeeper

Oct 15, 2022

Scan and patch tool for CVE-2021-44228 and related log4j concerns.

A Log4J2 CVE-2021-44228 Vulnerability Scanner and Patcher Links to download the latest version: Linux x64 with glibc2.17+ (RHEL7+) Windows & all other

Jun 1, 2022

Powerful and flexible library for loading, caching and displaying images on Android.

Powerful and flexible library for loading, caching and displaying images on Android.

Universal Image Loader The great ancestor of modern image-loading libraries :) UIL aims to provide a powerful, flexible and highly customizable instru

Jan 2, 2023

Render After Effects animations natively on Android and iOS, Web, and React Native

Render After Effects animations natively on Android and iOS, Web, and React Native

Lottie for Android, iOS, React Native, Web, and Windows Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations expo

Jan 3, 2023
Comments
  • Badge link problems in readme

    Badge link problems in readme

    It would be nice if maven badge in readme was linked to: https://search.maven.org/artifact/org.silentsoft/nullify to take visitors directly to maven central artifact without need to search.

    Also the build badge's link to travis gives a 404 error.

    opened by cicirello 1
  • Maven Central javadoc jar missing documentation

    Maven Central javadoc jar missing documentation

    The javadocs in the javadoc jar on Maven Central only has method names and parameters but no actual documentation. Although examples in the GutHub readme are nice, it would be better if the class and all public methods had javadoc comments in the source, which would make the javadoc jar far more useful. Nice little library though.

    opened by cicirello 1
Releases(v1.0.1)
  • v1.0.0(Jan 18, 2022)

    Philosophy

    A semantic emptiness is a key concept used to indicate the absence of a value. Even if an object is not actually referenced as null, it can be considered null if it is semantically filled with empty values.

    In the beginning there was...

    You had to convert an empty value to null to persist it in a database. Also you had to convert null to an empty string to display it in a GUI or something elsewhere like Stream or Writer. If you don't want to use null at all, you had to write a code to getting default value/object. like this:

    if (value != null && value.length() <= 0) {
        entity.setValue(null);
    } else {
        entity.setValue(value);
    }
    

    or

    entity.setValue(value == null || value.length() <= 0 ? null : value);
    

    Okay, That's totally fine. But how about this?

    entity.setValue(Nullify.of(value));
    

    in some cases, you might want to use empty string("") instead of null:

    Nullify.toString(value);
    

    Further, checking for semantically empty

    if (collection == null || collection.size() <= 0) {
        collection = Arrays.asList("default_value");
    } else {
        boolean isSemanticallyEmpty = true;
        for (String value : collection) {
            if (value != null && value.length() > 0) {
                isSemanticallyEmpty = false;
                break;
            }
        }
        if (isSemanticallyEmpty) {
            collection = Arrays.asList("default_value");
        }
    }
    

    above code can also be replaced with:

    Nullify.of(collection, Arrays.asList("default_value"));
    

    Predicates

    • Nullify.isNull(object)
    • Nullify.isNotNull(object)
    Source code(tar.gz)
    Source code(zip)
    nullify-1.0.0-javadoc.jar(22.63 KB)
    nullify-1.0.0-sources.jar(3.45 KB)
    nullify-1.0.0.jar(4.54 KB)
Owner
Hyesung Lee
Developer who wants to benefit the world.
Hyesung Lee
KSAN : Software Defined Storage for Objects and Files

KSAN : Software Defined Storage for Objects and Files Overview KSAN์€ ๋Œ€๊ทœ๋ชจ ์˜ค๋ธŒ์ ํŠธ ์Šคํ† ๋ฆฌ์ง€ ์„œ๋น„์Šค๋ฅผ ์•ˆ์ •์ ์ด๋ฉฐ ํšจ์œจ์ ์œผ๋กœ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์„ค๊ณ„๋œ ์†Œํ”„ํŠธ์›จ์–ด ์ •์˜ ์˜ค๋ธŒ์ ํŠธ ์Šคํ† ๋ฆฌ์ง€ ์‹œ์Šคํ…œ์ž…๋‹ˆ๋‹ค. KSAN ์‹œ์Šคํ…œ์€ ๊ธฐ

InfiniStor / KSAN 21 Dec 28, 2022
Observing a sequence of objects that can be numerically ranked best and worst.

Optimal-Stopping The Secretary Problem from Optimal Stopping. https://en.wikipedia.org/wiki/Optimal_stopping Observing a sequence of objects that can

null 1 Feb 3, 2022
Using this library, and writing a few lines of code, you can manage your own domain objects in ZooKeeper

Using this library, and writing a few lines of code, you can manage your own domain objects in ZooKeeper. It provides CRUD operations and change notifications out of the box.

Sahab 4 Oct 26, 2022
Java How To Program (Early Objects), 10th Edition (Paul Deitel, Deitel & Associates, Inc. Harvey Deitel)

Java How To Program (Early Objects), 10th Edition Description I have written book source codes and answers to exercises Structure of Source Codes Each

Ali Moradzade 2 Apr 19, 2022
The Apache Software Foundation 605 Dec 30, 2022
A suite of software tools and services created to support activity planning and sequencing needs of missions with modeling, simulation, scheduling and validation capabilities

Aerie A suite of software tools and services created to support activity planning and sequencing needs of missions with modeling, simulation, scheduli

NASA Advanced Multi-Mission Operations System 31 Jan 3, 2023
A compact and highly efficient workflow and Business Process Management (BPM) platform for developers, system admins and business users.

Flowable (V6) Maven Central: Docker Images: License: Homepage: https://www.flowable.org/ flowable / flowษ™b(ษ™)l / a compact and highly efficient workfl

Flowable 6k Jan 7, 2023
InterfaceMaker is a modern plugin to handle and customize join items, hotbars and menus with a developer and administrator friendly API.

Interface Maker InterfaceMaker is a modern plugin to handle and customize join items, hotbars and menus with a developer friendly API. Features Simple

2LStudios - Minecraft 10 Nov 27, 2022
Program that allows employees to clock in and clock out of work. Employees who are managers can add, edit and delete employees and shifts from the database.

Clock-In-Clock-Out-System Created by: Kennedy Janto, Taylor Vandenberg, Duc Nguyen, Alex Gomez, Janista Gitbumrungsin This is a semester long project

null 6 Nov 5, 2022
This repository contains the code for the Runescape private server project, and this repo is soley maintained by @Avanae and @ThePolyphia and @Xeveral

Runescape: The private server project. A Runescape private server based on the 2009 era. This repository contains the code for the Runescape private s

ProjectArchitecture 4 Oct 1, 2022