Example usage for java.util Objects equals

List of usage examples for java.util Objects equals

Introduction

In this page you can find the example usage for java.util Objects equals.

Prototype

public static boolean equals(Object a, Object b) 

Source Link

Document

Returns true if the arguments are equal to each other and false otherwise.

Usage

From source file:fr.mycellar.domain.wine.Format.java

@Override
protected boolean dataEquals(IdentifiedEntity other) {
    Format format = (Format) other;
    return Objects.equals(getName(), format.getName());
}

From source file:cz.muni.fi.dndtroopsapi.dto.TroopCreateDTO.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//from ww  w . jav a 2 s.  c  om
    if (!(obj instanceof TroopCreateDTO)) {
        return false;
    }
    final TroopCreateDTO other = (TroopCreateDTO) obj;

    if (this.name == null) {
        if (other.getName() != null) {
            return false;
        }
    }
    if (!name.equals(other.getName())) {
        return false;
    }

    if (this.money == null) {
        if (other.getMoney() != null) {
            return false;
        }
    }

    if (other.getMoney() == null) {
        if (this.money != null) {
            return false;
        }
    }
    if (!(this.money.compareTo(other.getMoney()) == 0)) {
        return false;
    }

    if (this.mission == null) {
        if (other.getMission() != null) {
            return false;
        }
    }
    if (!Objects.equals(this.mission, other.getMission())) {
        return false;
    }
    return true;
}

From source file:cool.pandora.modeller.ui.handlers.iiif.PatchListHandler.java

private static Map<String, List<String>> getPageResourcesMap(final ArrayList<String> listsList,
        final ArrayList<String> resourcesList) {
    final Map<String, List<String>> pageResourcesMap = new HashMap<>();
    for (final String list : listsList) {
        final ArrayList<String> rl = new ArrayList<>();
        for (final String resource : resourcesList) {
            final String var1 = substringAfter(list, "list/");
            final String var2 = leftPad(substringBefore(substringAfter(resource, "word/"), "_"), 3, "0");
            if (Objects.equals(var1, var2)) {
                rl.add(resource);//  w  w w.ja  v a 2  s  .  c o  m
            }
        }
        pageResourcesMap.put(list, rl);
    }
    return pageResourcesMap;
}

From source file:com.inkubator.sms.gateway.service.impl.NotificationUserMessagesListener.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 50, rollbackFor = Exception.class)
public void onMessage(Message message) {
    try {/*from  www.j av  a2 s  .c o  m*/
        TextMessage textMessage = (TextMessage) message;
        String json = textMessage.getText();
        PasswordHistory passwordHistory = (PasswordHistory) jsonConverter.getClassFromJson(json,
                PasswordHistory.class);
        passwordHistory.setPassword(AESUtil.getAESDescription(passwordHistory.getPassword(),
                SMSGATEWAY.KEYVALUE, SMSGATEWAY.AES_ALGO));
        if (Objects.equals(passwordHistory.getEmailNotification(),
                SMSGATEWAY.EMAIL_NOTIFICATION_NOT_YET_SEND)) {
            VelocityTempalteModel vtm = new VelocityTempalteModel();
            List<String> toSend = new ArrayList<>();
            List<String> toSentCC = new ArrayList<String>();
            vtm.setFrom(ownerEmail);
            toSend.add(passwordHistory.getEmailAddress());
            vtm.setTo(toSend.toArray(new String[toSend.size()]));
            vtm.setCc(toSentCC.toArray(new String[toSentCC.size()]));
            vtm.setBcc(toSentCC.toArray(new String[toSentCC.size()]));
            vtm.setSubject("User Notification");
            Map maptoSend = new HashMap();
            if (passwordHistory.getLocalId().equals("en")) {
                vtm.setTemplatePath("email_user_confirmation_en.vm");
                //                    if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_UPDATE)) {
                //                        maptoSend.put("headerInfo", "Your password in OPTIMA HR has been updated. <br/>");
                //                    }
                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_NEW)) {
                    maptoSend.put("headerInfo", "Your account in OPTIMA HR already created.<br/>");
                }

                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_RESET)) {
                    maptoSend.put("headerInfo", "Your Password in OPTIMA HR has been reset. <br/>");
                }
            }
            System.out.println(" suksesss");
            if (passwordHistory.getLocalId().equals("in")) {
                vtm.setTemplatePath("email_user_confirmation.vm");
                //                    if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_UPDATE)) {
                //                        maptoSend.put("headerInfo", "Password Anda pada Aplikasi OPTIMA HR berhasil diubah. <br/>");
                //                    }
                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_NEW)) {
                    maptoSend.put("headerInfo", "Anda telah terdaftar di Aplikasi OPTIMA HR <br/>");
                }

                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_RESET)) {
                    maptoSend.put("headerInfo",
                            "Password Anda pada Aplikasi OPTIMA HR berhasil direset. <br/>");
                }
            }
            Gson gson = new GsonBuilder().create();
            TypeToken<List<String>> token = new TypeToken<List<String>>() {
            };
            List<String> dataRole = gson.fromJson(passwordHistory.getListRole(), token.getType());
            maptoSend.put("role", dataRole);
            maptoSend.put("user", passwordHistory);
            maptoSend.put("ownerAdministrator", ownerAdministrator);
            maptoSend.put("ownerCompany", ownerCompany);
            maptoSend.put("applicationUrl", applicationUrl);
            maptoSend.put("applicationName", applicationName);
            try {
                velocityTemplateSender.sendMail(vtm, maptoSend);
            } catch (Exception ex) {
                LOGGER.error("Error", ex);
            }
            passwordHistory.setEmailNotification(1);
            passwordHistory.setPassword(HashingUtils.getHashSHA256(passwordHistory.getPassword()));
            this.passwordHistoryDao.update(passwordHistory);
            System.out.println(" suksesss");
        }
    } catch (Exception ex) {
        LOGGER.error("Error", ex);
    }
}

