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

ru.cwcode.tkach.refreshmenu.configurationUI.valueSupplier.ValueSupplierRegistry Maven / Gradle / Ivy

package ru.cwcode.tkach.refreshmenu.configurationUI.valueSupplier;

import java.util.ArrayList;
import java.util.List;

public class ValueSupplierRegistry {
  List suppliers = new ArrayList<>();
  
  public ValueSupplierRegistry() {
    register(new AnvilValueSupplier());
    register(new LocationValueSupplier());
    register(new ItemStackValueSupplier());
  }
  
  public void register(ValueSupplier valueSupplier) {
    suppliers.add(valueSupplier);
  }
  
  public ValueSupplier match(Class type) {
    for (ValueSupplier supplier : suppliers) {
      if(supplier.supports(type)) return supplier;
    }
    return null;
  }
  
  public boolean supports(Class type) {
    return match(type) != null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy