Example usage for org.apache.commons.lang3.builder EqualsBuilder reflectionEquals

List of usage examples for org.apache.commons.lang3.builder EqualsBuilder reflectionEquals

Introduction

In this page you can find the example usage for org.apache.commons.lang3.builder EqualsBuilder reflectionEquals.

Prototype

public static boolean reflectionEquals(final Object lhs, final Object rhs, final boolean testTransients) 

Source Link

Document

This method uses reflection to determine if the two Objects are equal.

It uses AccessibleObject.setAccessible to gain access to private fields.

Usage

From source file:org.codemucker.jtest.bean.tester.hashcodeequals.TstBeanPropertyNotIncludedInEquals.java

@Override
public boolean equals(Object other) {
    return EqualsBuilder.reflectionEquals(this, other, new String[] { "fieldIgnore" });
}

From source file:org.eclipse.recommenders.internal.utils.codestructs.Variable.java

@Override
public boolean equals(final Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, Collections.singleton("type"));
}

From source file:org.ecloudmanager.jeecore.domain.DomainObject.java

@Override
public boolean equals(Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, getExcludeFieldNames());
}

From source file:org.ecloudmanager.service.template.VirtualMachineTemplateService.java

public String importVm(VirtualMachineTemplate src, VirtualMachineTemplate dst, ApplicationDeployment owner) {
    ObjectId id = dst.getId();//from w w w.j  a va  2s .co m
    String name = dst.getName();
    DeploymentObject parent = dst.getParent();
    cloner.copyPropertiesOfInheritedClass(src, dst);
    dst.setId(id);

    if (!StringUtils.isEmpty(name)) {
        dst.setName(name);
    }

    List<String> addedRecipes = new ArrayList<>();
    List<String> addedRenamedRecipes = new ArrayList<>();

    List<Recipe> newRunlist = new ArrayList<>();
    dst.getRunlist().stream().forEachOrdered(recipe -> {
        Recipe newRecipe = null;
        Recipe existingRecipe = recipeRepository.findByName(recipe.getName(), owner);
        if (existingRecipe != null) {
            if (EqualsBuilder.reflectionEquals(recipe, existingRecipe, ImmutableList.of("id", "owner"))) {
                newRecipe = existingRecipe;
            }
        }

        if (newRecipe == null) {
            newRecipe = cloner.deepClone(recipe);
            newRecipe.setId(new ObjectId());
            newRecipe.setOwner(owner);
            recipeService.saveWithUniqueName(newRecipe);
            if (newRecipe.getName().equals(recipe.getName())) {
                addedRecipes.add(newRecipe.getName());
            } else {
                addedRenamedRecipes.add(newRecipe.getName());
            }
        }

        newRunlist.add(newRecipe);
    });

    dst.setRunlist(newRunlist);
    dst.setParent(parent);

    StringBuilder builder = new StringBuilder();
    if (addedRecipes.size() > 0) {
        builder.append("The following recipes were imported: ").append(StringUtils.join(addedRecipes, ","));
    }
    if (addedRenamedRecipes.size() > 0) {
        builder.append("The following recipes were imported with modified names: ")
                .append(StringUtils.join(addedRenamedRecipes, ","));
    }

    return builder.toString();
}

From source file:org.force66.aws.email.collector.model.BaseType.java

@Override
public boolean equals(Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, TEST_TRANSIENTS);
}

From source file:org.jlib.basefunctions.apachecommons.service.ApacheCommonsBaseFunctionsDispatcher.java

@Override
public <Obj> Equals<Obj> genericEquals(final String... excludedFields) {
    return (object1, object2) -> EqualsBuilder.reflectionEquals(object1, object2, excludedFields);
}

From source file:org.kalypso.contribs.eclipse.core.runtime.StatusWithEquals.java

@Override
public boolean equals(final Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, false);
}

From source file:org.lenskit.specs.AbstractSpec.java

/**
 * Test this spec for equality with another spec.  This implementation uses {@link EqualsBuilder#reflectionEquals(Object, Object, boolean)},
 * with transient fields excluded.//from   w w w  .  j a  va 2  s .c  o  m
 *
 * @param o The object with which this spec should be compared.
 * @return `true` if the specs are equal.
 */
@Override
public boolean equals(Object o) {
    return EqualsBuilder.reflectionEquals(this, o, false);
}

From source file:org.plos.namedentity.api.entity.Auth.java

@Override
public boolean equals(Object o) {
    return EqualsBuilder.reflectionEquals(this, o, concat(Entity.EXCLUDED_FIELDS, Auth.EXCLUDED_FIELDS));
}

From source file:org.plos.namedentity.api.entity.Entity.java

@Override
public boolean equals(Object o) {
    return EqualsBuilder.reflectionEquals(this, o, EXCLUDED_FIELDS);
}