java - Enum to String Conversion -


i have class testcase. inside of have inner class test. inside class enum ownertype setters , getters of enum.

public static final class test {     public enum ownertype {         user("user"), role("role");         private final string value;         private ownertype(string value) {             this.value = value;         }         public string tovalue() {             return value;         }     }      private ownertype m_ownertype;     public ownertype getownertype() {         return m_ownertype;     }      public void setownertype(ownertype m_ownertype) {         this.m_ownertype = m_ownertype;     }      private jsonobject getjsonobject() {         jsonobject obj = new jsonobject();         obj.put(key, new jsonstring(m_ownertype.tostring())); // showing error enum string conversion          return obj;     } } 

m_ownertype ownertype enum in obj.put() doing wrong related conversion enum string.

thanks.

java enums come built-in function name() preferred way of serializing them strings.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -