graphql.scalars.alias.AliasedScalar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-extended-scalars Show documentation
Show all versions of graphql-java-extended-scalars Show documentation
A library fo extended scalars for graphql-java
package graphql.scalars.alias;
import graphql.Assert;
import graphql.Internal;
import graphql.language.Value;
import graphql.schema.Coercing;
import graphql.schema.CoercingParseLiteralException;
import graphql.schema.CoercingParseValueException;
import graphql.schema.CoercingSerializeException;
import graphql.schema.GraphQLScalarType;
import java.util.Map;
/**
* Access this via {@link graphql.scalars.ExtendedScalars#newAliasedScalar(String)}
*/
@Internal
public final class AliasedScalar {
private AliasedScalar() {}
/**
* A builder for {@link graphql.scalars.alias.AliasedScalar}
*/
public static class Builder {
private String name;
private String description;
private GraphQLScalarType aliasedScalar;
/**
* Sets the name of the aliased scalar
*
* @param name the name of the aliased scalar
*
* @return this builder
*/
public Builder name(String name) {
this.name = name;
return this;
}
/**
* Sets the description of the aliased scalar
*
* @param description the description of the aliased scalar
*
* @return this builder
*/
public Builder description(String description) {
this.description = description;
return this;
}
/**
* Sets the scalar that is to be aliased
*
* @param aliasedScalar the scalar that is to be aliased
*
* @return this builder
*/
public Builder aliasedScalar(GraphQLScalarType aliasedScalar) {
this.aliasedScalar = aliasedScalar;
return this;
}
/**
* @return the built {@link AliasedScalar}
*/
public GraphQLScalarType build() {
Assert.assertNotNull(name);
return aliasedScalarImpl(name, description, aliasedScalar);
}
}
private static GraphQLScalarType aliasedScalarImpl(String name, String description, GraphQLScalarType aliasedScalar) {
Assert.assertNotNull(aliasedScalar);
Coercing