PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/pkg/ParamRelation.java

http://mobicents.googlecode.com/
Java | 108 lines | 85 code | 23 blank | 0 comment | 2 complexity | 4f2f59394eeb13e930565d49f3474b74 MD5 | raw file
  1package javax.megaco.pkg;
  2
  3import java.io.Serializable;
  4
  5public class ParamRelation implements Serializable {
  6
  7	private int relation_type;
  8
  9	public static final int M_SET = 1;
 10	public static final int M_SUBLIST = 2;
 11	public static final int M_RANGE = 3;
 12	public static final int M_EQUAL = 4;
 13	public static final int M_NOT_EQUAL = 5;
 14	public static final int M_GREATER = 6;
 15	public static final int M_LESS = 7;
 16
 17	public static final ParamRelation SET = new ParamRelation(M_SET);
 18	public static final ParamRelation SUBLIST = new ParamRelation(M_SUBLIST);
 19	public static final ParamRelation RANGE = new ParamRelation(M_RANGE);
 20	public static final ParamRelation EQUAL = new ParamRelation(M_EQUAL);
 21	public static final ParamRelation NOT_EQUAL = new ParamRelation(M_NOT_EQUAL);
 22	public static final ParamRelation GREATER = new ParamRelation(M_GREATER);
 23	public static final ParamRelation LESS = new ParamRelation(M_LESS);
 24
 25	private ParamRelation(int relation_type) {
 26		this.relation_type = relation_type;
 27	}
 28
 29	public int getParamRelation() {
 30		return this.relation_type;
 31	}
 32
 33	public static final ParamRelation getObject(int value) throws IllegalArgumentException {
 34		ParamRelation p = null;
 35		switch (value) {
 36		case (M_SET):
 37			p = SET;
 38			break;
 39
 40		case (M_SUBLIST):
 41			p = SUBLIST;
 42			break;
 43
 44		case (M_RANGE):
 45			p = RANGE;
 46			break;
 47
 48		case (M_EQUAL):
 49			p = EQUAL;
 50			break;
 51
 52		case (M_NOT_EQUAL):
 53			p = NOT_EQUAL;
 54			break;
 55
 56		case (M_GREATER):
 57			p = GREATER;
 58			break;
 59
 60		case (M_LESS):
 61			p = LESS;
 62		default:
 63			throw new IllegalArgumentException("There is no ParamRelation for passed value = " + value);
 64		}
 65		return p;
 66	}
 67
 68	private Object readResolve() {
 69		return this.getObject(this.relation_type);
 70	}
 71
 72	@Override
 73	public String toString() {
 74		String p = null;
 75		switch (this.relation_type) {
 76		case (M_SET):
 77			p = "ParamRelation[SET]";
 78			break;
 79
 80		case (M_SUBLIST):
 81			p = "ParamRelation[SUBLIST]";
 82			break;
 83
 84		case (M_RANGE):
 85			p = "ParamRelation[RANGE]";
 86			break;
 87
 88		case (M_EQUAL):
 89			p = "ParamRelation[EQUAL]";
 90			break;
 91
 92		case (M_NOT_EQUAL):
 93			p = "ParamRelation[NOT_EQUAL]";
 94			break;
 95
 96		case (M_GREATER):
 97			p = "ParamRelation[GREATER]";
 98			break;
 99
100		case (M_LESS):
101			p = "ParamRelation[LESS]";
102		default:
103			p = "ParamRelation[" + this.relation_type + "]";
104		}
105		return p;
106	}
107
108}