A
Aryeh M. Friedman
I have the following:
package isu.db;
/**
* Create a mapping between int enums and symbolic ones (i.e. C to
Java style)
*
* @author Aryeh M. Friedman
* @version 12/19/09
*/
public interface DBEnum
{
/**
* Get the C style value of the enum
*
* @return the int (C style) version of the enum
*/
public int getValue();
}
package isu.campus;
import isu.db.DBEnum;
/**
* The type of campus we are dealing with
*
* @author Aryeh M. Friedman
* @version 12/19/09
*/
public enum CampusType implements DBEnum
{
TwoYear(0),
Trade(1),
FourYear(2),
Univeristy(3),
Seminary(4),
Acaedemy(5),
MedSchool(6),
LawSchool(7),
GradOnly(8),
PostDoc(9);
CampusType(int value)
{
this.value=value;
}
public int getValue()
{
return value;
}
private int value;
}
When we store each enum in our DB we do it as the int xxx.value for
that enum... I am looking for a non O(n) method (i.e. no need to loop
through each value looking for a match) for turning the DB field into
an in RAM enum... ideas?
package isu.db;
/**
* Create a mapping between int enums and symbolic ones (i.e. C to
Java style)
*
* @author Aryeh M. Friedman
* @version 12/19/09
*/
public interface DBEnum
{
/**
* Get the C style value of the enum
*
* @return the int (C style) version of the enum
*/
public int getValue();
}
package isu.campus;
import isu.db.DBEnum;
/**
* The type of campus we are dealing with
*
* @author Aryeh M. Friedman
* @version 12/19/09
*/
public enum CampusType implements DBEnum
{
TwoYear(0),
Trade(1),
FourYear(2),
Univeristy(3),
Seminary(4),
Acaedemy(5),
MedSchool(6),
LawSchool(7),
GradOnly(8),
PostDoc(9);
CampusType(int value)
{
this.value=value;
}
public int getValue()
{
return value;
}
private int value;
}
When we store each enum in our DB we do it as the int xxx.value for
that enum... I am looking for a non O(n) method (i.e. no need to loop
through each value looking for a match) for turning the DB field into
an in RAM enum... ideas?