Example usage for java.util HashSet hashCode

List of usage examples for java.util HashSet hashCode

Introduction

In this page you can find the example usage for java.util HashSet hashCode.

Prototype

int hashCode();

Source Link

Document

Returns the hash code value for this set.

Usage

From source file:org.dataconservancy.packaging.tool.model.dprofile.DomainProfile.java

/**
 * Generates a hashcode for the DomainProfile NodeTypes are excluded from the hashcode to eliminate recursive issues.
 * Note: Lists are converted to HashSets to make them order independent.
 * @return The hashcode of this DomainProfile object.
 *///from w  w  w .j av  a  2  s  .  c om
@Override
public int hashCode() {
    HashSet<PropertyType> propertyTypeSet = null;
    if (prop_types != null) {
        propertyTypeSet = new HashSet<>();
        propertyTypeSet.addAll(prop_types);
    }

    HashSet<PropertyCategory> propertyCategorySet = null;
    if (prop_categories != null) {
        propertyCategorySet = new HashSet<>();
        propertyCategorySet.addAll(prop_categories);
    }

    HashSet<NodeTransform> nodeTransformSet = null;
    if (node_transforms != null) {
        nodeTransformSet = new HashSet<>();
        nodeTransformSet.addAll(node_transforms);
    }

    final int prime = 31;
    int result = super.hashCode();
    result = prime * result + ((domain_id == null) ? 0 : domain_id.hashCode());
    result = prime * result + ((id == null) ? 0 : id.hashCode());
    result = prime * result + ((nodeTransformSet == null) ? 0 : nodeTransformSet.hashCode());
    result = prime * result + ((propertyCategorySet == null) ? 0 : propertyCategorySet.hashCode());
    result = prime * result + ((propertyTypeSet == null) ? 0 : propertyTypeSet.hashCode());
    return result;
}

From source file:org.dataconservancy.packaging.tool.model.dprofile.NodeType.java

/**
 * Calculates the HashCode of the NodeType.
 * Note: Lists are converted to HashSets in this method to make them order independent.
 * @return The hashcode of the NodeType.
 *///from w  w  w .ja  v a 2 s  .com
@Override
public int hashCode() {
    HashSet<URI> domainTypeSet = null;
    if (domain_types != null) {
        domainTypeSet = new HashSet<>();
        domainTypeSet.addAll(domain_types);
    }

    HashSet<NodeConstraint> parentConstraintSet = null;
    if (parent_constraints != null) {
        parentConstraintSet = new HashSet<>();
        parentConstraintSet.addAll(parent_constraints);
    }

    HashSet<PropertyConstraint> propertyConstraintSet = null;
    if (property_constraints != null) {
        propertyConstraintSet = new HashSet<>();
        propertyConstraintSet.addAll(property_constraints);
    }

    HashSet<PropertyType> inheritablePropertySet = null;
    if (inheritable_properties != null) {
        inheritablePropertySet = new HashSet<>();
        inheritablePropertySet.addAll(inheritable_properties);
    }

    HashSet<Property> defaultPropertyValueSet = null;
    if (default_property_values != null) {
        defaultPropertyValueSet = new HashSet<>();
        defaultPropertyValueSet.addAll(default_property_values);
    }

    final int prime = 31;
    int result = super.hashCode();
    result = prime * result + ((child_file_constraint == null) ? 0 : child_file_constraint.hashCode());
    result = prime * result + ((defaultPropertyValueSet == null) ? 0 : defaultPropertyValueSet.hashCode());
    result = prime * result + ((domainTypeSet == null) ? 0 : domainTypeSet.hashCode());
    result = prime * result + ((file_assoc == null) ? 0 : file_assoc.hashCode());
    result = prime * result + ((id == null) ? 0 : id.hashCode());
    result = prime * result + ((inheritablePropertySet == null) ? 0 : inheritablePropertySet.hashCode());
    result = prime * result + ((parentConstraintSet == null) ? 0 : parentConstraintSet.hashCode());
    result = prime * result
            + ((profile == null || profile.getIdentifier() == null) ? 0 : profile.getIdentifier().hashCode());
    result = prime * result + ((propertyConstraintSet == null) ? 0 : propertyConstraintSet.hashCode());
    result = prime * result + ((supplied_properties == null) ? 0 : supplied_properties.hashCode());
    result = prime * result
            + ((preferredParentType == null) ? 0 : preferredParentType.getIdentifier().hashCode());
    return result;
}