- Timestamp:
- 06/30/13 12:48:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/ParamBuilder.java
r87 r88 4 4 import com.framsticks.params.annotations.ParamAnnotation; 5 5 import com.framsticks.params.types.*; 6 import com.framsticks.util.Builder; 6 7 import com.framsticks.util.FramsticksException; 7 8 import com.framsticks.util.lang.Strings; … … 23 24 24 25 @FramsClassAnnotation(name = "prop", id = "prop") 25 public class ParamBuilder {26 public class ParamBuilder implements Builder<Param> { 26 27 private final static Logger log = Logger.getLogger(ParamBuilder.class.getName()); 27 28 … … 63 64 private Object def; 64 65 66 private Integer extra; 67 65 68 String containedTypeName; 69 70 protected Class<?> storageType; 66 71 67 72 protected FramsClassBuilder classBuilder; … … 83 88 * @return the min 84 89 */ 90 @ParamAnnotation 85 91 public Object getMin() { 86 92 return min; … … 90 96 * @return the max 91 97 */ 98 @ParamAnnotation 92 99 public Object getMax() { 93 100 return max; … … 97 104 * @return the def 98 105 */ 106 @ParamAnnotation 99 107 public Object getDef() { 100 108 return def; … … 135 143 public Param finish() { 136 144 try { 145 if (paramType == null) { 146 throw new FramsticksException().msg("trying to finish incomplete param"); 147 } 148 137 149 return paramType.getConstructor(ParamBuilder.class).newInstance(this); 138 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {150 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | FramsticksException e) { 139 151 throw new FramsticksException().msg("failed to create param").cause(e).arg("name", name); 140 152 } … … 219 231 public ParamBuilder type(String type) { 220 232 // typeString = type; 233 assert type != null; 221 234 222 235 log.trace("parsing type: " + type); … … 352 365 } 353 366 367 @ParamAnnotation(id = "xtra") 368 public Integer getExtra() { 369 return extra; 370 } 371 354 372 /** 355 373 * @return the paramType … … 359 377 } 360 378 379 @ParamAnnotation(id = "xtra") 380 public ParamBuilder extra(Integer extra) { 381 this.extra = extra; 382 return this; 383 } 384 385 @ParamAnnotation 361 386 public ParamBuilder min(Object min) { 362 387 this.min = min; … … 364 389 } 365 390 391 @ParamAnnotation 366 392 public ParamBuilder max(Object max) { 367 393 this.max = max; … … 369 395 } 370 396 397 @ParamAnnotation 371 398 public ParamBuilder def(Object def) { 372 399 this.def = def; … … 374 401 } 375 402 376 // public Class<?> getStorageType() {377 // assert param != null;378 // return param.getStorageType();379 // }380 403 381 404 public Param build(String line) throws Exception { … … 435 458 } 436 459 437 public ParamBuilder defaultDef(Object def) {460 public ParamBuilder fillDef(Object def) { 438 461 if (this.def == null) { 439 462 return def(def); … … 442 465 } 443 466 467 public ParamBuilder fillStorageType(Class<?> storageType) { 468 if (this.storageType == null) { 469 this.storageType = storageType; 470 } 471 return this; 472 } 473 474 475 public Class<?> getStorageType() { 476 return storageType; 477 } 444 478 } 479
Note: See TracChangeset
for help on using the changeset viewer.