コード例 #1
0
ファイル: NullOkGuard.java プロジェクト: kpreid/e-on-java
 /** Matches a nullOk[x] guard made by this. */
 public Object match__get_1(Object specimen, OneArgFunc optEjector) {
   T.require(null == myOptSubGuard, "Already parameterized: ", this);
   ClassDesc kind = ClassDesc.make(NullOkGuard.class);
   NullOkGuard ofKind = (NullOkGuard) kind.coerce(specimen, optEjector);
   if (ofKind.myOptSubGuard == null) {
     throw Thrower.toEject(optEjector, "Not a parameterized nullOk");
   }
   Object[] result = {ofKind.myOptSubGuard};
   return ConstList.fromArray(result);
 }
コード例 #2
0
ファイル: NullOkGuard.java プロジェクト: kpreid/e-on-java
 /**
  * If specimen is null, returns null. Otherwise passes it to my wrapped Guard, if there is one.
  */
 public Object coerce(Object specimen, OneArgFunc optEjector) {
   // shorten first
   specimen = Ref.resolution(specimen);
   if (null == specimen) {
     return null;
   } else if (null == myOptSubGuard) {
     throw Thrower.toEject(optEjector, "must be null");
   } else {
     return myOptSubGuard.coerce(specimen, optEjector);
   }
 }