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

com.fitbur.fasterxml.jackson.databind.introspect.ObjectIdInfo Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.fasterxml.jackson.databind.introspect;

import com.fitbur.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fitbur.fasterxml.jackson.annotation.ObjectIdGenerator;

/**
 * Container object that encapsulates information usually
 * com.fitburrived from {@link JsonIdentityInfo} annotation or its
 * custom alternatives
 */
public class ObjectIdInfo
{
    protected final String _propertyName;
    protected final Class> _generator;
    protected final Class _scope;
    protected final boolean _alwaysAsId;

    public ObjectIdInfo(String prop, Class scope, Class> gen) {
        this(prop, scope, gen, false);
    }

    protected ObjectIdInfo(String prop, Class scope, Class> gen,
            boolean alwaysAsId)
    {
        _propertyName = prop;
        _scope = scope;
        _generator = gen;
        _alwaysAsId = alwaysAsId;
    }

    public ObjectIdInfo withAlwaysAsId(boolean state) {
        if (_alwaysAsId == state) {
            return this;
        }
        return new ObjectIdInfo(_propertyName, _scope, _generator, state);
    }
    
    public String getPropertyName() { return _propertyName; }
    public Class getScope() { return _scope; }
    public Class> getGeneratorType() { return _generator; }
    public boolean getAlwaysAsId() { return _alwaysAsId; }

    @Override
    public String toString() {
        return "ObjectIdInfo: propName="+_propertyName
                +", scope="+(_scope == null ? "null" : _scope.getName())
                +", generatorType="+(_generator == null ? "null" : _generator.getName())
                +", alwaysAsId="+_alwaysAsId;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy