HashingStrategy Type — netty Architecture
Architecture documentation for the HashingStrategy type/interface in HashingStrategy.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 61400b4f_9ab5_045d_7009_24699f767e47["HashingStrategy"] efea1463_73f7_1807_fc33_eafc9956af81["HashingStrategy.java"] 61400b4f_9ab5_045d_7009_24699f767e47 -->|defined in| efea1463_73f7_1807_fc33_eafc9956af81 style 61400b4f_9ab5_045d_7009_24699f767e47 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/HashingStrategy.java lines 21–73
public interface HashingStrategy<T> {
/**
* Generate a hash code for {@code obj}.
* <p>
* This method must obey the same relationship that {@link java.lang.Object#hashCode()} has with
* {@link java.lang.Object#equals(Object)}:
* <ul>
* <li>Calling this method multiple times with the same {@code obj} should return the same result</li>
* <li>If {@link #equals(Object, Object)} with parameters {@code a} and {@code b} returns {@code true}
* then the return value for this method for parameters {@code a} and {@code b} must return the same result</li>
* <li>If {@link #equals(Object, Object)} with parameters {@code a} and {@code b} returns {@code false}
* then the return value for this method for parameters {@code a} and {@code b} does <strong>not</strong> have to
* return different results results. However this property is desirable.</li>
* <li>if {@code obj} is {@code null} then this method return {@code 0}</li>
* </ul>
*/
int hashCode(T obj);
/**
* Returns {@code true} if the arguments are equal to each other and {@code false} otherwise.
* This method has the following restrictions:
* <ul>
* <li><i>reflexive</i> - {@code equals(a, a)} should return true</li>
* <li><i>symmetric</i> - {@code equals(a, b)} returns {@code true} if {@code equals(b, a)} returns
* {@code true}</li>
* <li><i>transitive</i> - if {@code equals(a, b)} returns {@code true} and {@code equals(a, c)} returns
* {@code true} then {@code equals(b, c)} should also return {@code true}</li>
* <li><i>consistent</i> - {@code equals(a, b)} should return the same result when called multiple times
* assuming {@code a} and {@code b} remain unchanged relative to the comparison criteria</li>
* <li>if {@code a} and {@code b} are both {@code null} then this method returns {@code true}</li>
* <li>if {@code a} is {@code null} and {@code b} is non-{@code null}, or {@code a} is non-{@code null} and
* {@code b} is {@code null} then this method returns {@code false}</li>
* </ul>
*/
boolean equals(T a, T b);
/**
* A {@link HashingStrategy} which delegates to java's {@link Object#hashCode()}
* and {@link Object#equals(Object)}.
*/
@SuppressWarnings("rawtypes")
HashingStrategy JAVA_HASHER = new HashingStrategy() {
@Override
public int hashCode(Object obj) {
return obj != null ? obj.hashCode() : 0;
}
@Override
public boolean equals(Object a, Object b) {
return (a == b) || (a != null && a.equals(b));
}
};
}
Source
Frequently Asked Questions
What is the HashingStrategy type?
HashingStrategy is a type/interface in the netty codebase, defined in common/src/main/java/io/netty/util/HashingStrategy.java.
Where is HashingStrategy defined?
HashingStrategy is defined in common/src/main/java/io/netty/util/HashingStrategy.java at line 21.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free