Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 747 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spring-Data JPA CrudRepository returns Iterable, is it OK to cast this to List?

#1
I'm writing a code-gen tool to generate backend wiring code for Spring Boot applications using Spring Data JPA and it's mildly annoying me that the methods in the `CrudRepository` return `Iterable` rather than `List`, as `Iterable` doesn't provide quite enough functionality, but `List` does, so I'm looking for the best way to convert the `Iterable` into a `List`.

I saw [this post](

[To see links please register here]

) on changing an `Iterable` to a `Collection` and I was wondering, rather than using a library like Guava or implementing my own function to do the conversion, why not just cast it to `List`? Is there something wrong with doing that that I don't know about?

**Edit**:
I ask because since it's a code-gen tool it's not reasonable to make it generate code that introduces dependencies on 3rd party libraries, and writing my own function to do the conversion also isn't really reasonable because it would have to live somewhere and I'd rather not have that in the generated code. A simple cast will work, if a little ugly, but just wondered if there's something I'm missing?
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through