Package com.opengamma.engine.view.worker

Source Code of com.opengamma.engine.view.worker.InvalidFunctionDependencyNodeFilter

/**
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.engine.view.worker;

import org.threeten.bp.Instant;

import com.opengamma.engine.depgraph.DependencyNode;
import com.opengamma.engine.depgraph.DependencyNodeFilter;
import com.opengamma.engine.function.CompiledFunctionDefinition;

/**
* Filters a dependency graph to exclude any nodes that use functions that aren't valid for the valuation time.
*/
/* package */final class InvalidFunctionDependencyNodeFilter implements DependencyNodeFilter {

  private final Instant _valuationTime;

  public InvalidFunctionDependencyNodeFilter(final Instant valuationTime) {
    _valuationTime = valuationTime;
  }

  // DependencyNodeFilter

  @Override
  public boolean accept(final DependencyNode node) {
    final CompiledFunctionDefinition cfd = node.getFunction().getFunction();
    Instant t = cfd.getEarliestInvocationTime();
    if (t != null) {
      if (_valuationTime.isBefore(t)) {
        return false;
      }
    }
    t = cfd.getLatestInvocationTime();
    if (t != null) {
      if (_valuationTime.isAfter(t)) {
        return false;
      }
    }
    return true;
  }

}
TOP

Related Classes of com.opengamma.engine.view.worker.InvalidFunctionDependencyNodeFilter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.