예제 #1
0
 public static String matchDeclaringTypeName(JavaType sourceType) {
   Type candidateType = matchDeclaringType(sourceType);
   if (candidateType instanceof TypeNameWrapper) {
     return TypeNameWrapper.class.cast(candidateType).getTypeName();
   }
   Class rawType = ReflectUtil.getRawClass(candidateType);
   return rawType.getName();
 }
 public static AntClassLoader newAntClassLoader(
     final ClassLoader parent, final Project project, final Path path, final boolean parentFirst) {
   if (AntClassLoader.subClassToLoad != null) {
     return ReflectUtil.newInstance(
         AntClassLoader.subClassToLoad,
         AntClassLoader.CONSTRUCTOR_ARGS,
         new Object[] {parent, project, path, parentFirst});
   }
   return new AntClassLoader(parent, project, path, parentFirst);
 }
예제 #3
0
  public void read(StructureReader ins) throws IOException {
    int ncomponents = ins.readInt();
    components = new GEdge[ncomponents];
    weights = new double[ncomponents];

    for (int i = 0; i < components.length; i++) {
      weights[i] = ins.readDouble();
      String cls = ins.readString();
      components[i] = (GEdge) ReflectUtil.createObject(cls);
      ins.blockBegin();
      components[i].read(ins);
      ins.blockEnd();
    }

    attributes = Attributes.read(ins);

    nodes = LinAlg.copy(components[0].nodes);
  }
예제 #4
0
 public static boolean matchFieldMethods(Type candidate, Collection<JavaMethod> methods) {
   if (candidate instanceof TypeNameWrapper) {
     return true;
   }
   Class rawClass = ReflectUtil.getRawClass(candidate);
   JavaType candidateType = new ClassTypeProvider(rawClass).get();
   Set<String> candidateMethods = new HashSet<String>();
   for (JavaMethod method : candidateType.getMethods()) {
     candidateMethods.add(method.getName());
   }
   for (JavaMethod method : methods) {
     String methodName = method.getName();
     if (methodName.length() > 3
         && (methodName.startsWith("get") || methodName.startsWith("is"))) {
       if (!candidateMethods.contains(methodName)) {
         return false;
       }
     }
   }
   return true;
 }
예제 #5
0
 /**
  * Creates a RelFieldTrimmer.
  *
  * @param validator Validator
  */
 public RelFieldTrimmer(SqlValidator validator) {
   Util.discard(validator); // may be useful one day
   this.trimFieldsDispatcher =
       ReflectUtil.createMethodDispatcher(
           TrimResult.class, this, "trimFields", RelNode.class, BitSet.class, Set.class);
 }
예제 #6
0
 public static JavaMethod matchFirstFieldByType(Type ownerType, Type matchingType) {
   Class rawOwnerType = ReflectUtil.getRawClass(ownerType);
   JavaType javaOwnerType = new ClassTypeProvider(rawOwnerType).get();
   return matchFirstAccessorByType(javaOwnerType, matchingType);
 }
 /**
  * Creates a new FarragoReduceExpressionsRule object.
  *
  * @param relClass class of rels to which this rule should apply
  */
 private FarragoReduceExpressionsRule(Class<? extends RelNode> relClass) {
   super(
       new RelOptRuleOperand(relClass, ANY),
       "FarragoReduceExpressionsRule:" + ReflectUtil.getUnqualifiedClassName(relClass));
 }