com.coditory.quark.context.BeanDescriptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quark-context Show documentation
Show all versions of quark-context Show documentation
Coditory Quark Configuration Library
package com.coditory.quark.context;
import java.util.Objects;
import static java.util.Objects.requireNonNull;
final class BeanDescriptor {
public static BeanDescriptor descriptor(Class type) {
return new BeanDescriptor<>(type, null);
}
public static BeanDescriptor descriptor(Class type, String name) {
return new BeanDescriptor<>(type, name);
}
private final String name;
private final Class type;
private BeanDescriptor(Class type, String name) {
this.type = requireNonNull(type);
this.name = name == null || name.isBlank() ? null : name;
}
BeanDescriptor withType(Class type) {
return new BeanDescriptor<>(type, name);
}
String getName() {
return name;
}
Class getType() {
return type;
}
@Override
public String toString() {
return "BeanDescriptor{" +
"name='" + name + '\'' +
", type=" + type +
'}';
}
String toShortString() {
return name != null
? type.getSimpleName() + ":" + name
: type.getSimpleName();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BeanDescriptor> that = (BeanDescriptor>) o;
return Objects.equals(name, that.name)
&& Objects.equals(type, that.type);
}
@Override
public int hashCode() {
return Objects.hash(name, type);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy