PushForm

public static class PushForm { public static List<String> PUSH_TYPE = Arrays.asList("DING", "TEXT", "ARTICLE"); public Object platform; public Object audience; public String type; public Article article; public Text text; public boolean validate() { return audience != null && !StringUtil.isEmpty(type) && PUSH_TYPE.contains(type) && (!"TEXT".equals(type) || (text != null && text.validate())) && (!"ARTICLE".equals(type) || (article != null && article.validate())); } public boolean isAudiencePushAll() { return audience.getClass().getSimpleName().equals("String") || "all".equals(this.audience); } public boolean isPlatformPushAll() { return platform == null || platform.getClass().getSimpleName().equals("String") || "all".equals(this.platform); } public Set<String> getPlatform() { try { java.util.ArrayList platform = (java.util.ArrayList) this.platform; Set<String> result = new HashSet<>(); for (Object o : platform) { result.add((String)o); } return result; } catch (Exception e) { throw new IllegalArgumentException("Invalid Parameter 'platform'"); } } public Set<String> getPushToken() { try { com.google.gson.internal.LinkedTreeMap audience = (com.google.gson.internal.LinkedTreeMap) this.audience; ArrayList push_token = (ArrayList) audience.get("push_token"); Set<String> result = new HashSet<>(); for (Object o : push_token) { result.add((String)o); } return result; } catch (Exception e) { throw new IllegalArgumentException("Invalid Parameter 'audience'"); } } public static class Text { public String ticker; public String content; public boolean validateTextLength() { return content != null && content.length() <= 70; } public boolean validate() { return !StringUtil.isEmpty(content); } } public static class Article { public String title; public String ticker; public String summary; public String cover_pic; public String link; public boolean validate() { return !StringUtil.isEmpty(title) && !StringUtil.isEmpty(link); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.