- Timestamp:
- 07/16/13 23:31:35 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/AccessOperations.java
r101 r102 10 10 11 11 import static com.framsticks.params.SetStateFlags.*; 12 import static com.framsticks.util.lang.Containers.filterInstanceof; 12 13 13 14 public final class AccessOperations { … … 74 75 } 75 76 77 public static void save(Access access, Sink sink) { 78 if (access instanceof ObjectAccess) { 79 ObjectAccess objectAccess = (ObjectAccess) access; 80 FramsClass framsClass = access.getFramsClass(); 81 assert framsClass != null; 82 sink.print(framsClass.getId()).print(":").breakLine(); 83 for (PrimitiveParam<?> p : filterInstanceof(framsClass.getParamEntries(), PrimitiveParam.class)) { 84 Object value = objectAccess.get(p, Object.class); 85 if ((value == null) || value.equals(p.getDef(Object.class))) { 86 continue; 87 } 88 sink.print(p.getId()).print(":"); 89 p.save(sink, value); 90 sink.breakLine(); 91 } 92 sink.breakLine(); 93 return; 94 95 } 96 if (access instanceof ListAccess) { 97 ListAccess listAccess = (ListAccess) access; 98 for (CompositeParam p : filterInstanceof(listAccess.getParams(), CompositeParam.class)) { 99 Object child = listAccess.get(p, Object.class); 100 //this is probably an assertion 101 assert child != null; 102 save(listAccess.getElementAccess().select(child), sink); 103 } 104 return; 105 } 106 throw new FramsticksException().msg("unknown access category").arg("access", access); 107 } 108 76 109 public static void load(Access access, Source source) { 110 if (!(access instanceof ObjectAccess)) { 111 throw new FramsticksException().msg("access is not an object access").arg("access", access); 112 } 77 113 Entry entry; 78 114 while ((entry = readEntry(source)) != null) {
Note: See TracChangeset
for help on using the changeset viewer.