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

com.obsidiandynamics.blackstrom.manifold.Manifold Maven / Gradle / Ivy

The newest version!
package com.obsidiandynamics.blackstrom.manifold;

import java.util.*;

import com.obsidiandynamics.blackstrom.*;
import com.obsidiandynamics.blackstrom.factor.*;
import com.obsidiandynamics.blackstrom.handler.*;
import com.obsidiandynamics.blackstrom.ledger.*;

public final class Manifold implements Disposable {
  private final Ledger ledger;
  
  private final Set factors;
  
  Manifold(Ledger ledger, Set factors) {
    this.ledger = ledger;
    this.factors = factors;
    
    final InitContext context = new DefaultInitContext(ledger);
    factors.forEach(f -> f.init(context));
    
    factors.forEach(f -> ledger.attach(new MessageHandlerAdapter(f)));
    ledger.init();
  }
  
  public Ledger getLedger() {
    return ledger;
  }
  
  public Set getFactors() {
    return Collections.unmodifiableSet(factors);
  }

  @Override
  public void dispose() {
    ledger.dispose();
    factors.forEach(Disposable::dispose);
  }
  
  public static ManifoldBuilder builder() {
    return new ManifoldBuilder();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy