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

  • Home
  • SEARCH
  • 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 7662313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:46:04+00:00 2026-05-31T13:46:04+00:00

Is there a way to easily generate java beans given a vector in clojure?

  • 0

Is there a way to easily generate java beans given a vector in clojure? For example given a vector like this:

[
    String :key1
    Integer :key2
]

I’d like it to generate code like this:

public class NotSureWhatTheTypeWouldBeHere {
    private String key1;
    private Integer key2;

    public NotSureWhatTheTypeWouldBeHere() {}
    public NotSureWhatTheTypeWouldBeHere(String key1, Integer key2) {
        this.key1 = key1;
        this.key2 = key2;
    }

    public void setKey1(String key1) {
        this.key1 = key1;
    }
    public String getKey1() {
        return this.key1;
    }
    public void setKey2(Integer key2) {
        this.key2 = key2;
    }
    public String getKey2() {
        return this.key2;
    }

    // and equals,hashCode, toString, etc.
}

For context, I’d like to write an app that is written in java but calls into a library written in clojure. So that means the return values should be java beans (I know they don’t have to be, but I’d like them to be). One way would be to define the model in java and then use clojure’s normal java interop to populate the model in the clojure code, but I like the idea of a concise clojure vector(or map) expanding out to a (verbose) java bean.

  • 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. Editorial Team
    Editorial Team
    2026-05-31T13:46:06+00:00Added an answer on May 31, 2026 at 1:46 pm

    I don’t think your Java code would play nicely with auto generated Java bean compliant classes. You need to have at least an interface on the Java side to make any sense of what’s Clojure is going to return. Without that, you will have to revert to:

    Object result = callClojureLib(params);
    

    Then, no matter if the actual result implements the Java bean contract, your Java code will have to do all sorts of reflection wizardry to be able to even call a setter, as you’re missing the class specification.

    Another approach to the problem would be to use the java.util.Map interface as the contract between Java and Clojure worlds. This way, you could just use plain Clojure maps as transfer objects, as they are assignable to java.util.Map:

    user=> (isa? (class {}) java.util.Map)
    true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Surely there must be a way to do this easily! I've tried the Linux
I would like to know is there any way to generate xml schema from
Is there a way to easily convert Crystal Reports reports to Reporting Services RDL
Is there a way to easily sort in SQL Server 2005 while ignoring hyphens
Is there any way to easily make a HTTP request with C++? Specifically, I
Is there any way of easily deciphering (i.e. at a glance) whether or not
In Visual Studio (C++), is there a way to easily find duplicate headers that
Is there a good way to create a form in VB6 that can easily
is there way how to get name ov event from Lambda expression like with
Possible Duplicate: Reversing an MD5 Hash Given this method in c# public string CalculateFileHash(string

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.