Sweetener - Escapes

Everyone, sooner or later, must face with escaping characters problem. For this reason we have created a special class Escapes as part of sweetener project, which goal is solve this problem. Escapes class contains five special methods to escape special characters for:

read more

Jsolve - Projects in Maven Central

Jsolve - Projects in Maven Central! From now Sweetener, Oven and Type-converter are in Maven Cetral.
Current versions of our libraries are: sweetener: 1.0.0, oven: 1.0.1, type-converter: 1.0.1. In order to use it in maven project just add the below dependency to your pom file.

read more

Sweetener - Collection Restrictions - Part III - Custom restrictions

Sweetener contains many pre-defined restrictions, but we cannot predict all use-cases of our mechanism. For this reason we have prepared CustomRestriction. If none of the restrictions prepared by us is what you are looking for, you can create your own restriction. Preparing CustomRestriction is simple and intuitive. To create your own Restriction you need to create new class which extends CustomRestriction class. Let’s assume that we want to create restriction which checks whether string starts with some substring. The example restriction might look as follows:

read more

Unit testing exceptions in Java

Testing exceptions is crucial when you are into defensive programming. Ensuring your code behaves correctly under unforeseen circumstances. Though JUnit’s @Test(expected = ...) seems to be good enough, there are cases where you might find your tests green when they shouldn’t. The bad thing is it verifies whether an exception was thrown in whole test method:

read more

Sweetener - Collection Restrictions - Part II - Filtering by date

Filtering objects by using Date class is a very common problem. There are times when we want find objects, for which one of the field is in some time range. Such an example may be find all people who were born before the year 1988. However, there is problem with dates in Java, namely the lack of a uniform approach. There are still applications which use java.util.Date or java.util.Calendar. In addition to the java.util.Date there is also java.sql.Date. Modern applications written in Java < SE 8 use JodaTime library to represent date. It has introduced several new classes of date: DateTime, LocalDate, LocalTime, LocalDateTime. All of these classes are located in org.joda.time package. In the SE8 these classes have been integrated into the standard SE8 and have been placed in java.time. As you can see there is a very large number representation of a date in Java. For this reason, it is hard to create a generic restriction which could operate on all of these date types. To solve this problem, we have prepared a special mechanism that allows comparison of the dates of any type, we’ve create DateExtractor interface. For each type of date used during filtering you should register appropriate extractor:

read more

Łukasz Stypka

Java experienced enthusiast, opened for new technologies. Clean code and simple solution fan.

Tomasz Kuryłek

Self-styled and passionate java hipster. Focused on solution that makes user and himself ecstatic..