Skip to content

A set of small and highly reusable libraries for Java.

License

Notifications You must be signed in to change notification settings

sweet-mustard/vinegar-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vinegar (Java)

Build status

Vinegar is a set of small but highly reusable libraries. Vinegar libraries typically don't require any other libraries, but play nice with popular frameworks and libraries.

Getting Started

Add a Maven dependency on the vinegar library you need in pom.xml:

<dependency>
  <groupId>be.sweetmustard.vinegar</groupId>
  <artifactId>vinegar-pattern-matcher</artifactId>
  <version>0.1.1</version>
</dependency>

Features

Pattern Matcher

The Pattern Matcher Vinegar is inspired by JDK enhancement proposal 305. It brings Pattern Matching to Java in the form of a DSL. Here's an example of the Pattern Matcher Vinegar in action:

import static be.sweetmustard.vinegar.matcher.MappingCondition.is;

Function<Shape, String> matcher = new PatternMatcher<Shape, String>()
    .when(is(Circle.class))
        .then(c -> "Circle with radius " + c.getRadius())
    .when(is(Rectangle.class))
        .then(r -> "Rectangle with width " + r.getWidth() + " and height " + r.getHeight())
    .otherwise("Unknown shape");

String result = matcher.apply(new Rectangle(2, 5)); // Returns: Rectangle with width 2 and height 5

See also Pattern Matching for Java

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Contributors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

About

A set of small and highly reusable libraries for Java.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages