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

How to use
Satisfactions
in
org.grouplens.grapht.reflect

Best Java code snippets using org.grouplens.grapht.reflect.Satisfactions (Showing top 14 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();
    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

  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: org.grouplens.grapht/grapht

if (provider != null) {
  return BindingResult.newBuilder()
            .setDesire(desire.restrict(Satisfactions.providerType(provider.value())))
            .setCachePolicy(provider.cachePolicy())
            .addFlag(BindingFlag.TERMINAL)
  if (Types.isInstantiable(impl.value())) {
    return BindingResult.newBuilder()
              .setDesire(desire.restrict(Satisfactions.type(impl.value())))
              .setCachePolicy(impl.cachePolicy())
              .build();
if (dnull != null) {
  return BindingResult.newBuilder()
            .setDesire(desire.restrict(Satisfactions.nullOfType(desire.getDesiredType())))
            .setCachePolicy(CachePolicy.NO_PREFERENCE)
            .addFlag(BindingFlag.TERMINAL)
origin: org.grouplens.grapht/grapht

@Override
public void to(@Nullable T instance) {
  if (instance == null) {
    toNull();
    return;
  } else if (!(instance instanceof Number)
        && !ClassUtils.isPrimitiveWrapper(instance.getClass())
        && !sourceType.isInstance(instance)) {
    String msg = String.format("%s is not an instance of %s",
                  instance, sourceType);
    throw new InvalidBindingException(sourceType, msg);
  }
  // Apply some type coercing if we're dealing with primitive types
  Object coerced = coerce(instance);
  Satisfaction s = Satisfactions.instance(coerced);
  BindRuleBuilder brb = startRule().setSatisfaction(s);
  generateBindings(brb, coerced.getClass());
}

origin: org.grouplens.grapht/grapht

logger.debug("found provider {} for {}", providerName, type);
Class<?> clazz = classLoader.loadClass(providerName);
Satisfaction sat = Satisfactions.providerType((Class<Provider<?>>) clazz.asSubclass(Provider.class));
if (!type.isAssignableFrom(sat.getErasedType())) {
  throw new ResolutionException(providerName + " does not provide " + type);
logger.debug("found implementation {} for {}", implName, type);
Class<?> clazz = classLoader.loadClass(implName);
Satisfaction sat = Satisfactions.type(clazz);
if (!type.isAssignableFrom(sat.getErasedType())) {
  throw new ResolutionException(providerName + " not compatible with " + type);
origin: org.grouplens.grapht/grapht

@Override
public void toProvider(@Nonnull Provider<? extends T> provider) {
  Satisfaction s = Satisfactions.providerInstance(provider);
  BindRuleBuilder brb = startRule().setSatisfaction(s);
  generateBindings(brb, Types.getProvidedType(provider));
}
origin: org.grouplens.grapht/grapht

@Override
public void toProvider(@Nonnull Class<? extends Provider<? extends T>> provider) {
  Satisfaction s = Satisfactions.providerType(provider);
  BindRuleBuilder brb = startRule().setSatisfaction(s);
  generateBindings(brb, Types.getProvidedType(provider));
}
origin: org.grouplens.grapht/grapht

@Override
public void to(@Nonnull Class<? extends T> impl, boolean chained) {
  Preconditions.isAssignable(sourceType, impl);
  if (logger.isWarnEnabled()) {
    if (Types.shouldBeInstantiable(impl)
        && !Types.isInstantiable(impl)
        && impl.getAnnotation(DefaultProvider.class) == null
        && impl.getAnnotation(DefaultImplementation.class) == null) {
      logger.warn("Concrete type {} does not have an injectable or public default constructor, but probably should", impl);
    }
  }
  
  BindRuleBuilder brb = startRule();
  if (Types.isInstantiable(impl)) {
    brb.setSatisfaction(Satisfactions.type(impl));
  } else {
    brb.setImplementation(impl);
  }
  brb.setTerminal(!chained);
  generateBindings(brb, impl);
}
origin: org.grouplens.grapht/grapht

@Override
public void toNull(Class<? extends T> type) {
  Satisfaction s = Satisfactions.nullOfType(type);
  BindRuleBuilder brb = startRule().setSatisfaction(s);
  generateBindings(brb, type);
}
origin: org.grouplens.grapht/grapht

if (dfltDouble != null) {
  bld = BindingResult.newBuilder()
            .setDesire(desire.restrict(Satisfactions.instance(dfltDouble.value())));
  bld = BindingResult.newBuilder().setDesire(desire.restrict(Satisfactions.instance(dfltInt.value())));
  bld = BindingResult.newBuilder().setDesire(desire.restrict(Satisfactions.instance(dfltBool.value())));
  bld = BindingResult.newBuilder().setDesire(desire.restrict(Satisfactions.instance(dfltStr.value())));
origin: lenskit/lenskit

  instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType());
} else {
  instanceSat = Satisfactions.instance(obj);
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: 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: org.grouplens.lenskit/lenskit-eval

  instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType());
} else {
  instanceSat = Satisfactions.instance(obj);
org.grouplens.grapht.reflectSatisfactions

Javadoc

Class to construct specific Satisfaction implementations.

Most used methods

  • instance
  • nullOfType
  • providerInstance
  • providerType
  • type

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JTextField (javax.swing)
  • Github Copilot alternatives
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