All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.goeuro.sync4j.fs.Local Maven / Gradle / Ivy

There is a newer version: 0.14
Show newest version
package com.goeuro.sync4j.fs;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import java.net.URI;
import java.nio.file.Paths;
import java.util.Objects;

@Immutable
public class Local implements LoosePath {

    @Nonnull
    public static Local localOf(@Nonnull String plain) {
        return localOf(Paths.get(plain));
    }

    @Nonnull
    public static Local localOf(@Nonnull java.nio.file.Path delegate) {
        return new Local(delegate);
    }

    @Nonnull
    private final java.nio.file.Path delegate;

    protected Local(@Nonnull java.nio.file.Path delegate) {
        this.delegate = delegate;
    }

    @Nonnull
    public java.nio.file.Path delegate() {
        return delegate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final Local localPath = (Local) o;
        return Objects.equals(delegate(), localPath.delegate());
    }

    @Override
    @Nonnull
    public URI toUri() {
        return delegate().toUri();
    }

    @Override
    public int hashCode() {
        return Objects.hash(delegate());
    }

    @Override
    public String toString() {
        return toUri().toString();
    }

    @Override
    public int compareTo(@Nonnull LoosePath o) {
        if (!(o instanceof Local)) {
            return 1;
        }
        return delegate().compareTo(((Local) o).delegate());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy