io.permazen.MethodKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of permazen-main Show documentation
Show all versions of permazen-main Show documentation
Permazen classes that map Java model classes onto the core API.
The newest version!
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen;
import java.lang.reflect.Method;
import java.util.Arrays;
/**
* Object identifying a method name, parameter types, and return type.
*/
class MethodKey {
private final String name;
private final Class>[] parameterTypes;
private final Class> returnType;
MethodKey(Method method) {
this.name = method.getName();
this.returnType = method.getReturnType();
this.parameterTypes = method.getParameterTypes();
}
@Override
public int hashCode() {
int hash = this.getClass().hashCode();
hash ^= this.name.hashCode();
for (Class> parameterType : this.parameterTypes)
hash = (hash * 31) + parameterType.hashCode();
hash ^= this.returnType.hashCode();
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj == null || obj.getClass() != this.getClass())
return false;
final MethodKey that = (MethodKey)obj;
return this.name.equals(that.name)
&& this.returnType == that.returnType
&& Arrays.equals(this.parameterTypes, that.parameterTypes);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy