Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 177281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:01:38+00:00 2026-05-11T14:01:38+00:00

Does anyone know a library or some at least some research on creating and

  • 0

Does anyone know a library or some at least some research on creating and using persistent data structures in Java? I don’t refer to persistence as long term storage but persistence in terms of immutability (see Wikipedia entry).

I’m currently exploring different ways to model an api for persistent structures. Using builders seems to be a interesting solution:

// create persistent instance Person p = Builder.create(Person.class)              .withName('Joe')              .withAddress(Builder.create(Address.class)                  .withCity('paris')                  .build())               .build();  // change persistent instance, i.e. create a new one  Person p2 = Builder.update(p).withName('Jack');  Person p3 = Builder.update(p)               .withAddress(Builder.update(p.address())                 .withCity('Berlin')                 .build)             .build(); 

But this still feels somewhat boilerplated. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:01:39+00:00Added an answer on May 11, 2026 at 2:01 pm

    I guess the obvious choices are:

    o Switch to a transient data structure (builder) for the update. This is quite normal. StringBuilder for String manipulation for example. As your example.

    Person p3 =     Builder.update(p)     .withAddress(         Builder.update(p.address())        .withCity('Berlin')        .build()     )     .build(); 

    o Always use persistent structures. Although there appears to be lots of copying, you should actually be sharing almost all state, so it is nowhere near as bad as it looks.

    final Person p3 = p     .withAddress(         p.address().withCity('Berlin')     ); 

    o Explode the data structure into lots of variables and recombine with one huge and confusing constructor.

    final Person p3 = Person.of(     p.name(),     Address.of(        p.house(), p.street(), 'Berlin', p.country()     ),     p.x(),     p.y(),     p.z()  ); 

    o Use call back interfaces to provide the new data. Even more boilerplate.

    final Person p3 = Person.of(new PersonInfo(     public String  name   () { return p.name(); )     public Address address() { return Address.of(new AddressInfo() {        private final Address a = p.address();        public String house  () { return a.house()  ; }        public String street () { return a.street() ; }        public String city   () { return 'Berlin'   ; }        public String country() { return a.country(); }     })),     public Xxx     x() { return p.x(); }     public Yyy     y() { return p.y(); }     public Zzz     z() { return p.z(); }  }); 

    o Use nasty hacks to make fields transiently available to code.

    final Person p3 = new PersonExploder(p) {{     a = new AddressExploder(a) {{         city = 'Berlin';     }}.get(); }}.get(); 

    (Funnily enough I was just put down a copy of Purely Functional Data Structures by Chris Okasaki.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 136k
  • Answers 136k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes - static classes have no constructors: static class VeryLonelyType{}… May 12, 2026 at 7:14 am
  • Editorial Team
    Editorial Team added an answer Try looking at Double.TryParse() if you are using .NET 1.1/2.0/3.0/3.5/4.0/4.5 May 12, 2026 at 7:14 am
  • Editorial Team
    Editorial Team added an answer In your code you must change ButtonType="Image" to ButtonType="Link" -… May 12, 2026 at 7:14 am

Related Questions

I am looking for a cross-platform C++ master/worker library or work queue library. The
I'm looking for a good audio compression library for .NET. Anything using MP3 is
Does anyone know of an existing ruby implementation of a read/write lock - http://en.wikipedia.org/wiki/Readers-writer_lock
I'm working on building the Boost platform for a currently unsupported toolchain. Obviously we'd

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.