Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.jsontype;

Simple container class for types with optional logical name, used as external identifier

Author(s):
tatu
 
 public final class NamedType
    implements java.io.Serializable
    private static final long serialVersionUID = 1L;
    protected final Class<?> _class;
    protected final int _hashCode;
    protected String _name;
    
    public NamedType(Class<?> c) { this(cnull); }
    
    public NamedType(Class<?> cString name)
    {
         = c;
         = c.getName().hashCode();
        setName(name);
    }
    public Class<?> getType() { return ; }
    public String getName() { return ; }
    public void setName(String name) {
         = (name == null || name.length() == 0) ? null : name;
    }
    public boolean hasName() { return  != null; }
    
    
Equality is defined based on class only, not on name
    @Override
    public boolean equals(Object o)
    {
        if (o == thisreturn true;
        if (o == nullreturn false;
        if (o.getClass() != getClass()) return false;
        return  == ((NamedTypeo).;
    }
    @Override
    public int hashCode() { return ; }
    @Override
    public String toString() {
    	return "[NamedType, class "+.getName()+", name: "+( == null ? "null" :("'"++"'"))+"]";
    }
New to GrepCode? Check out our FAQ X