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:com.cloud.agent.api.manager.GetApiDefaultsAnswer.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }//from ww  w .  j  ava  2  s. co m

    if (!(o instanceof GetApiDefaultsAnswer)) {
        return false;
    }

    GetApiDefaultsAnswer that = (GetApiDefaultsAnswer) o;

    return super.equals(that) && Objects.equals(_apiDefaults, that._apiDefaults);
}

From source file:my.school.spring.rest.controllers.UseSchedulesCondition.java

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

    final Map<String, Object> annotationAttributes = Optional
            .ofNullable(metadata.getAnnotationAttributes(UseSchedules.class.getName())).orElse(new HashMap<>());
    Boolean isScheduledInstance = (Boolean) annotationAttributes.getOrDefault("value", false);

    Boolean allowScheduled = Optional
            .ofNullable(context.getEnvironment().getProperty("setup.versionProvider.scheduled", Boolean.class))
            .orElse(false);/*from   ww w  .ja va  2  s.  co  m*/
    final boolean scheduled = Objects.equals(allowScheduled, isScheduledInstance);
    LOG.info("Application will reuse {} implementation of the VersionProvider",
            (scheduled) ? "SCHEDULED" : "NOT SCHEDULED");
    return scheduled;
}

From source file:io.sidecar.Error.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }/*from w ww . ja  v  a  2 s . c o m*/
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    Error that = (Error) o;

    return Objects.equals(this.status, that.status) && Objects.equals(this.message, that.message);
}

From source file:com.norconex.collector.core.pipeline.ChecksumStageUtil.java

private static boolean resolveChecksum(boolean isMeta, String newChecksum, BasePipelineContext ctx,
        Object subject) {//from  www. j a v  a 2 s .c  om
    BaseCrawlData crawlData = ctx.getCrawlData();

    // Set new checksum on crawlData + metadata
    String type;
    if (isMeta) {
        crawlData.setMetaChecksum(newChecksum);
        type = "metadata";
    } else {
        crawlData.setContentChecksum(newChecksum);
        type = "document";
    }

    // Get old checksum from cache
    BaseCrawlData cachedCrawlData = ctx.getCachedCrawlData();
    String oldChecksum = null;
    if (cachedCrawlData != null) {
        if (isMeta) {
            oldChecksum = cachedCrawlData.getMetaChecksum();
        } else {
            oldChecksum = cachedCrawlData.getContentChecksum();
        }
    } else {
        LOG.debug("ACCEPTED " + type + " checkum (new): Reference=" + crawlData.getReference());
        return true;
    }

    // Compare checksums
    if (StringUtils.isNotBlank(newChecksum) && Objects.equals(newChecksum, oldChecksum)) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("REJECTED " + type + " checkum (unmodified): Reference=" + crawlData.getReference());
        }
        crawlData.setState(CrawlState.UNMODIFIED);
        ctx.fireCrawlerEvent(CrawlerEvent.REJECTED_UNMODIFIED, ctx.getCrawlData(), subject);
        return false;
    }

    crawlData.setState(CrawlState.MODIFIED);
    LOG.debug("ACCEPTED " + type + " checksum (modified): Reference=" + crawlData.getReference());
    return true;
}

From source file:it.ozimov.springboot.templating.mail.service.FreemarkerTemplateService.java

@Override
public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
        final @NonNull Map<String, Object> model) throws IOException, TemplateException {
    checkArgument(!isNullOrEmpty(templateReference.trim()), "The given template is null, empty or blank");
    checkArgument(Objects.equals(getFileExtension(templateReference), expectedTemplateExtension()),
            "Expected a Freemarker template file with extension ftl, while %s was given",
            getFileExtension(templateReference));

    try {//from   w w w . jav  a2s.  c om
        return FreeMarkerTemplateUtils.processTemplateIntoString(
                freemarkerConfiguration.getTemplate(templateReference, Charset.forName("UTF-8").name()), model);
    } catch (freemarker.template.TemplateException e) {
        throw new TemplateException(e);
    }
}

From source file:com.okta.sdk.models.log.LogDebugContext.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*w w w  .  j  a v a 2 s.c  o m*/
    if (obj == null || !(obj instanceof LogDebugContext)) {
        return false;
    }
    final LogDebugContext other = (LogDebugContext) obj;
    return Objects.equals(this.debugData, other.debugData);
}

From source file:org.graylog.plugins.pipelineprocessor.parser.errors.ParseError.java

@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (!(o instanceof ParseError))
        return false;
    ParseError that = (ParseError) o;//from ww  w .ja  va 2 s .  c  o  m
    return Objects.equals(type, that.type) && Objects.equals(ctx, that.ctx);
}

From source file:com.gs.obevo.db.api.appdata.ServerDirectory.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }// ww w.  j  ava2  s  .c  om
    if (o == null || getClass() != o.getClass()) {
        return false;
    }
    ServerDirectory that = (ServerDirectory) o;
    return Objects.equals(name, that.name) && Objects.equals(directoryPath, that.directoryPath);
}

From source file:com.haulmont.cuba.core.global.UserFormatToolsImpl.java

@Override
public String formatUser(@Nonnull User user, @Nullable User substitutedUser) {
    if (substitutedUser != null && !Objects.equals(user, substitutedUser)) {
        return formatSubstitution(user, substitutedUser);
    } else {/*from w  w  w.  j  a  v a 2  s. c o  m*/
        return formatOfficial(user);
    }
}

From source file:de.sub.goobi.forms.SpracheForm.java

/**
 * The constructor of this class loads the required MessageBundle.
 *//*from  w ww  . j av a2  s.com*/
public SpracheForm() {
    String key = ConfigCore.getParameter("language.force-default", "de");
    Locale locale = new Locale.Builder().setLanguageTag(key).build();
    if (!LocaleUtils.isAvailableLocale(locale)) {
        FacesContext context = FacesContext.getCurrentInstance();
        if (!Objects.equals(context.getViewRoot(), null)) {
            context.getViewRoot().setLocale(locale);
            context.getExternalContext().getSessionMap().put(SESSION_LOCALE_FIELD_ID, locale);
        }
    }
}