Tabnine Logo
Component
Code IndexAdd Tabnine to your IDE (free)

How to use
Component
in
org.grouplens.grapht

Best Java code snippets using org.grouplens.grapht.Component (Showing top 20 results out of 315)

origin: lenskit/lenskit

  public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) {
    Component label = node.getLabel();
    if (!label.getSatisfaction().hasInstance()) {
      Satisfaction instanceSat = Satisfactions.nullOfType(label.getSatisfaction().getErasedType());
      Component newLbl = Component.create(instanceSat,
                        label.getCachePolicy());
      // build new node with replacement label
      DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLbl);
      // retain all non-transient edges
      for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) {
        if (!GraphtUtils.edgeIsTransient(edge)) {
          bld.addEdge(edge.getTail(), edge.getLabel());
        }
      }
      DAGNode<Component,Dependency> repl = bld.build();
      logger.debug("simulating instantiation of {}", node);
      return repl;
    } else {
      return node;
    }
  }
}
origin: lenskit/lenskit

Component label = node.getLabel();
if (label.getSatisfaction().hasInstance()) {
  logger.trace("node {} shareable because it has an instance", node);
  return true;
if (label.getCachePolicy() == CachePolicy.NEW_INSTANCE) {
  logger.trace("node {} not shareable because it has a new-instance cache policy", node);
  return false;
Class<?> type = label.getSatisfaction().getErasedType();
logger.trace("node {} has satisfaction type {}", node, type);
if (type.getAnnotation(Shareable.class) != null) {
return label.getSatisfaction().visit(new AbstractSatisfactionVisitor<Boolean>() {
  @Override
  public Boolean visitDefault() {
origin: lenskit/lenskit

private Visitor(DAGNode<Component, Dependency> nd, String id) {
  currentNode = nd;
  nodeId = id;
  if (currentNode == null) {
    throw new IllegalStateException("dumper not running");
  }
  Component csat = currentNode.getLabel();
  assert csat != null;
  satisfaction = csat.getSatisfaction();
}
origin: org.grouplens.grapht/grapht

public Component makeSatisfaction() {
  return Component.create(satisfaction, policy);
}
origin: org.grouplens.grapht/grapht

if (current.node.getLabel().equals(ROOT_SATISFACTION)) {
  Pair<DAGNode<Component, Dependency>, Dependency> rootNode =
      resolveFully(desire, current.context, deferralQueue);
  Satisfaction sat = parent.getLabel().getSatisfaction();
  for (Desire d: sat.getDependencies()) {
    logger.debug("Attempting to resolve deferred dependency {} of {}", d, sat);
origin: org.grouplens.grapht/grapht

/**
 * Create a new Component wrapping the given satisfaction and cache policy.  The injector is
 * responsible for using the satisfaction to implement this component consistent with its
 * cache policy.
 *
 * @param satisfaction The satisfaction to wrap
 * @param policy       The policy used with this satisfaction
 * @throws NullPointerException the satisfaction or policy is null
 */
public static Component create(Satisfaction satisfaction, CachePolicy policy) {
  return new Component(satisfaction, policy);
}
origin: lenskit/lenskit

/**
 * Get the placeholder nodes from a graph.
 *
 * @param graph The graph.
 * @return The set of nodes that have placeholder satisfactions.
 */
public static Set<DAGNode<Component, Dependency>> getPlaceholderNodes(DAGNode<Component,Dependency> graph) {
  return graph.getReachableNodes()
        .stream()
        .filter(n -> n.getLabel().getSatisfaction() instanceof PlaceholderSatisfaction)
        .collect(Collectors.toSet());
}
origin: lenskit/lenskit

  @Override
  public void describe(DAGNode<Component, Dependency> node, DescriptionWriter description) {
    node.getLabel().getSatisfaction().visit(new LabelDescriptionVisitor(description));
    description.putField("cachePolicy", node.getLabel().getCachePolicy().name());
    List<DAGNode<Component, Dependency>> edges =
        node.getOutgoingEdges()
        .stream()
        .sorted(GraphtUtils.DEP_EDGE_ORDER)
        .map(DAGEdge::getTail)
        .collect(Collectors.toList());
    description.putList("dependencies", edges, INSTANCE);
  }
}
origin: lenskit/lenskit

  public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) {
    Component label = node.getLabel();
    Satisfaction satisfaction = label.getSatisfaction();
    if (satisfaction.hasInstance()) {
      return node;
    }
    Object obj = instantiator.apply(node);

    Satisfaction instanceSat;
    if (obj == null) {
      instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType());
    } else {
      instanceSat = Satisfactions.instance(obj);
    }
    Component newLabel = Component.create(instanceSat, label.getCachePolicy());
    // build new node with replacement label
    DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLabel);
    // retain all non-transient edges
    for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) {
      if (!GraphtUtils.edgeIsTransient(edge)) {
        bld.addEdge(edge.getTail(), edge.getLabel());
      }
    }
    return bld.build();
  }
}
origin: lenskit/lenskit

@Nullable
private Optional<Object> getDiskCachedObject(Path file, DAGNode<Component,Dependency> node) {
  if (file != null && Files.exists(file)) {
    logger.debug("reading object for {} from cache (key {})",
           node.getLabel().getSatisfaction(), key);
    Object obj = readCompressedObject(file, node.getLabel().getSatisfaction().getErasedType());
    logger.debug("read object {} from key {}", obj, key);
    return Optional.fromNullable(obj);
  } else {
    return null;
  }
}
origin: org.lenskit/lenskit-core

Component label = node.getLabel();
if (label.getSatisfaction().hasInstance()) {
  logger.trace("node {} shareable because it has an instance", node);
  return true;
if (label.getCachePolicy() == CachePolicy.NEW_INSTANCE) {
  logger.trace("node {} not shareable because it has a new-instance cache policy", node);
  return false;
Class<?> type = label.getSatisfaction().getErasedType();
logger.trace("node {} has satisfaction type {}", node, type);
if (type.getAnnotation(Shareable.class) != null) {
return label.getSatisfaction().visit(new AbstractSatisfactionVisitor<Boolean>() {
  @Override
  public Boolean visitDefault() {
origin: lenskit/lenskit

Satisfaction satisfaction = label.getSatisfaction();
if (satisfaction.hasInstance()) {
  return node;
  instanceSat = Satisfactions.instance(obj);
Component newLabel = Component.create(instanceSat, label.getCachePolicy());
origin: lenskit/lenskit

/**
 * Check a graph for placeholder satisfactions.
 *
 * @param graph The graph to check.
 * @throws RecommenderConfigurationException if the graph has a placeholder satisfaction.
 */
public static void checkForPlaceholders(DAGNode<Component, Dependency> graph, Logger logger) throws RecommenderConfigurationException {
  Set<DAGNode<Component, Dependency>> placeholders = getPlaceholderNodes(graph);
  Satisfaction sat = null;
  for (DAGNode<Component,Dependency> node: placeholders) {
    Component csat = node.getLabel();
    // special-case DAOs for non-checking
    if (DataAccessObject.class.isAssignableFrom(csat.getSatisfaction().getErasedType())) {
      logger.debug("found DAO placeholder {}", csat.getSatisfaction());
    } else {
      // all other placeholders are bad
      if (sat == null) {
        sat = csat.getSatisfaction();
      }
      logger.error("placeholder {} not removed", csat.getSatisfaction());
    }
  }
  if (sat != null) {
    throw new RecommenderConfigurationException("placeholder " + sat + " not removed");
  }
}
origin: org.grouplens.lenskit/lenskit-eval

  @Override
  public void describe(DAGNode<Component, Dependency> node, DescriptionWriter description) {
    node.getLabel().getSatisfaction().visit(new LabelDescriptionVisitor(description));
    description.putField("cachePolicy", node.getLabel().getCachePolicy().name());
    List<DAGNode<Component, Dependency>> edges =
        Lists.transform(GraphtUtils.DEP_EDGE_ORDER.sortedCopy(node.getOutgoingEdges()),
                DAGEdge.<Component,Dependency>extractTail());
    description.putList("dependencies", edges, INSTANCE);
  }
}
origin: org.lenskit/lenskit-core

  public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) {
    Component label = node.getLabel();
    if (!label.getSatisfaction().hasInstance()) {
      Satisfaction instanceSat = Satisfactions.nullOfType(label.getSatisfaction().getErasedType());
      Component newLbl = Component.create(instanceSat,
                        label.getCachePolicy());
      // build new node with replacement label
      DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLbl);
      // retain all non-transient edges
      for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) {
        if (!GraphtUtils.edgeIsTransient(edge)) {
          bld.addEdge(edge.getTail(), edge.getLabel());
        }
      }
      DAGNode<Component,Dependency> repl = bld.build();
      logger.debug("simulating instantiation of {}", node);
      return repl;
    } else {
      return node;
    }
  }
}
origin: lenskit/lenskit

Component csat = node.getLabel();
assert csat != null;
Satisfaction sat = csat.getSatisfaction();
try {
  tgt = sat.visit(new Visitor(node, id));
origin: org.grouplens.grapht/grapht

Map<Desire, Instantiator> depMap = makeDependencyMap(node, backEdges);
Instantiator raw = node.getLabel().getSatisfaction().makeInstantiator(depMap);
CachePolicy policy = node.getLabel().getCachePolicy();
if (policy.equals(CachePolicy.NO_PREFERENCE)) {
  policy = defaultCachePolicy;
origin: org.lenskit/lenskit-core

  public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) {
    Component label = node.getLabel();
    Satisfaction satisfaction = label.getSatisfaction();
    if (satisfaction.hasInstance()) {
      return node;
    }
    Object obj = instantiator.apply(node);

    Satisfaction instanceSat;
    if (obj == null) {
      instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType());
    } else {
      instanceSat = Satisfactions.instance(obj);
    }
    Component newLabel = Component.create(instanceSat, label.getCachePolicy());
    // build new node with replacement label
    DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLabel);
    // retain all non-transient edges
    for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) {
      if (!GraphtUtils.edgeIsTransient(edge)) {
        bld.addEdge(edge.getTail(), edge.getLabel());
      }
    }
    return bld.build();
  }
}
origin: lenskit/lenskit

/**
 * Get the component of a particular type, if one is already instantiated.  This is useful to extract pre-built
 * models from serialized recommender engines, for example.
 * @param type The required component type.
 * @param <T> The required component type.
 * @return The component instance, or {@code null} if no instance can be retreived (either because no such
 * component is configured, or it is not yet instantiated).
 */
@Nullable
public <T> T getComponent(Class<T> type) {
  DAGNode<Component, Dependency> node = GraphtUtils.findSatisfyingNode(graph, Qualifiers.matchDefault(), type);
  if (node == null) {
    return null;
  }
  Satisfaction sat = node.getLabel().getSatisfaction();
  if (sat instanceof InstanceSatisfaction) {
    return type.cast(((InstanceSatisfaction) sat).getInstance());
  } else {
    return null;
  }
}
origin: org.grouplens.lenskit/lenskit-eval

Satisfaction satisfaction = label.getSatisfaction();
if (satisfaction.hasInstance()) {
  return node;
  instanceSat = Satisfactions.instance(obj);
Component newLabel = Component.create(instanceSat, label.getCachePolicy());
org.grouplens.graphtComponent

Javadoc

A component to be instantiated in the final dependency plan. A component consists of a Satisfaction and related information for instantiating it (such as the CachePolicy).

Most used methods

  • create
    Create a new Component wrapping the given satisfaction and cache policy. The injector is responsible
  • getCachePolicy
  • getSatisfaction
  • <init>
  • equals

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • setRequestProperty (URLConnection)
  • getSystemService (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • JFrame (javax.swing)
  • JTextField (javax.swing)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now