Class TypeSet

All Implemented Interfaces:
IdentifiedCollection<CanonicalType>, TypeRules

public class TypeSet extends IdentifiedCollection.Base<CanonicalType> implements TypeRules
  • Field Details

    • GLOBAL_TYPE_SET

      public static final TypeSet GLOBAL_TYPE_SET

      A jvm-global type set, only use with extreme prejudice

  • Constructor Details

    • TypeSet

      public TypeSet()
    • TypeSet

      public TypeSet(TypeRegistry typeRegistry)
  • Method Details

    • addType

      public void addType(String identifier, Resource resource, ConstructionCallback<Type> builder)
    • add

      public CanonicalType add(@NonNull @NonNull String id, @NonNull @NonNull Type type) throws ObjectAlreadyExistsException
      Throws:
      ObjectAlreadyExistsException
    • getLinkedType

      public LinkedType getLinkedType(@NonNull @NonNull String id)
    • getRequired

      @Deprecated public CanonicalType getRequired(@NonNull @NonNull String id)
      Deprecated.
    • getRequired

      public CanonicalType getRequired(@NonNull @NonNull String id, ProblemSink problemSink)
    • findEquivalenceCoercer

      public Optional<Coercer> findEquivalenceCoercer(Type sourceType, Type targetType)
      Description copied from interface: TypeRules

      Search through the list of EquivalenceRules and find the first one that can safely coerce a value from the source type to the target type. This will return an object that will allow the source type to be safely converted to the target type.

      Specified by:
      findEquivalenceCoercer in interface TypeRules
      Parameters:
      sourceType - the type of the value that is being assigned to something. type
      targetType - the receiving type
      Returns:
      a Coercer, or empty if none could be found.
    • testVariance

      public Variance testVariance(Type sourceType, Type targetType)
      Description copied from interface: TypeRules

      Search through the list of VarianceRules to determine whether a value of sourceType can be assigned to a receiver of targetType

      Specified by:
      testVariance in interface TypeRules
      Parameters:
      sourceType - the type of the value that is being assigned to something.
      targetType - the receiving type
      Returns:
      a determined variance calculation, or Variance.UNKNOWN if it couldn't be determined. You should assume invariance if unknown is returned.
    • validate

      public void validate(Consumer<Problem> problemConsumer)
    • debug

      public void debug(String msg, Object... args)
      Description copied from interface: TypeRules

      Print some debug info to the TypeRules logger - this should be decorated with some extra context that helps put a particular rule checks logging more easily interpreted

      Specified by:
      debug in interface TypeRules
    • getTypeRegistry

      public TypeRegistry getTypeRegistry()