From source file:th.co.geniustree.intenship.advisor.model.SelectCategory.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }/*  ww  w  .jav a  2  s  .c o m*/
    if (getClass() != obj.getClass()) {
        return false;
    }
    final SelectCategory other = (SelectCategory) obj;
    if (!Objects.equals(this.id, other.id)) {
        return false;
    }
    return true;
}

From source file:com.spotify.styx.docker.KubernetesPodEventTranslator.java

private static Optional<Integer> getExitCodeIfValid(String workflowInstance, Pod pod, ContainerStatus status,
        Stats stats) {/*from  ww  w. ja va2s  .  com*/
    final ContainerStateTerminated terminated = status.getState().getTerminated();

    // Check termination log exit code, if available
    if ("true".equals(pod.getMetadata().getAnnotations().get(DOCKER_TERMINATION_LOGGING_ANNOTATION))) {
        if (terminated.getMessage() == null) {
            LOG.warn("Missing termination log message for workflow instance {} container {}", workflowInstance,
                    status.getContainerID());
            stats.terminationLogMissing();
        } else {
            try {
                // TODO: handle multiple termination log messages
                final TerminationLogMessage message = Json.deserialize(
                        ByteString.encodeUtf8(terminated.getMessage()), TerminationLogMessage.class);

                if (!Objects.equals(message.exitCode, terminated.getExitCode())) {
                    LOG.warn(
                            "Exit code mismatch for workflow instance {} container {}. Container exit code: {}. "
                                    + "Termination log exit code: {}",
                            workflowInstance, status.getContainerID(), terminated.getExitCode(),
                            message.exitCode);
                    stats.exitCodeMismatch();
                }

                if (terminated.getExitCode() != null && message.exitCode == 0) {
                    // If we have a non-zero container exit code but a zero termination log exit code,
                    // return the container exit code to indicate failure. This guards against jobs that
                    // incorrectly write a successful exit code to the termination log _before_ running
                    // the actual job, which then fails. We could then still incorrectly get a zero exit
                    // code from docker, but there is not a lot we can do about that.
                    return Optional.of(terminated.getExitCode());
                } else {
                    return Optional.of(message.exitCode);
                }
            } catch (IOException e) {
                stats.terminationLogInvalid();
                LOG.warn("Unexpected termination log message for workflow instance {} container {}",
                        workflowInstance, status.getContainerID(), e);
            }
        }

        // If there's no termination log exit code, fall back to k8s exit code if it is not zero.
        // Rationale: It is important for users to be able to get the exit code of the container to be
        // able to debug failures, but at the same time we must be careful about using the use the k8s
        // exit code when checking whether the execution was successful as dockerd some times returns
        // incorrect exit codes.
        // TODO: consider separating execution status and debugging info in the "terminate" event.
        if (terminated.getExitCode() != null && terminated.getExitCode() != 0) {
            return Optional.of(terminated.getExitCode());
        } else {
            return Optional.empty();
        }
    }

    // No termination log expected, use k8s exit code
    if (terminated.getExitCode() == null) {
        LOG.warn("Missing exit code for workflow instance {} container {}", workflowInstance,
                status.getContainerID());
        return Optional.empty();
    } else {
        return Optional.of(terminated.getExitCode());
    }
}

From source file:eu.eubrazilcc.lvl.storage.security.PermissionHistory.java

@Override
public boolean equals(final Object obj) {
    if (obj == null || !(obj instanceof PermissionHistory)) {
        return false;
    }/*from  w  ww  .ja  v a 2s. com*/
    final PermissionHistory other = PermissionHistory.class.cast(obj);
    return Objects.equals(history, other.history);
}

From source file:com.teradata.benchto.service.model.Measurement.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }/*ww w.j  a v  a  2 s  . co m*/
    if (o == null || getClass() != o.getClass()) {
        return false;
    }
    Measurement that = (Measurement) o;
    return Objects.equals(name, that.name);
}

From source file:com.github.horrorho.inflatabledonkey.args.Arg.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }//from   www .  ja v  a  2  s  .  co m
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final Arg other = (Arg) obj;
    if (!Objects.equals(this.option, other.option)) {
        return false;
    }
    if (!Objects.equals(this.mapper, other.mapper)) {
        return false;
    }
    if (this.property != other.property) {
        return false;
    }
    return true;
}

From source file:eu.eubrazilcc.lvl.storage.SequenceKey.java

@Override
public boolean equals(final Object obj) {
    if (obj == null || !(obj instanceof SequenceKey)) {
        return false;
    }//from w  ww. j a  v a2  s . co m
    final SequenceKey other = SequenceKey.class.cast(obj);
    return Objects.equals(dataSource, other.dataSource) && Objects.equals(accession, other.accession);
}