Advertisement
Guest User

Untitled

a guest
Dec 28th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. Class 1:
  2. public class Class1 implements ConfigurationSerializable {
  3.  
  4.     Class2 attribute;
  5.  
  6.     @Override
  7.     public Map<String, Object> serialize() {
  8.         Map<String, Object> result = new LinkedHashMap<>();
  9.         result.put("atr",attribute);
  10.         args.get("atr");//this is not null
  11.         return result;
  12.     }
  13.  
  14.     public static Class1 deserialize(Map<String, Object> args) {
  15.         Class1 result = new Class1();
  16.          args.get("atr"); //this is null
  17.         result.attribute = (Class2) args.get("atr");
  18.         return result;
  19.     }
  20.  
  21. }
  22.  
  23. Class 2:
  24. public class Class2 implements ConfigurationSerializable {
  25.  
  26.     String one,two,three;
  27.  
  28.     @Override
  29.     public Map<String, Object> serialize() {
  30.         Map<String, Object> result = new LinkedHashMap<>();
  31.         result.put("one",one);
  32.         result.put("two",two);
  33.         result.put("three",three);
  34.         return result;
  35.     }
  36.  
  37.     public static Class2 deserialize(Map<String, Object> args) {
  38.         Class2 result = new Class2();
  39.         result.one = (String) args.get("one");
  40.         result.two = (String) args.get("two");
  41.         result.three = (String) args.get("three");
  42.         return result;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement