com.atlassian.plugin.descriptors
Class ModuleDescriptors.HashCodeBuilder

java.lang.Object
  extended by com.atlassian.plugin.descriptors.ModuleDescriptors.HashCodeBuilder
Enclosing class:
ModuleDescriptors

@NotThreadSafe
public static class ModuleDescriptors.HashCodeBuilder
extends Object

Assists in implementing Object.hashCode() methods for module descriptors based on the hashCode of their complete key.

The full specification of the hashCode() contract is defined by ModuleDescriptor.hashCode()

Usage:

  1. If you are using this builder to implement the hashCode() method in a module descriptor implementation:

    new ModuleDescriptors.HashCodeBuilder().descriptor(this).toHashCode();

  2. If you are using this builder to calculate the hashCode of a descriptor from outside a module descriptor implementation; given a descriptor instance desc:

    new ModuleDescriptors.EqualsBuilder().descriptor(desc).toHashCode();

Since:
2.8.0

Constructor Summary
ModuleDescriptors.HashCodeBuilder()
           
 
Method Summary
 ModuleDescriptors.HashCodeBuilder descriptor(ModuleDescriptor descriptor)
          Sets the module descriptor to create a hashCode implementation for.
 int hashCode()
          The computed hashCode from toHashCode() is returned due to the likelihood of bugs in mis-calling toHashCode() and the unlikeliness of it mattering what the hashCode for HashCodeBuilder itself is.
 int toHashCode()
          Return the computed hashCode for this module descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModuleDescriptors.HashCodeBuilder

public ModuleDescriptors.HashCodeBuilder()
Method Detail

descriptor

public ModuleDescriptors.HashCodeBuilder descriptor(ModuleDescriptor descriptor)
Sets the module descriptor to create a hashCode implementation for.

Parameters:
descriptor - the descriptor. Must not be null.
Returns:
this builder.

toHashCode

public int toHashCode()
Return the computed hashCode for this module descriptor.

Returns:
hashCode based on the hashCode of the complete key of the module descriptor.

hashCode

public int hashCode()
The computed hashCode from toHashCode() is returned due to the likelihood of bugs in mis-calling toHashCode() and the unlikeliness of it mattering what the hashCode for HashCodeBuilder itself is.

Overrides:
hashCode in class Object
Returns:
hashCode based on the complete key of the module descriptor.


Copyright © 2013 Atlassian. All Rights Reserved.