Skip to content

Utility methods for working with immutable objects in Java.

License

Notifications You must be signed in to change notification settings

terheyden/immutables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Immutables

Immutables is a utility class for working with Guava immutable objects.

There are many excellent reasons to use immutable objects wherever possible. But that doesn't mean it should be a pain in the neck to work with them.

    LedgerItem item2 = new LedgerItem(hourAhead, id2);

    // Multiple items can fire at the same time, so we make a list here:
    ImmutableList<LedgerItem> items2 = ImmutableList.of(item2);

    // Items are mapped to a scheduled time, so:
    ImmutableSortedMap<Instant, ImmutableList<LedgerItem>> scheduledItems2 =
        ImmutableSortedMap.<Instant, ImmutableList<LedgerItem>>naturalOrder()
            .putAll(scheduledItems1b)
            .put(hourAhead, items2)
            .build();
    LedgerItem item2 = new LedgerItem(hourAhead, id2);

    // Items are mapped to a scheduled time, so:
    ImmutableSortedMap<Instant, ImmutableList<LedgerItem>> scheduledItems2 =
        Immutables.addToSortedMapList(scheduledItems1b, hourAhead, item2);

About

Utility methods for working with immutable objects in Java.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages