com.google.javascript.jscomp.serialization.AutoOneOf_JSTypeSerializer_SimplifiedType Maven / Gradle / Ivy
package com.google.javascript.jscomp.serialization;
import com.google.common.collect.ImmutableSet;
import com.google.javascript.rhino.jstype.JSType;
import javax.annotation.Generated;
@Generated("com.google.auto.value.processor.AutoOneOfProcessor")
final class AutoOneOf_JSTypeSerializer_SimplifiedType {
private AutoOneOf_JSTypeSerializer_SimplifiedType() {} // There are no instances of this type.
static JSTypeSerializer.SimplifiedType single(JSType single) {
single.getClass(); // NullPointerException if null
return new Impl_single(single);
}
static JSTypeSerializer.SimplifiedType union(ImmutableSet union) {
union.getClass(); // NullPointerException if null
return new Impl_union(union);
}
// Parent class that each implementation will inherit from.
private abstract static class Parent_ extends JSTypeSerializer.SimplifiedType {
@Override
JSType single() {
throw new UnsupportedOperationException(getKind().toString());
}
@Override
ImmutableSet union() {
throw new UnsupportedOperationException(getKind().toString());
}
}
// Implementation when the contained property is "single".
private static final class Impl_single extends Parent_ {
private final JSType single;
Impl_single(JSType single) {
this.single = single;
}
@Override
public JSTypeSerializer.SimplifiedType.Kind getKind() {
return JSTypeSerializer.SimplifiedType.Kind.SINGLE;
}
@Override
public JSType single() {
return single;
}
@Override
public String toString() {
return "SimplifiedType{single=" + this.single + "}";
}
@Override
public boolean equals(Object x) {
if (x instanceof JSTypeSerializer.SimplifiedType) {
JSTypeSerializer.SimplifiedType that = (JSTypeSerializer.SimplifiedType) x;
return this.getKind() == that.getKind()
&& this.single.equals(that.single());
} else {
return false;
}
}
@Override
public int hashCode() {
return single.hashCode();
}
}
// Implementation when the contained property is "union".
private static final class Impl_union extends Parent_ {
private final ImmutableSet union;
Impl_union(ImmutableSet union) {
this.union = union;
}
@Override
public JSTypeSerializer.SimplifiedType.Kind getKind() {
return JSTypeSerializer.SimplifiedType.Kind.UNION;
}
@Override
public ImmutableSet union() {
return union;
}
@Override
public String toString() {
return "SimplifiedType{union=" + this.union + "}";
}
@Override
public boolean equals(Object x) {
if (x instanceof JSTypeSerializer.SimplifiedType) {
JSTypeSerializer.SimplifiedType that = (JSTypeSerializer.SimplifiedType) x;
return this.getKind() == that.getKind()
&& this.union.equals(that.union());
} else {
return false;
}
}
@Override
public int hashCode() {
return union.hashCode();
}
}
}