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.stock.Output.java

@Override
protected boolean dataEquals(IdentifiedEntity other) {
    Output output = (Output) other;/*from ww w  . j a  va2  s .  c  o  m*/
    return Objects.equals(getDate(), output.getDate()) && Objects.equals(getCellar(), output.getCellar())
            && Objects.equals(getNumber(), output.getNumber()) && Objects.equals(getPrice(), output.getPrice())
            && Objects.equals(getDestination(), output.getDestination())
            && Objects.equals(getBottle(), output.getBottle());
}

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

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

From source file:ispok.service.DomicileServiceImpl.java

@Override
public void saveDomicile(DomicileDto domicileDto) {

    logger.entry();//from www .  j a va2s.  com

    String address1 = domicileDto.getAddress1();

    List<Domicile> domicileList = genericDao.getByProperty("address1", address1, Domicile.class);

    logger.debug("Domicile list size: {}", domicileList.size());

    boolean createNew = true;
    Domicile domicile;

    Long cityId = domicileDto.getCityId();
    Long postalCodeId = domicileDto.getPostalCodeId();
    Long regionId = domicileDto.getRegionId();
    Long countryId = domicileDto.getCountryId();

    for (Domicile d : domicileList) {
        City city = d.getCity();
        PostalCode postalCode = d.getPostalCode();
        Region region = d.getRegion();
        Country country = d.getCountry();

        if ((!Objects.equals(city.getId(), cityId)) || (!Objects.equals(postalCode.getId(), postalCodeId))
                || (!Objects.equals(region.getId(), regionId))
                || (!Objects.equals(country.getId(), countryId))) {
            System.out.println("city: " + city.getId() + " , " + cityId);
            System.out.println("postal code: " + postalCode.getId() + " , " + postalCodeId);
            System.out.println("region: " + region.getId() + " , " + regionId);
            System.out.println("country: " + country.getId() + " , " + countryId);
        } else {
            logger.debug("Domicile exists");
            domicileDto.setId(d.getId());
            logger.exit();
            return;
            //                createNew = false;
            //                domicile = d;
            //                break;
        }
    }

    domicile = new Domicile();
    domicile.setAddress1(address1);
    domicile.setCity(genericDao.getById(cityId, City.class));
    domicile.setPostalCode(genericDao.getById(postalCodeId, PostalCode.class));
    domicile.setRegion(genericDao.getById(regionId, Region.class));
    domicile.setCountry(genericDao.getById(countryId, Country.class));

    domicileDto.setId(genericDao.saveOrUpdate(domicile).getId());

    logger.exit();
}

From source file:com.jivesoftware.os.upena.shared.Key.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }/*  ww  w  . j  a v  a2s.  c  o  m*/
    if (getClass() != obj.getClass()) {
        return false;
    }
    final Key<T> other = (Key<T>) obj;
    if (!Objects.equals(this.key, other.key)) {
        return false;
    }
    return true;
}

From source file:com.norconex.commons.lang.EqualsUtil.java

/**
 * Whether a source object equals ALL of the target objects
 * @param source object being tested for equality with targets
 * @param targets one or more objects to be tested with source for equality
 * @return <code>true</code> if all of the target objects are equal
 *///from  ww  w .  j  a va2  s . c  o m
public static boolean equalsAll(Object source, Object... targets) {
    if (targets == null) {
        return source == null;
    }
    for (Object object : targets) {
        if (!Objects.equals(source, object)) {
            return false;
        }
    }
    return true;
}

From source file:com.kazuki43zoo.jpetstore.component.validation.RepeatedFieldValidator.java

public boolean isValid(Object value, ConstraintValidatorContext context) {
    BeanWrapper beanWrapper = new BeanWrapperImpl(value);
    Object fieldValue = beanWrapper.getPropertyValue(field);
    Object repeatedFieldValue = beanWrapper.getPropertyValue(repeatedField);
    boolean matched = Objects.equals(fieldValue, repeatedFieldValue);
    if (matched) {
        return true;
    } else {//w  w  w.j  a v a  2 s  .co m
        context.disableDefaultConstraintViolation();
        context.buildConstraintViolationWithTemplate(message).addPropertyNode(repeatedField)
                .addConstraintViolation();
        return false;
    }
}

From source file:com.ibm.watson.catalyst.jumpqa.splitter.Splitter.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null || getClass() != obj.getClass())
        return false;
    Splitter other = (Splitter) obj;//  www.  j ava  2s  . c o  m
    if (!Objects.equals(other._p.toString(), this._p.toString()))
        return false;
    if (!Objects.equals(other._p.flags(), this._p.flags()))
        return false;
    return true;
}

From source file:sachin.spider.WebURL.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//from w w  w .  j  av a 2  s. c  o m
    if (getClass() != obj.getClass()) {
        return false;
    }
    final WebURL other = (WebURL) obj;
    if (!Objects.equals(this.url, other.url)) {
        return false;
    }
    return true;
}

From source file:net.dv8tion.jda.core.handle.UserUpdateHandler.java

@Override
protected Long handleInternally(JSONObject content) {
    SelfUserImpl self = (SelfUserImpl) api.getSelfUser();

    String name = content.getString("username");
    String discriminator = content.getString("discriminator");
    String avatarId = !content.isNull("avatar") ? content.getString("avatar") : null;
    Boolean verified = content.has("verified") ? content.getBoolean("verified") : null;
    Boolean mfaEnabled = content.has("mfa_enabled") ? content.getBoolean("mfa_enabled") : null;

    //Client only
    String email = !content.isNull("email") ? content.getString("email") : null;

    if (!Objects.equals(name, self.getName()) || !Objects.equals(discriminator, self.getDiscriminator())) {
        String oldName = self.getName();
        String oldDiscriminator = self.getDiscriminator();
        self.setName(name);//from   ww w  .j  av  a 2  s .co m
        self.setDiscriminator(discriminator);
        api.getEventManager().handle(new SelfUpdateNameEvent(api, responseNumber, oldName, oldDiscriminator));
    }
    if (!Objects.equals(avatarId, self.getAvatarId())) {
        String oldAvatarId = self.getAvatarId();
        self.setAvatarId(avatarId);
        api.getEventManager().handle(new SelfUpdateAvatarEvent(api, responseNumber, oldAvatarId));
    }
    if (verified != null && verified != self.isVerified()) {
        boolean wasVerified = self.isVerified();
        self.setVerified(verified);
        api.getEventManager().handle(new SelfUpdateVerifiedEvent(api, responseNumber, wasVerified));
    }
    if (mfaEnabled != null && mfaEnabled != self.isMfaEnabled()) {
        boolean wasMfaEnabled = self.isMfaEnabled();
        self.setMfaEnabled(mfaEnabled);
        api.getEventManager().handle(new SelfUpdateMFAEvent(api, responseNumber, wasMfaEnabled));
    }
    if (api.getAccountType() == AccountType.CLIENT && !Objects.equals(email, self.getEmail())) {
        String oldEmail = self.getEmail();
        self.setEmail(email);
        api.getEventManager().handle(new SelfUpdateEmailEvent(api, responseNumber, oldEmail));
    }

    return null;
}

From source file:com.vsct.dt.hesperides.templating.packages.TemplateUpdatedEvent.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*from   w ww . j av  a2  s  .co m*/
    if (obj == null || getClass() != obj.getClass()) {
        return false;
    }
    final TemplateUpdatedEvent other = (TemplateUpdatedEvent) obj;
    return Objects.equals(this.updated, other.updated);
}