Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

All power corrupts, but we need electricity.


devel / comp.lang.java.programmer / Re: Java record

SubjectAuthor
* Java recordJason H
`- Java recorde.d.pro...@gmail.com

1
Re: Java record

<tvcrgf$6po8$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=228&group=comp.lang.java.programmer#228

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: DarthPiriteze@deathstar.gal (Jason H)
Newsgroups: comp.lang.java.programmer
Subject: Re: Java record
Date: Tue, 21 Mar 2023 18:02:55 +0000
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <tvcrgf$6po8$2@dont-email.me>
References: <906f5a76-929d-46cb-b5e0-fcc8e4ad4e0en@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 21 Mar 2023 18:02:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="313b16856fd983c461eeb9cb0df225c5";
logging-data="222984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5lwcrZZAEtmBJ5jEIV95oIQDjtJSrQLI="
User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:jfnzXaMium+IRnWoaWEYU8C8aqI=
In-Reply-To: <906f5a76-929d-46cb-b5e0-fcc8e4ad4e0en@googlegroups.com>
Content-Language: en-US
 by: Jason H - Tue, 21 Mar 2023 18:02 UTC

On 3/1/23 19:18, e.d.pro...@gmail.com wrote:
> I just saw they added a new thing called record to Java 16. Is this not a replacement for a DTO or am I missing something?
> I create a DTO class like:
> public class TestDTO {
> private String testField;
> public String getTestField() {
> return this.testField;
> }
> public void setTestField(String test) {
> this.testField = test;
> }
> }
>
> I define a matching record definition like:
> public record TestRecordDTO(String testField) {
>
> }
>
> Now I try to test them:
> public static void main(String[] args) {
> TestRecordDTO rec = new TestRecordDTO("testrec");
>
> TestDTO dto = new TestDTO();
> dto.setTestField("testrec");
>
> Gson gson = new Gson();
> System.out.println(gson.toJson(rec)); // {"testField":"testrec"}
> System.out.println(gson.toJson(dto)); // {"testField":"testrec"}
> rec.testField();
> dto.getTestField();
>
> dto = gson.fromJson(gson.toJson(dto), TestDTO.class);
> System.out.println(dto.getTestField()); // testrec
> rec = gson.fromJson(gson.toJson(rec), TestRecordDTO.class); // throws AssertionError
> System.out.println(rec);
> }
>
> In web, we use DTOs on the back end to pass data to and from the Javascript/Typescript on the front end. It looks like passing to the front end works, now how do we use it as a model to get the user input?

I encountered this when I Googled how to do structs in Java. The answer
was not before 16 (though really, a class with a bunch of public
variables will do, if that's what you need).

Re: Java record

<4a22cff7-d236-4c8b-ac4d-d6ad8a6a0b29n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=229&group=comp.lang.java.programmer#229

  copy link   Newsgroups: comp.lang.java.programmer
X-Received: by 2002:a05:6214:1851:b0:56f:36e:fbf with SMTP id d17-20020a056214185100b0056f036e0fbfmr611593qvy.4.1679483066541;
Wed, 22 Mar 2023 04:04:26 -0700 (PDT)
X-Received: by 2002:a05:6902:1503:b0:af7:38fc:f6da with SMTP id
q3-20020a056902150300b00af738fcf6damr1158877ybu.2.1679483066239; Wed, 22 Mar
2023 04:04:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.java.programmer
Date: Wed, 22 Mar 2023 04:04:25 -0700 (PDT)
In-Reply-To: <tvcrgf$6po8$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.237.40.232; posting-account=2czF5goAAAD4GBMPIGV4KcD2K4PhoB_H
NNTP-Posting-Host: 98.237.40.232
References: <906f5a76-929d-46cb-b5e0-fcc8e4ad4e0en@googlegroups.com> <tvcrgf$6po8$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4a22cff7-d236-4c8b-ac4d-d6ad8a6a0b29n@googlegroups.com>
Subject: Re: Java record
From: e.d.programmer@gmail.com (e.d.pro...@gmail.com)
Injection-Date: Wed, 22 Mar 2023 11:04:26 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1597
 by: e.d.pro...@gmail.com - Wed, 22 Mar 2023 11:04 UTC

> > In web, we use DTOs on the back end to pass data to and from the Javascript/Typescript on the front end. It looks like passing to the front end works, now how do we use it as a model to get the user input?
> I encountered this when I Googled how to do structs in Java. The answer
> was not before 16 (though really, a class with a bunch of public
> variables will do, if that's what you need).
Sounds like a record is a class with public final variables.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor