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

graphql.schema.idl.SchemaPrinterComparatorEnvironment Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
package graphql.schema.idl;

import graphql.Assert;
import graphql.PublicApi;
import graphql.schema.GraphQLType;

import java.util.function.Consumer;

/**
 * Defines the scope to control where the registered {@code Comparator} can be applied.
 * 

* {@code elementType}s can be ordered within its {@code parentType} to restrict the {@code Comparator}s scope of operation. * Otherwise supplying only the {@code elementType} results in the {@code Comparator} being reused across all matching {@code GraphQLType}s regardless of parent. */ @PublicApi public class SchemaPrinterComparatorEnvironment { private Class parentType; private Class elementType; private SchemaPrinterComparatorEnvironment(Class parentType, Class elementType) { Assert.assertNotNull(elementType, "elementType can't be null"); this.parentType = parentType; this.elementType = elementType; } /** * @return The parent type or {@code null} if not supplied. */ public Class getParentType() { return parentType; } /** * @return The valid element type. */ public Class getElementType() { return elementType; } /** * This helps you transform the current {@code SchemaPrinterComparatorEnvironment} into another one by starting a builder with all * the current values and allows you to transform it how you want. * * @param builderConsumer the consumer code that will be given a builder to transform. * @return a new object based on calling build on that builder. */ public SchemaPrinterComparatorEnvironment transform(Consumer builderConsumer) { Builder builder = newEnvironment(this); builderConsumer.accept(builder); return builder.build(); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SchemaPrinterComparatorEnvironment that = (SchemaPrinterComparatorEnvironment) o; if (parentType != null ? !parentType.equals(that.parentType) : that.parentType != null) { return false; } return elementType.equals(that.elementType); } @Override public int hashCode() { int result = parentType != null ? parentType.hashCode() : 0; result = 31 * result + elementType.hashCode(); return result; } public static Builder newEnvironment() { return new Builder(); } public static Builder newEnvironment(SchemaPrinterComparatorEnvironment existing) { return new Builder(existing); } public static class Builder { private Class parentType; private Class elementType; public Builder() { } public Builder(SchemaPrinterComparatorEnvironment existing) { this.parentType = existing.parentType; this.elementType = existing.elementType; } public Builder parentType(Class parentType) { this.parentType = parentType; return this; } public Builder elementType(Class elementType) { this.elementType = elementType; return this; } public SchemaPrinterComparatorEnvironment build() { return new SchemaPrinterComparatorEnvironment(parentType, elementType); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy