Created
May 13, 2014 12:10
-
-
Save guodong1111/98a66e20a924583fbaca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chocolabs.chocosdk.deeplinking.pojo; | |
import java.io.Serializable; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
public class ChocoAction<P extends Enum<P>,A extends Enum<A>> implements Serializable{ | |
/** | |
* | |
*/ | |
private static final long serialVersionUID = 1L; | |
private Class<P> pageEnum; | |
private Class<A> actionEnum; | |
private String deepLinkUrl; | |
private String appName; | |
private P pageName; | |
private A action; | |
private HashMap<String,String> keyWord; | |
public ChocoAction(Class<P> pageEnum,Class<A> actionEnum) { | |
this.pageEnum = pageEnum; | |
this.actionEnum = actionEnum; | |
} | |
public String getDeepLinkUrl() { | |
return deepLinkUrl; | |
} | |
public void setDeepLinkUrl(String deepLinkUrl) { | |
this.deepLinkUrl = deepLinkUrl; | |
} | |
public String getAppName() { | |
return appName; | |
} | |
public ChocoAction<P, A> setAppName(String appName) { | |
this.appName = appName; | |
return this; | |
} | |
public P getPageName() { | |
return pageName; | |
} | |
public ChocoAction<P, A> setPageName(String pageName) { | |
try{ | |
this.pageName = Enum.<P>valueOf(pageEnum, pageName); | |
}catch(IllegalArgumentException e){ | |
} | |
return this; | |
} | |
public A getAction() { | |
return action; | |
} | |
public ChocoAction<P, A> setAction(String action) { | |
try{ | |
this.action = Enum.<A>valueOf(actionEnum, action); | |
}catch(IllegalArgumentException e){ | |
} | |
return this; | |
} | |
public HashMap<String,String> getKeyWord() { | |
return keyWord; | |
} | |
public ChocoAction<P, A> addKeyWord(String key,String value){ | |
if(keyWord==null){ | |
keyWord = new HashMap<>(); | |
} | |
keyWord.put(key, value); | |
return this; | |
} | |
public ChocoAction<P, A> setKeyWord(JSONObject jsonObject) throws JSONException { | |
keyWord = new HashMap<>(); | |
Iterator<?> iterator= jsonObject.keys(); | |
while(iterator.hasNext()){ | |
String key = (String)iterator.next(); | |
String value = jsonObject.getString(key); | |
keyWord.put(key, value); | |
} | |
return this; | |
} | |
public ChocoAction<P, A> setKeyWord(HashMap<String,String> keyWord) { | |
this.keyWord = keyWord; | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment