com.google.javascript.jscomp.colors.AutoOneOf_Color Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of closure-compiler-unshaded Show documentation
Show all versions of closure-compiler-unshaded Show documentation
Closure Compiler is a JavaScript optimizing compiler. It parses your
JavaScript, analyzes it, removes dead code and rewrites and minimizes
what's left. It also checks syntax, variable references, and types, and
warns about common JavaScript pitfalls. It is used in many of Google's
JavaScript apps, including Gmail, Google Web Search, Google Maps, and
Google Docs.
package com.google.javascript.jscomp.colors;
import com.google.common.collect.ImmutableCollection;
import javax.annotation.Generated;
@Generated("com.google.auto.value.processor.AutoOneOfProcessor")
final class AutoOneOf_Color {
private AutoOneOf_Color() {} // There are no instances of this type.
static Color singleton(SingletonColorFields singleton) {
singleton.getClass(); // NullPointerException if null
return new Impl_singleton(singleton);
}
static Color union(ImmutableCollection 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 Color {
@Override
SingletonColorFields singleton() {
throw new UnsupportedOperationException(kind().toString());
}
@Override
public ImmutableCollection union() {
throw new UnsupportedOperationException(kind().toString());
}
}
// Implementation when the contained property is "singleton".
private static final class Impl_singleton extends Parent_ {
private final SingletonColorFields singleton;
Impl_singleton(SingletonColorFields singleton) {
this.singleton = singleton;
}
@Override
public Color.Kind kind() {
return Color.Kind.SINGLETON;
}
@Override
public SingletonColorFields singleton() {
return singleton;
}
@Override
public String toString() {
return "Color{singleton=" + this.singleton + "}";
}
@Override
public boolean equals(Object x) {
if (x instanceof Color) {
Color that = (Color) x;
return this.kind() == that.kind()
&& this.singleton.equals(that.singleton());
} else {
return false;
}
}
@Override
public int hashCode() {
return singleton.hashCode();
}
}
// Implementation when the contained property is "union".
private static final class Impl_union extends Parent_ {
private final ImmutableCollection union;
Impl_union(ImmutableCollection union) {
this.union = union;
}
@Override
public Color.Kind kind() {
return Color.Kind.UNION;
}
@Override
public ImmutableCollection union() {
return union;
}
@Override
public String toString() {
return "Color{union=" + this.union + "}";
}
@Override
public boolean equals(Object x) {
if (x instanceof Color) {
Color that = (Color) x;
return this.kind() == that.kind()
&& this.union.equals(that.union());
} else {
return false;
}
}
@Override
public int hashCode() {
return union.hashCode();
}
}
}