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

org.molgenis.data.meta.system.SystemPackageRegistry Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
package org.molgenis.data.meta.system;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import org.molgenis.data.meta.SystemPackage;
import org.molgenis.data.meta.model.Package;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/** Registry containing all {@link SystemPackage}. */
@Component
public class SystemPackageRegistry {

  private static final Logger LOG = LoggerFactory.getLogger(SystemPackageRegistry.class);

  // note: a list instead of map is used since system packages might not be initialized when added
  // to the registry
  private final List systemPackages;

  public SystemPackageRegistry() {
    systemPackages = new ArrayList<>(32);
  }

  void addSystemPackage(SystemPackage systemPackage) {
    LOG.trace("Registering system package [{}] ...", systemPackage.getId());
    systemPackages.add(systemPackage);
  }

  public boolean containsPackage(Package aPackage) {
    for (SystemPackage systemPackage : systemPackages) {
      if (systemPackage.getId().equals(aPackage.getId())) return true;
    }
    return false;
  }

  Stream getSystemPackages() {
    return systemPackages.stream();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy