Пример #1
0
 private static Vector toVector(FieldType fieldType, Object res) {
   if (res instanceof ScriptableVec) {
     ScriptableVec vec = (ScriptableVec) res;
     if (!(vec.vec() instanceof Vector)) {
       throw new IllegalStateException("Unknown object being cast to Vector: " + res);
     }
     return (Vector) vec.vec();
   }
   if (!(res instanceof List)) {
     throw new IllegalStateException("Unknown object being cast to Vector: " + res);
   }
   return VectorBuilder.build(fieldType, (List) res);
 }
Пример #2
0
 private static FieldType toVectorType(Object o) {
   if (o instanceof ScriptableVec) {
     ScriptableVec vec = (ScriptableVec) o;
     return vec.vec().getType();
   }
   if (!(o instanceof List)) {
     throw new IllegalStateException("Unknown object being cast to Vector: " + o);
   }
   List l = (List) o;
   if (l.size() == 0) {
     return FieldType.DOUBLE;
   }
   Object element = l.get(0);
   return toFieldType(element);
 }