private Simple next(DataModelSource source) throws IOException {
   DataModelReflection next = source.next();
   if (next != null) {
     return SIMPLE.toObject(next);
   }
   return null;
 }
 /**
  * Creates a new instance.
  *
  * @param conf current configuration
  * @param definition data type
  * @param pathExpression the source path (can include wildcard)
  * @throws IOException if failed to create instance
  * @throws IllegalArgumentException if some parameters were {@code null}
  */
 @SuppressWarnings("unchecked")
 public TemporaryDataModelSource(
     Configuration conf, DataModelDefinition<?> definition, String pathExpression)
     throws IOException {
   this.conf = conf;
   this.definition = (DataModelDefinition<Object>) definition;
   this.object = definition.toObject(definition.newReflection().build());
   Path path = new Path(pathExpression);
   this.fs = path.getFileSystem(conf);
   FileStatus[] list = fs.globStatus(path);
   List<Path> paths = new ArrayList<>();
   for (int i = 0; i < list.length; i++) {
     paths.add(list[i].getPath());
   }
   this.rest = paths.iterator();
 }
 @Override
 public DataModelReflection next() throws IOException {
   while (true) {
     if (current == null) {
       if (rest.hasNext() == false) {
         return null;
       }
       current = TemporaryStorage.openInput(conf, definition.getModelClass(), rest.next());
     }
     if (current.readTo(object)) {
       break;
     } else {
       current.close();
       current = null;
     }
   }
   return definition.toReflection(object);
 }
 /**
  * Adds a property to the building object.
  *
  * @param name the property name
  * @param value the property value (nullable)
  * @return this object (for method chain)
  * @throws IllegalArgumentException if the property is not defined (on {@code check = true}), or
  *     the property value has inconsistent type, or some parameters were {@code null}
  * @throws IllegalStateException the property has been already added
  */
 public Builder<T> add(PropertyName name, Object value) {
   if (name == null) {
     throw new IllegalArgumentException("name must not be null"); // $NON-NLS-1$
   }
   if (properties.containsKey(name)) {
     throw new IllegalStateException(
         MessageFormat.format("The property \"{0}\" was already set in {1}", name, definition));
   }
   PropertyType type = definition.getType(name);
   if (type != null && value != null && type.getRepresentation().isInstance(value) == false) {
     throw new IllegalArgumentException(
         MessageFormat.format(
             "The property \"{0}\" must be type of {1}, but was {2} ({3})",
             name, type, value, definition));
   }
   properties.put(name, value);
   return this;
 }
 private DataModelReflection num(Integer number, double value) {
   Simple simple = new Simple();
   simple.number = number;
   simple.doubleValue = value;
   return SIMPLE.toReflection(simple);
 }
 private DataModelReflection datetime(Calendar dateTime) {
   Simple simple = new Simple();
   simple.datetimeValue = dateTime;
   return SIMPLE.toReflection(simple);
 }
 private DataModelReflection obj(Integer number, String text) {
   Simple simple = new Simple();
   simple.number = number;
   simple.text = text;
   return SIMPLE.toReflection(simple);
 }