Interface TraitFactory

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TraitFactory
Creates traits using trait data from a model.
  • Method Details

    • createTrait

      Optional<Trait> createTrait(ShapeId id, ShapeId target, Node value)
      Creates and configures a trait using model trait data.
      Parameters:
      id - Shape ID of the trait.
      target - Shape that the trait is applied on.
      value - The Node value of the trait.
      Returns:
      Returns the created trait wrapped in an Optional.
      Throws:
      SourceException - on configuration error.
      RuntimeException - if an error occurs while creating the trait.
    • createServiceFactory

      static TraitFactory createServiceFactory(Iterable<TraitService> services)
      Creates a TraitFactory that uses a List of TraitService provider instances.
      Parameters:
      services - List of TraitService provider instances.
      Returns:
      Returns the created TraitFactory.
    • createServiceFactory

      static TraitFactory createServiceFactory()
      Creates a TraitFactory that discovers TraitService providers using the Thread context class loader.
      Returns:
      Returns the created TraitFactory.
    • createServiceFactory

      static TraitFactory createServiceFactory(ClassLoader classLoader)
      Creates a TraitFactory that discovers TraitService providers using the given ClassLoader.
      Parameters:
      classLoader - Class loader used to find TraitService providers.
      Returns:
      Returns the created TraitFactory.