Skip to content

Gatoke/ultimate-checker

Repository files navigation

logo

Ultimate-Checker Build codecov License: MIT

Are you tired of == != || && when comparing values?

tired cat

Do you feel professionally burned out after a long day of writing code like this?

boolean shouldHaveSomeRest = 
    selectedOption == FeelingEnum.TIRED
        || selectedOption == FeelingEnum.SLEEPY
        || selectedOption == FeelingEnum.RESIGNED;

angry cat

It's time for change...

REPRESENTING ULTIMATE CHECKER:

boolean shouldCodeMore = Check.anyEqual(selectedOption,
        FeelingEnum.NOT_TIRED,
        FeelingEnum.NOT_SLEEPY,
        FeelingEnum.ABLE_TO_DO_MORE_JIRA_TASKS
);

relaxed cat


Interested? Here's more:

interested cats

  • 1. allTrue:

boolean canPerformOperation = Check.allTrue(
        userRepository.doesExist(userId),
        authorizationService.hasPrivileges(userId),
        operationType == SomeEnum.DEPOSIT
);
  • 2. noneFalse (safe for null values!!):

boolean canPerformOperation = Check.noneFalse(
        userRepository.doesExist(userId),
        authorizationService.hasPrivileges(userId),
        null // it's totaly safe (no joke)!! treats "null" as not "false"
);
  • 4. allFalse:

boolean hasPermission = Check.allFalse(
        authorizationService.isBanned(userId),
        paymentService.didExceedMonthlyLimit(userId)
);
  • 5. noneTrue (also null safe):

boolean hasPermission = Check.noneTrue(
        authorizationService.isBanned(userId),
        paymentService.didExceedMonthlyLimit(userId),
        null
);
  • 6. anyTrue (null safe):

boolean hasAccess = Check.anyTrue(
        authorizationService.isAdministrator(userId),
        authorizationService.isTester(userId)
);
  • 7. anyFalse (null safe):

boolean shouldBlockAccess = Check.anyFalse(
        authorizationService.isTester(userId),
        authorizationService.hasPrivileges(userId)
);
  • 8. allEqual:

boolean haveWonEverywhere = Check.allEqual(username,
        electionsService.getWinnerFrom("Śródmieście"),
        electionsService.getWinnerFrom("Żoliborz")
);
  • 9. allNotEqual:

boolean didNotWinAnywhere = Check.allNotEqual(username,
        electionsService.getWinnerFrom("Śródmieście"),
        electionsService.getWinnerFrom("Żoliborz")
);
  • 10. anyEqual (null safe!!):

boolean haveWonSomewhere = Check.anyEqual(username,
        electionsService.getWinnerFrom("Śródmieście"),
        electionsService.getWinnerFrom("Żoliborz")
);
  • 11. anyNotEqual (null safe!!):

boolean haveFailedSomewhere = Check.anyNotEqual(username,
        electionsService.getWinnerFrom("Śródmieście"),
        electionsService.getWinnerFrom("Żoliborz")
);

Compatibility:

The project is tested with Java 8 but there's no usage of Java 8's specific API, so it should be compatible with Java 7 also.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published