se.bjurr.violations.lib.util.Present Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of violations-lib Show documentation
Show all versions of violations-lib Show documentation
Library for parsing report files from static code analyzis.
package se.bjurr.violations.lib.util;
import static se.bjurr.violations.lib.util.Utils.checkNotNull;
import java.util.Collections;
import java.util.Set;
final class Present extends Optional {
private static final long serialVersionUID = 0;
private final T reference;
Present(T reference) {
this.reference = reference;
}
@Override
public Set asSet() {
return Collections.singleton(reference);
}
@Override
public boolean equals(Object object) {
if (object instanceof Present) {
Present> other = (Present>) object;
return reference.equals(other.reference);
}
return false;
}
@Override
public T get() {
return reference;
}
@Override
public int hashCode() {
return 0x598df91c + reference.hashCode();
}
@Override
public boolean isPresent() {
return true;
}
@Override
public T or(T defaultValue) {
checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)");
return reference;
}
@Override
public T orNull() {
return reference;
}
@Override
public String toString() {
return "Optional.of(" + reference + ")";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy