
br.com.objectos.way.gdrive.AbstractGFile Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.way.gdrive;
import org.joda.time.DateTime;
import com.google.api.services.drive.model.File;
import com.google.common.base.Objects;
/**
* @author [email protected] (Marcio Endo)
*/
abstract class AbstractGFile implements GFile {
final DriveExec exec;
final File file;
private final String id;
private final MimeType mimeType;
private final DateTime createdDate;
private final DateTime modifiedDate;
public AbstractGFile(Builder builder) {
exec = builder.getExec();
file = builder.getFile();
id = file.getId();
String key = file.getMimeType();
mimeType = MimeType.get(key);
com.google.api.client.util.DateTime _createdDate = file.getCreatedDate();
createdDate = new DateTime(_createdDate.toStringRfc3339());
com.google.api.client.util.DateTime _modifiedDate = file.getModifiedDate();
modifiedDate = new DateTime(_modifiedDate.toStringRfc3339());
}
@Override
public String getId() {
return id;
}
@Override
public String getName() {
return file.getTitle();
}
@Override
public MimeType getMimeType() {
return mimeType;
}
@Override
public DateTime getCreatedDate() {
return createdDate;
}
@Override
public DateTime getModifiedDate() {
return modifiedDate;
}
@Override
public final int hashCode() {
return Objects.hashCode(id);
}
@Override
public void trash() {
exec.trash(id);
}
@Override
public void untrash() {
exec.untrash(id);
}
@Override
public final boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj == null) {
return false;
}
if (obj instanceof AbstractGFile) {
final AbstractGFile that = (AbstractGFile) obj;
return Objects.equal(this.id, that.id);
} else {
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy