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

org.jsimpledb.JEnumFieldInfo Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package org.jsimpledb;

import com.google.common.base.Converter;

import org.jsimpledb.core.EnumValue;

class JEnumFieldInfo extends JSimpleFieldInfo {

    final Class> enumType;
    final EnumConverter converter;

    @SuppressWarnings("unchecked")
    JEnumFieldInfo(JEnumField jfield, int parentStorageId) {
        super(jfield, parentStorageId);
        this.enumType = (Class>)jfield.getTypeToken().getRawType();
        this.converter = jfield.converter;
    }

    public Class> getEnumType() {
        return this.enumType;
    }

    @Override
    public Converter> getConverter(JTransaction jtx) {
        return this.converter.reverse();
    }

// Object

    @Override
    public String toString() {
        return super.toString() + " and type " + this.enumType;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this)
            return true;
        if (!super.equals(obj))
            return false;
        final JEnumFieldInfo that = (JEnumFieldInfo)obj;
        return this.enumType == that.enumType;
    }

    @Override
    public int hashCode() {
        return super.hashCode() ^ this.enumType.hashCode();
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy