I have this code in which I think two types of participants, the code becomes very long and I think I can apply the FACTORY pattern, but it is not implemented, should I create a class of specific classes "ParticipantOWner" and "ParticipantNormal"?
enter the description of the image here
I want to create those classes based on that image of FACTORY PATTERNS, in the category that there are specific classes LusuryCar, SmallCar and SedanCar
public Meet createRelacion(Long idOwner, Long idUser) {
Meet currentMeet = new Meet();
Bet bet = new Bet();
bet.setInversion(100);
currentMeet.setBet(bet);
currentMeet.setState(State.start);
currentMeet.setName(Math.random() + "");
User user = userRepository.findById(idUser);
User owner = userRepository.findById(idOwner);
Bet betParticipant = new Bet();
betParticipant.setInversion(0);
/////////////////// PRIMER PARTICIPANTE/////////////////
Participant participant = new Participant(); //
participant.setRol(Rol.NORMAL); //
participant.setMeet(currentMeet); //
participant.setUser(user); //
participant.setBet(betParticipant); //
////////////////////////////////////////////////////////////
participantRepository.save(participant);
/////////////////// SEGUNDO PARTICIPANTE//////////////////
Participant participantOwner = new Participant();///
participantOwner.setMeet(currentMeet); ///
participantOwner.setRol(Rol.OWNER); ///
participantOwner.setUser(owner); ///
/////////////////////////////////////////////////////////////
participantRepository.save(participantOwner);
return currentMeet;
}
Aucun commentaire:
Enregistrer un commentaire