- Timestamp:
- 09/23/13 18:54:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/Registry.java
r103 r107 8 8 import com.framsticks.util.DoubleMap; 9 9 import com.framsticks.util.FramsticksException; 10 import com.framsticks.util.lang.Casting; 10 11 import com.framsticks.util.lang.Strings; 11 12 … … 53 54 registerAndBuild(r); 54 55 } 56 57 for (String i : ParamCandidate.getAllCandidates(javaClass).getDependentClassesFromInfo()) { 58 putFramsClass(FramsClassBuilder.readFromStream(getClass().getResourceAsStream("/info/" + i + ".info"))); 59 } 55 60 return this; 56 61 } … … 76 81 try { 77 82 if (!javaClasses.containsValue(javaClass)) { 83 registerAndBuild(javaClass); 84 } 85 86 if (!javaClasses.containsValue(javaClass)) { 78 87 throw new FramsticksException().msg("java class is not registered"); 79 88 } … … 114 123 } 115 124 116 public @Nonnull Access prepareAccess(CompositeParam param) throws ConstructionException { 117 return wrapAccessWithListIfNeeded(param, createAccess(param.getContainedTypeName())); 118 } 119 120 public @Nonnull Access createAccess(@Nonnull String name) throws ConstructionException { 125 public @Nonnull Access prepareAccess(CompositeParam param, boolean force) throws ConstructionException { 126 return wrapAccessWithListIfNeeded(param, createAccess(param.getContainedTypeName(), force)); 127 } 128 129 public @Nonnull Access createAccess(@Nonnull Object object) throws ConstructionException { 130 if (object instanceof MapBasedObject) { 131 return createAccess(((MapBasedObject) object).getFramsTypeName()); 132 } 133 return createAccess(object.getClass()); 134 } 135 136 public @Nonnull Access createAccess(@Nonnull String name, boolean force) throws ConstructionException { 121 137 try { 122 138 Strings.assureNotEmpty(name); 123 139 FramsClass framsClass = getFramsClass(name); 124 140 if (framsClass == null) { 125 throw new ConstructionException().msg("framsclass is missing"); 141 if (!force) { 142 throw new ConstructionException().msg("framsclass is missing"); 143 } 144 return new FreeAccess(name); 126 145 } 127 146 … … 131 150 throw new FramsticksException().msg("failed to create access for name").arg("name", name).cause(e); 132 151 } 152 } 153 154 public @Nonnull Access createAccess(@Nonnull String name) throws ConstructionException { 155 return createAccess(name, false); 133 156 } 134 157 … … 166 189 167 190 public Access bindAccessFor(Object object) { 168 return createAccess(object.getClass()).select(object); 191 return createAccess(object).select(object); 192 } 193 194 public Registry register(ParamsPackage paramsPackage) { 195 paramsPackage.register(this); 196 return this; 197 } 198 199 public Registry registerAndBuild(ParamsPackage paramsPackage) { 200 paramsPackage.setBuild(true); 201 paramsPackage.register(this); 202 return this; 203 } 204 205 public Access bindAccessFor(Access parent, String paramName) { 206 CompositeParam childParam = Casting.throwCast(CompositeParam.class, parent.getParam(paramName)); 207 return prepareAccess(childParam, true).select(parent.get(childParam, Object.class)); 169 208 } 170 209
Note: See TracChangeset
for help on using the changeset viewer.