Spring Boot: JPA with projection Loop Update Value [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
I would like to ask you about JPA with projection.
Noted: I would like to update new value to getChild.
// From Folder Projection
public interface AuthMenu {
Long getMenuId();
String getMenuName();
String getMenuLink();
List<AuthSubMenu> getChild();
}
// From Folder Service implements
#Override
public List<AuthMenu> getListMenuByRoleUser(Long UserId) {
List<Integer> _actionIds = roleActionsRepository.getListActionIds(UserId);
List<AuthMenu> listMenu = menuRepository.getListMenuIds(1,_actionIds);
for (int i = 0; i < listMenu.size(); i++) {
// Want to update new value <-
}
return listMenu;
}
Could you help me please?
My expectation is want to update new value to getChild().

Related

Java : how to use the Param to present a class [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a question about param, what param to present the class, such as if I findBuildingsType( buildingEntities, Village) it will return all village building as a result
Welcome.
You can deliver a Class via arguments like this:
private List<Building> findBuildingsType(List<Building> buildings, Class<? extends Building> typ) {
List<Building> re = new ArrayList<>();
for (Building building : buildings) {
if (typ.isInstance(building)) {
re.add(building);
}
}
return re;
}
Especially for your problem consider using streams:
List<Building> buildingsOfTypeMansion = buildings.stream().filter(building -> building instanceof Mansion).collect(Collectors.toList());

How to check if user exists in Cloud Firestore? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Here is it I add value about user.
val user = hashMapOf(
USER_CONVERSATIONS to arrayListOf(""),
USER_EMAIL_COLUMN to personEmail,
USER_NAME_COLUMN to personName,
USER_PHOTO_URL_COLUMN to personPhoto.toString(),
USER_ID_COLUMN to personId
)
db.collection("users").add(user)
Which rule do I need to put inside Cloud Filestore or checking inside app?
Here is it my structure: https://imgur.com/a/w0AltSf
Thank you for extended answer!
I would like to do not register my account with new id, and check this in app, answer was given, thank you!
You can request to know if that document exists before inserting it. You can use something like this.
firestore.collection("users").whereEqualTo("id", YOUR_USER_ID)
.limit(1).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
#Override
public void onComplete(#NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
// You can check here if document exist.
// It will be empty if it doesnt.
boolean isEmpty = task.getResult().isEmpty();
}
}
});

From immutability's concern, any issue with this code (call by reference) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
From immutability's point of view, is there any concerns for this code ?
public class mainPkg {
private boolean MyFunc1(MyInfo info) {
List<MyObj> myList = new ArrayList<MyObj>();
anotherPkg.MyFunc2(info, myList);
anotherPkg.MyFunc3(info, myList);
return CollectionUtils.isEmpty(myList);
}
}
public class anotherPkg {
public static boolean MyFunc2(MyInfo info, List<MyObj> myList) {
if(info.version < 2) {
myList.add(new MyObj('wrong version'));
return false;
}
return true;
}
}
MyFunc1(), MyFunc2() are used only in 1 place, and will only be used in this place. When i pass list as argument into myFunc2, it's like the classic call by reference. Not using global variable for myFunc1().
From immutability's point of view, what're are the concerns for this code ?
You are mutating the list referenced by myList in MyFunc2, therefore, your code is not immutable, therefore, it doesn't make sense to look at concerns "from immutability's point of view".

How to write test case for the given method [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I want to write a test case for the given method
private String productCode;
public PaymentManager() {
this.productCode = "SMART-TV;
}
#Override
public boolean isResponsibleFor(TransactionDetailResource resource) {
return productCode.equals(resource.getProductCode());
}
How to write test case for this method
First, create a test class and a test function
#Test
public void testIsResponsibleFor() {
...
}
(If you are using Eclipse, you can press Ctrl+J, It will automatically create the test class for you)
Then in your test function you must create your two objects, one PaymentManager and one TransactionDetailResource.
PaymentManager p = PaymentManager();
TransactionDetailResource t = TransactionDetailResource();
t.setProductCode("SMART-TV")
I have assumed you got a Setter in your TransactionDetailResource class.
AssertThat(p.isResponsibleFor(t),is(Boolean.True))
This is a partial answer but It can gives you a starting point

commons-beanutils: if set method return is this model, can't get writeMethod [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
private long payActualMoney;
public long getPayActualMoney() {
return this.payActualMoney;
}
public TAllocate setPayActualMoney(long payActualMoney) {
this.payActualMoney = payActualMoney;
setPayActualMoneyIsSet(true);
return this;
}
PropertyUtils.getPropertyDescriptors not return payActualMoney 's writeMethod,and return an property 'setPayActualMoney'
That is because your setter return type isn't void.

Categories

Resources