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:net.dv8tion.jda.core.handle.GuildUpdateHandler.java

@Override
protected Long handleInternally(JSONObject content) {
    final long id = content.getLong("id");
    if (api.getGuildLock().isLocked(id))
        return id;

    GuildImpl guild = (GuildImpl) api.getGuildMap().get(id);
    Member owner = guild.getMembersMap().get(content.getLong("owner_id"));
    String name = content.getString("name");
    String iconId = !content.isNull("icon") ? content.getString("icon") : null;
    String splashId = !content.isNull("splash") ? content.getString("splash") : null;
    Region region = Region.fromKey(content.getString("region"));
    Guild.VerificationLevel verificationLevel = Guild.VerificationLevel
            .fromKey(content.getInt("verification_level"));
    Guild.NotificationLevel notificationLevel = Guild.NotificationLevel
            .fromKey(content.getInt("default_message_notifications"));
    Guild.MFALevel mfaLevel = Guild.MFALevel.fromKey(content.getInt("mfa_level"));
    Guild.ExplicitContentLevel explicitContentLevel = Guild.ExplicitContentLevel
            .fromKey(content.getInt("explicit_content_filter"));
    Guild.Timeout afkTimeout = Guild.Timeout.fromKey(content.getInt("afk_timeout"));
    VoiceChannel afkChannel = !content.isNull("afk_channel_id")
            ? guild.getVoiceChannelMap().get(content.getLong("afk_channel_id"))
            : null;/*from w w  w.ja va  2s.  c o  m*/

    if (!Objects.equals(owner, guild.getOwner())) {
        Member oldOwner = guild.getOwner();
        guild.setOwner(owner);
        api.getEventManager().handle(new GuildUpdateOwnerEvent(api, responseNumber, guild, oldOwner));
    }
    if (!Objects.equals(name, guild.getName())) {
        String oldName = guild.getName();
        guild.setName(name);
        api.getEventManager().handle(new GuildUpdateNameEvent(api, responseNumber, guild, oldName));
    }
    if (!Objects.equals(iconId, guild.getIconId())) {
        String oldIconId = guild.getIconId();
        guild.setIconId(iconId);
        api.getEventManager().handle(new GuildUpdateIconEvent(api, responseNumber, guild, oldIconId));
    }
    if (!Objects.equals(splashId, guild.getSplashId())) {
        String oldSplashId = guild.getSplashId();
        guild.setSplashId(splashId);
        api.getEventManager().handle(new GuildUpdateSplashEvent(api, responseNumber, guild, oldSplashId));
    }
    if (!Objects.equals(region, guild.getRegion())) {
        Region oldRegion = guild.getRegion();
        guild.setRegion(region);
        api.getEventManager().handle(new GuildUpdateRegionEvent(api, responseNumber, guild, oldRegion));
    }
    if (!Objects.equals(verificationLevel, guild.getVerificationLevel())) {
        Guild.VerificationLevel oldVerificationLevel = guild.getVerificationLevel();
        guild.setVerificationLevel(verificationLevel);
        api.getEventManager().handle(
                new GuildUpdateVerificationLevelEvent(api, responseNumber, guild, oldVerificationLevel));
    }
    if (!Objects.equals(notificationLevel, guild.getDefaultNotificationLevel())) {
        Guild.NotificationLevel oldNotificationLevel = guild.getDefaultNotificationLevel();
        guild.setDefaultNotificationLevel(notificationLevel);
        api.getEventManager().handle(
                new GuildUpdateNotificationLevelEvent(api, responseNumber, guild, oldNotificationLevel));
    }
    if (!Objects.equals(mfaLevel, guild.getRequiredMFALevel())) {
        Guild.MFALevel oldMfaLevel = guild.getRequiredMFALevel();
        guild.setRequiredMFALevel(mfaLevel);
        api.getEventManager().handle(new GuildUpdateMFALevelEvent(api, responseNumber, guild, oldMfaLevel));
    }
    if (!Objects.equals(explicitContentLevel, guild.getExplicitContentLevel())) {
        Guild.ExplicitContentLevel oldExplicitContentLevel = guild.getExplicitContentLevel();
        guild.setExplicitContentLevel(explicitContentLevel);
        api.getEventManager().handle(
                new GuildUpdateExplicitContentLevelEvent(api, responseNumber, guild, oldExplicitContentLevel));
    }
    if (!Objects.equals(afkTimeout, guild.getAfkTimeout())) {
        Guild.Timeout oldAfkTimeout = guild.getAfkTimeout();
        guild.setAfkTimeout(afkTimeout);
        api.getEventManager().handle(new GuildUpdateAfkTimeoutEvent(api, responseNumber, guild, oldAfkTimeout));
    }
    if (!Objects.equals(afkChannel, guild.getAfkChannel())) {
        VoiceChannel oldAfkChannel = guild.getAfkChannel();
        guild.setAfkChannel(afkChannel);
        api.getEventManager().handle(new GuildUpdateAfkChannelEvent(api, responseNumber, guild, oldAfkChannel));
    }
    return null;
}

