Class VirtualCommandFactory

java.lang.Object
net.apartium.cocoabeans.commands.virtual.VirtualCommandFactory

@AvailableSince("0.0.39") @Experimental public class VirtualCommandFactory extends Object
Used to construct instances of VirtualCommandDefinition
See Also:
  • Constructor Details

    • VirtualCommandFactory

      public VirtualCommandFactory()
  • Method Details

    • addMetadataMapper

      public void addMetadataMapper(BiConsumer<AnnotatedElement,Map<String,Object>> mapper)
      Enrich all virtual commands created through this factory with metadata by adding it in the mapper parameter

      Example of usage:
      
       VirtualCommandFactory factory = ...;
       factory.addMetadataMapper((element, metadata) -> {
         Permission permission = element.getAnnotation(Permission.class);
         if (permission != null)
            metadata.put("permission", permission.value());
       });
       
      Parameters:
      mapper - mapping annotated element into metadata
    • create

      public VirtualCommandDefinition create(CommandNode... nodes)
      Map a command node into a virtual command
      Parameters:
      nodes - command nodes to represent
      Returns:
      a new virtual command instance
    • metaDataMap

      protected void metaDataMap(AnnotatedElement element, Map<String,Object> metadata)
    • getMetadata

      protected Map<String,Object> getMetadata(Collection<Class<?>> classes)
    • getMetadata

      protected Map<String,Object> getMetadata(Method method)
    • getVariants

      protected Set<VirtualCommandVariant> getVariants(Collection<Class<?>> classes)
    • getVariants

      protected void getVariants(Method method, Set<VirtualCommandVariant> variants)