This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.runtime.common.files;
020
021import org.apache.reef.util.BuilderUtils;
022
023/**
024 * Default POJO implementation of FileResource.
025 * Use newBuilder to construct an instance.
026 */
027public final class FileResourceImpl implements FileResource {
028  private final FileType type;
029  private final String name;
030  private final String path;
031
032  private FileResourceImpl(final Builder builder) {
033    this.type = BuilderUtils.notNull(builder.type);
034    this.name = BuilderUtils.notNull(builder.name);
035    this.path = BuilderUtils.notNull(builder.path);
036  }
037
038  @Override
039  public FileType getType() {
040    return type;
041  }
042
043  @Override
044  public String getName() {
045    return name;
046  }
047
048  @Override
049  public String getPath() {
050    return path;
051  }
052
053  @Override
054  public String toString() {
055    return String.format("FileResource: {%s:%s=%s}", this.name, this.type, this.path);
056  }
057
058  public static Builder newBuilder() {
059    return new Builder();
060  }
061
062  /**
063   * Builder used to create FileResource instances.
064   */
065  public static final class Builder implements org.apache.reef.util.Builder<FileResource> {
066    private FileType type;
067    private String name;
068    private String path;
069
070    /**
071     * @see FileResource#getType()
072     */
073    public Builder setType(final FileType type) {
074      this.type = type;
075      return this;
076    }
077
078    /**
079     * @see FileResource#getName()
080     */
081    public Builder setName(final String name) {
082      this.name = name;
083      return this;
084    }
085
086    /**
087     * @see FileResource#getPath()
088     */
089    public Builder setPath(final String path) {
090      this.path = path;
091      return this;
092    }
093
094    @Override
095    public FileResource build() {
096      return new FileResourceImpl(this);
097    }
098  }
099}