From source file:com.autodesk.client.model.Buckets.java

@Override
public boolean equals(java.lang.Object o) {
    if (this == o) {
        return true;
    }// ww  w . j av a2  s .c om
    if (o == null || getClass() != o.getClass()) {
        return false;
    }
    Buckets buckets = (Buckets) o;
    return Objects.equals(this.items, buckets.items) && Objects.equals(this.next, buckets.next);
}

From source file:io.curly.artifact.service.DefaultArtifactService.java

@Loggable
@Override//  www  .  j  a  v  a 2s  . c o m
@CachePut(value = { "artifacts", "singleArtifact" }, key = "#artifact.id")
public Artifact save(Artifact artifact, User user) {
    Assert.notNull(artifact, "Artifact must be not null1");
    Assert.notNull(user);
    if (artifact.getId() == null) {
        return repository.save(artifact);
    } else {
        Artifact ownedArtifact = repository.findByIdAndOwner(artifact.getId(), user.getId());
        if (ownedArtifact != null && Objects.equals(ownedArtifact.getOwner(), user.getId())) {
            return repository.save(artifact);
        }
    }
    throw new IllegalStateException("Cannot find an entity to be overridden and the id was not null ");
}

From source file:com.autodesk.client.model.Hubs.java

@Override
public boolean equals(java.lang.Object o) {
    if (this == o) {
        return true;
    }//from w w  w  . jav  a  2  s. co m
    if (o == null || getClass() != o.getClass()) {
        return false;
    }
    Hubs hubs = (Hubs) o;
    return Objects.equals(this.jsonapi, hubs.jsonapi) && Objects.equals(this.data, hubs.data);
}

From source file:net.bluemix.connectors.core.info.WatsonConversationServiceInfo.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*from w w  w. j a va  2 s .  co  m*/
    if (obj == null || getClass() != obj.getClass()) {
        return false;
    }
    final WatsonConversationServiceInfo other = (WatsonConversationServiceInfo) obj;
    if (!Objects.equals(this.username, other.username)) {
        return false;
    }
    if (!Objects.equals(this.password, other.password)) {
        return false;
    }
    if (!Objects.equals(this.url, other.url)) {
        return false;
    }
    return Objects.equals(this.id, other.id);
}

From source file:de.micromata.genome.logging.DocLogEntry.java

@Override
public boolean equals(Object other) {
    if ((other instanceof DocLogEntry) == false) {
        return false;
    }//  w  ww. j  a  v  a  2s . c om
    DocLogEntry dle = (DocLogEntry) other;
    return level.equals(dle.level) && Objects.equals(domain, dle.domain) && category.equals(dle.category);
}

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

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }//from w  ww  .  j a v a 2s.com
    if (obj == null || !(obj instanceof LogResource)) {
        return false;
    }
    final LogResource other = (LogResource) obj;
    return Objects.equals(this.id, other.id) && Objects.equals(this.type, other.type)
            && Objects.equals(this.alternateId, other.alternateId)
            && Objects.equals(this.displayName, other.displayName)
            && Objects.equals(this.detailEntry, other.detailEntry);
}

From source file:org.jam.metrics.applicationmetrics.utils.DataPoint.java

@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (o == null || getClass() != o.getClass())
        return false;
    DataPoint<?> dataPoint = (DataPoint<?>) o;
    return Objects.equals(timestamp, dataPoint.timestamp) && Objects.equals(value, dataPoint.value)
            && Objects.equals(tags, dataPoint.tags);
}

From source file:org.thevortex.lighting.jinks.robot.Effect.java

@Override
public boolean equals(Object o) {
    if (o == null)
        return false;
    if (this == o)
        return true;

    if (o instanceof Effect) {
        Effect effect = (Effect) o;/* www .ja v a2  s.c  om*/
        return Objects.equals(id, effect.id) && Objects.equals(scene, effect.scene)
                && Objects.equals(recipientId, effect.recipientId) && recipientType == effect.recipientType
                && notificationType == effect.notificationType && Objects.equals(note, effect.note);
    }
    return false;
}

From source file:com.github.horrorho.inflatabledonkey.data.CKContainer.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//from  ww  w  .  ja va  2  s. c  o  m
    if (getClass() != obj.getClass()) {
        return false;
    }
    final CKContainer other = (CKContainer) obj;
    if (!Objects.equals(this.name, other.name)) {
        return false;
    }
    if (!Objects.equals(this.env, other.env)) {
        return false;
    }
    if (!Objects.equals(this.ckDeviceUrl, other.ckDeviceUrl)) {
        return false;
    }
    if (!Objects.equals(this.url, other.url)) {
        return false;
    }
    return true;
}