
br.com.objectos.io.FsObject Maven / Gradle / Ivy
/*
* Copyright (C) 2011-2021 Objectos 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.io;
import br.com.objectos.lang.Lang;
import br.com.objectos.lang.ToStringObject;
import java.io.File;
import java.io.IOException;
import java.net.URI;
public abstract class FsObject implements ToStringObject {
FsObject() {}
public abstract R acceptFsObjectVisitor(FsObjectVisitor visitor, P p)
throws IOException;
@Override
public abstract boolean equals(Object obj);
public abstract boolean exists();
@Override
public final void formatToString(StringBuilder sb, int depth) {
Lang.formatToString(
sb, depth, this,
"", getPath()
);
}
public final String getPath() {
Object delegate;
delegate = getDelegate();
return delegate.toString();
}
@Override
public final int hashCode() {
Object delegate;
delegate = getDelegate();
return delegate.hashCode();
}
public boolean isDirectory() {
return false;
}
public boolean isNotFound() {
return false;
}
public boolean isRegularFile() {
return false;
}
public abstract FsObject refresh();
public Directory toDirectory() {
throw new AssertionError(
"Not a Directory instance. See isDirectory() method if necessary."
);
}
public abstract File toFile();
public NotFound toNotFound() {
throw new AssertionError(
"Not a NotFound instance. See isNotFound() method if necessary."
);
}
public RegularFile toRegularFile() {
throw new AssertionError(
"Not a RegularFile instance. See isRegularFile() method if necessary."
);
}
@Override
public final String toString() {
return Lang.toString(this);
}
public abstract URI toUri();
abstract Object getDelegate();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy