1 8 14 package jfun.yan; 15 16 import java.beans.IntrospectionException ; 17 import java.util.Map ; 18 19 import jfun.yan.factory.Factory; 20 import jfun.yan.factory.Pool; 21 22 23 53 public abstract class Component<T> implements Creator<T>, Typeful, Stateful{ 54 61 public Object getState() { 62 return null; 63 } 64 69 public Component<T> withState(Object obj){ 70 return Components.withState(this, obj); 71 } 72 79 public abstract Class getType(); 80 81 88 public Component<T> singleton(){ 89 return Components.singleton(this); 90 } 91 101 public Component<T> singleton(Pool scope){ 102 return Components.singleton(this, scope); 103 } 104 115 public <F> Component<F> factory(Class <F> factory_type, ClassLoader loader, 116 String toString){ 117 return Components.factory(this, factory_type, loader, toString); 118 } 119 129 public <F> Component<F> factory(Class <F> factory_type, String toString){ 130 return Components.factory(this, factory_type, toString); 131 } 132 141 public <F> Component<F> factory(Class <F> factory_type){ 142 return factory(factory_type, factory_type.getName()); 143 } 144 152 public Component<Factory<T>> factory(String toString){ 153 return Components.factory(this, toString); 154 } 155 163 public Component<Factory<T>> factory(){ 164 return factory("factory"); 165 } 166 171 public Component<T> guard(){ 172 return Components.guard(this); 173 } 174 181 public Component withArgument(int i, 182 Creator factory){ 183 return Components.withArgument(this, i, factory); 184 } 185 192 public Component<T> withArgument(int i, 193 Part part){ 194 return Components.withArgument(this, i, part); 195 } 196 205 206 public Component<T> withArguments(Creator... factories){ 207 return Components.withArguments(this, factories); 208 } 209 218 public Component<T> bindArguments(ParameterBinder binder){ 219 return Components.bindArguments(this, binder); 220 } 221 229 public Component<T> bindArgument(int k, ParameterBinder binder){ 230 return Components.bindArgument(this, k, binder); 231 } 232 238 public Component<T> withArguments(Part part){ 239 return Components.withArguments(this, part); 240 } 241 249 public Component<T> withProperty(Object k, Creator factory){ 250 return Components.withProperty(this, k, factory); 251 } 252 259 public Component<T> withProperty(Object k, Part p){ 260 return Components.withProperty(this, k, p); 261 } 262 276 public Component<T> withProperties(Map props){ 277 return Components.withProperties(this, props); 278 } 279 289 public Component<T> withProperties(String [] keys, Creator[] creators){ 290 return Components.withProperties(this, keys, creators); 291 } 292 301 public Component<T> bindProperties(PropertyBinder binder){ 302 return Components.bindProperties(this, binder); 303 } 304 312 public Component<T> bindProperty(Object k, PropertyBinder binder){ 313 return Components.bindProperty(this, k, binder); 314 } 315 321 public Component<T> withProperties(Part p){ 322 return Components.withProperties(this, p); 323 } 324 332 public <Super> Component<Super> subsume(Class <Super> type){ 333 return Components.subsume((Component)this, type); 334 } 335 345 public <X> Component<X> cast(Class <X> type){ 346 return Components.cast(this, type); 347 } 348 355 public Component proxy(Class ... itfs){ 356 return Components.proxy(this, itfs); 357 } 358 365 public <I> Component<I> proxy(Class <I> itf){ 366 return Components.proxy(this, itf); 367 } 368 376 public Component proxy(){ 377 return Components.proxy(this); 378 } 379 386 public <To> Component<To> map(jfun.yan.Map<T,To> m){ 387 return Monad.map(this, m); 388 } 389 396 public Component<T> mutate(Mutation<T> m){ 397 return Components.mutate(this, m); 398 } 399 406 public Component<T> incomplete(){ 407 return Components.incomplete(this); 408 } 409 410 416 public Component<T> label(Object lbl){ 417 return Components.label(this, lbl); 418 } 419 426 public Component<T> label(){ 427 return label(this); 428 } 429 430 436 public Component<T> ignoreProperty(Object key){ 437 return withProperty(key, Components.useDefault()); 438 } 439 440 441 448 public Component<T> optionalProperty(Object key){ 449 return Components.optionalProperty(this, key); 450 } 451 455 public Component<T> optionalProperties(){ 456 return Components.optionalProperties(this); 457 } 458 465 public Component<T> optionalParameter(int ind){ 466 return Components.optionalParameter(this, ind); 467 } 468 472 public Component<T> optionalParameters(){ 473 return Components.optionalParameters(this); 474 } 475 483 public Component<T> withDefaultProperty(Object key, Creator def){ 484 return Components.withDefaultProperty(this, key, def); 485 } 486 494 public Component<T> withDefaultArgument(int ind, Creator def){ 495 return Components.withDefaultArgument(this, ind, def); 496 } 497 498 503 public Component<T> optional(){ 504 return Monad.mplus(this, Components.useDefault()); 505 } 506 512 public Component<T> option(T val){ 513 return Monad.mplus(this, Components.value(val)); 514 } 515 521 public Component<T> recover(Recovery<T> r){ 522 return Monad.recover(this, r); 523 } 524 539 public <To> Component<To> bind(Binder<T,To> binder){ 540 return Monad.bind(this, binder); 541 } 542 560 public <To> Component<To> bind(ComponentBinder<T,To> binder){ 561 return Monad.bind(this, binder); 562 } 563 569 public <R> Component<R> ifelse(Component<R> yes, Component<R> no){ 570 return Monad.ifelse((Component<Boolean >)this, yes, no); 571 } 572 587 public Component<T> followedBy(ComponentBinder<T,?> binder){ 588 return Monad.followedBy(this, binder); 589 } 590 602 public Component<T> followedBy(Binder<T, ?> binder){ 603 return Monad.followedBy(this, binder); 604 } 605 616 public Component<T> followedBy(Creator<?> c2){ 617 return Monad.followedBy(this, c2); 618 } 619 620 627 public <R> Component<R> seq(Creator<R> c2){ 628 return Monad.seq(this, c2); 629 } 630 642 public Component<T> fromProperties(Object ... keys){ 643 return Components.fromProperties(this, keys); 644 } 645 658 public Component<T> fromArguments(Object ... keys){ 659 return Components.fromArguments(this, keys); 660 } 661 662 672 public Component<T> seal(){ 673 return Components.seal(this); 674 } 675 696 public Component<T> bean() 697 throws java.beans.IntrospectionException { 698 return Components.bean(this); 699 } 700 726 public Component<T> bean(String ... props) 727 throws java.beans.IntrospectionException , IllegalPropertyNameException, 728 NonWritablePropertyException, IllegalArgumentException { 729 return Components.bean(this, props); 730 } 731 756 public Component<T> bean(java.util.Set props) 757 throws java.beans.IntrospectionException , 758 IllegalPropertyNameException, NonWritablePropertyException{ 759 return Components.bean(this, props); 760 } 761 769 public Component method(final java.lang.reflect.Method mtd){ 770 return Components.bindMethod(this, mtd); 771 } 772 786 public Component method(final String name) 787 throws IllegalArgumentException { 788 return method(name, false); 789 } 790 805 public Component method(final String name, boolean suppress_security) 806 throws IllegalArgumentException { 807 return Components.bindMethod(this, name, suppress_security); 808 } 809 810 816 public Component field(final java.lang.reflect.Field fld){ 817 return Components.bindField(this, fld); 818 } 819 831 public Component field(String name) 832 throws IllegalArgumentException { 833 return field(name, false); 834 } 835 848 public Component field(final String name, boolean suppress_security) 849 throws IllegalArgumentException { 850 return Components.bindField(this, name, suppress_security); 851 } 852 853 869 public Component method(final String name, final Class ... param_types) 870 throws IllegalArgumentException { 871 return method(name, param_types, false); 872 } 873 890 public Component method(final String name, final Class [] param_types, 891 boolean suppress_security) 892 throws IllegalArgumentException { 893 return Components.bindMethod(this, name, param_types, suppress_security); 894 } 895 902 public Component getter(String name) 903 throws IntrospectionException { 904 return Components.bindGetter(this, name); 905 } 906 915 public Component<T> setter(String name) 916 throws IntrospectionException { 917 return Components.bindSetter(this, name); 918 } 919 927 public Component getter(String name, final int ind) 928 throws IntrospectionException { 929 return Components.bindGetter(this, name, ind); 930 } 931 941 public Component<T> setter(String name, int ind) 942 throws IntrospectionException { 943 return Components.bindSetter(this, name, ind); 944 } 945 951 public Component<T> repeat(int times){ 952 return Components.repeat(this, times); 953 } 954 959 public Component<T> synchronize(){ 960 return Components.synchronizedComponent(this); 961 } 962 } 963 | Popular Tags |