I have two similar classes, Foo and Bar And I’ve got two methods in another class that creates a Set of Foo (1st method) and Bar (2nd method) and are pretty much the same. The first one: And the second one: As you can see, both methods are pretty much the same so I thought I could use generics to
Tag: java
Applying Interface Segregation Principle to service layer interface
Using the book as analogy, suppose I have a book resource with the following API (there are also update and delete etc but for simplicity only show two here) Each of these API would call other APIs to get the result, rather than the typical CRUD database operation. And based on the requirement / existing fram…
How to load a different database file with Room?
Goal I have an app with plenty of data, with a switch button, which switch the language (french or english) of the entire app. However, some of my data are stored in a Room database. I have two .db files : database_fr.db and database_en.db. Let’s say the app is currently in french, with the database_fr.…
Retrieving data from LDAP
I want to fetch data from LDAP server. I can retrieve all users from the list. But now, what I want to do is get the person list under ‘directReports’ attribute. It returns users as java Objects. I cannot convert them to any type other than toString(). What I have done is convert objects to String…
Letter appears in console output, but shouldn’t. problem with Bukkit.getConsoleSender().sendMessage();
I’m trying to split code in classes. This code is sending to console text with B letter in start of line, but shouldn’t. Code: in ConsoleWrapper.java but if console.sendMessage((“§c[” + pluginName + “]” + msg)); executing in main class, letter B doesn’t appeat in cons…
Using AOP and DI itself causes Spring ApplicationListener to be fired twice
Software versions Spring Version 5.3.18 and earlier JDK Version 1.8.0_202 Overview When I use Spring ApplicationListener, in order to prevent transaction invalidation, my ApplicationListener implementation class writes the following code (of course, the code can be written differently to avoid this problem), …
Java SpringBoot – Endpoint to trigger a job moments after, but returns immediately
Small Java and SpringBoot question please. I would like to build an endpoint, which when a client calls in, will return immediately, but after a minute from the call, will trigger a job. I have no control over when the client triggers the requests, I cannot hold the client for that time, and I have no control…
DDD: choose relationship or only id reference with JPA/Hibernate
Here is a situation makes me quite confusing. I have two tables: users and articles. One user can write multiple articles and one article can only have one author. From this business. I have two entity: If I follow the JPA style, the Article should be like this: This will make the query service quite easy. Fo…
How do I retrieve data under UID for the signed in user with Firebase
I saved some data under a node with the currently signed in user UID, along with the post timestamp.I successfully manage to retrieve all the data under this node, but I would only like to retrieve the data for the currently signed in user, I am trying to create something similar to how amazon stores an item …
How to add Camel properties component to camel context?
I’m currently trying to add properties component with location set to my properties file to use properties placeholders in my project: But addComponent() function expects Component type argument, not PropertiesComponent even though PropertiesComponent extends the DefaultComponent class. I’ve added…