All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.inject.name.NamedImpl Maven / Gradle / Ivy

package com.google.inject.name;

import java.lang.annotation.Annotation;

import static com.google.common.base.Preconditions.checkNotNull;
import com.google.inject.internal.Annotations;

class NamedImpl implements Named {

    private final String value;

    public NamedImpl(String value) {
        this.value = checkNotNull(value, "name");
    }

    @Override
    public String value() {
        return this.value;
    }

    @Override
    public int hashCode() {
        // This is specified in java.lang.Annotation.
        return (127 * "value".hashCode()) ^ value.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Named)) {
            return false;
        }

        Named other = (Named) o;
        return value.equals(other.value());
    }

    @Override
    public Class annotationType() {
        return Named.class;
    }

    @Override
    public String toString() {
        return "@" + Named.class.getName() + "(value=" +  Annotations.memberValueString(value) + ")";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy