congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TypedKey
Code IndexAdd Tabnine to your IDE (free)

How to use
TypedKey
in
play.libs.typedmap

Best Java code snippets using play.libs.typedmap.TypedKey (Showing top 20 results out of 315)

origin: com.typesafe.play/play_2.11

/**
 * Creates a TypedKey with the given name.
 *
 * @param displayName The name to display when printing this key.
 * @param <A> The type of value this key is associated with.
 * @return A fresh key.
 */
public static <A> TypedKey<A> create(String displayName) {
  return new TypedKey<>(TypedKey$.MODULE$.apply(displayName));
}
origin: com.typesafe.play/play_2.12

/**
 * Add an attribute to the request.
 *
 * @param key The key of the attribute to add.
 * @param value The value of the attribute to add.
 * @param <T> The type of the attribute to add.
 * @return the request builder with extra attribute
 */
public <T> RequestBuilder attr(TypedKey<T> key, T value) {
  req = req.addAttr(key.asScala(), value);
  return this;
}
origin: com.github.rmannibucau/playx-servlet

@Override
public Object getAttribute(final String name) {
  return ofNullable(attributes.get(name))
      .orElseGet(() -> playDelegate.attrs().getOptional(TypedKey.create(name)).orElse(null));
}
origin: be.objectify/deadbolt-java_2.12

  @Override
  public CompletionStage<F.Tuple<Optional<? extends Subject>, Http.RequestHeader>> apply(final DeadboltHandler deadboltHandler,
                                    final Http.RequestHeader requestHeader)
  {
    if (cacheUserPerRequestEnabled)
    {
      final TypedKey<Subject> deadboltHandlerCacheId = this.typedKeyCache.computeIfAbsent(deadboltHandler.getId(), k -> TypedKey.create("deadbolt.java.cache-user." + k));
      final Optional<? extends Subject> cachedUser = requestHeader.attrs().getOptional(deadboltHandlerCacheId);
      if (cachedUser.isPresent())
      {
        return CompletableFuture.completedFuture(F.Tuple(cachedUser, requestHeader));
      }
      else
      {
        return deadboltHandler.getSubject(requestHeader).thenApply(subjectOption -> subjectOption.map(s -> F.<Optional<? extends Subject>, Http.RequestHeader>Tuple(Optional.of(s), requestHeader.addAttr(deadboltHandlerCacheId, s))).orElseGet(() -> F.Tuple(Optional.empty(), requestHeader)));
      }
    }
    return deadboltHandler.getSubject(requestHeader).thenApply(subjectOption -> subjectOption.map(s -> F.<Optional<? extends Subject>, Http.RequestHeader>Tuple(Optional.of(s), requestHeader)).orElseGet(() -> F.Tuple(Optional.empty(), requestHeader)));
  }
}
origin: com.typesafe.play/play_2.12

/**
 * Creates a TypedKey without a name.
 *
 * @param <A> The type of value this key is associated with.
 * @return A fresh key.
 */
public static <A> TypedKey<A> create() {
  return new TypedKey<>(TypedKey$.MODULE$.apply());
}
origin: com.typesafe.play/play

/**
 * Get a value from the map, throwing an exception if it is not present.
 *
 * @param key The key for the value to retrieve.
 * @param <A> The type of value to retrieve.
 * @return The value, if it is present in the map.
 * @throws java.util.NoSuchElementException If the value isn't present in the map.
 */
public <A> A get(TypedKey<A> key) {
  return underlying.apply(key.asScala());
}
origin: be.objectify/deadbolt-java_2.11

  @Override
  public CompletionStage<F.Tuple<Optional<? extends Subject>, Http.RequestHeader>> apply(final DeadboltHandler deadboltHandler,
                                    final Http.RequestHeader requestHeader)
  {
    if (cacheUserPerRequestEnabled)
    {
      final TypedKey<Subject> deadboltHandlerCacheId = this.typedKeyCache.computeIfAbsent(deadboltHandler.getId(), k -> TypedKey.create("deadbolt.java.cache-user." + k));
      final Optional<? extends Subject> cachedUser = requestHeader.attrs().getOptional(deadboltHandlerCacheId);
      if (cachedUser.isPresent())
      {
        return CompletableFuture.completedFuture(F.Tuple(cachedUser, requestHeader));
      }
      else
      {
        return deadboltHandler.getSubject(requestHeader).thenApply(subjectOption -> subjectOption.map(s -> F.<Optional<? extends Subject>, Http.RequestHeader>Tuple(Optional.of(s), requestHeader.addAttr(deadboltHandlerCacheId, s))).orElseGet(() -> F.Tuple(Optional.empty(), requestHeader)));
      }
    }
    return deadboltHandler.getSubject(requestHeader).thenApply(subjectOption -> subjectOption.map(s -> F.<Optional<? extends Subject>, Http.RequestHeader>Tuple(Optional.of(s), requestHeader)).orElseGet(() -> F.Tuple(Optional.empty(), requestHeader)));
  }
}
origin: com.typesafe.play/play

/**
 * Creates a TypedKey with the given name.
 *
 * @param displayName The name to display when printing this key.
 * @param <A> The type of value this key is associated with.
 * @return A fresh key.
 */
public static <A> TypedKey<A> create(String displayName) {
  return new TypedKey<>(TypedKey$.MODULE$.apply(displayName));
}
origin: com.typesafe.play/play_2.11

/**
 * Add an attribute to the request.
 *
 * @param key The key of the attribute to add.
 * @param value The value of the attribute to add.
 * @param <T> The type of the attribute to add.
 * @return the request builder with extra attribute
 */
public <T> RequestBuilder attr(TypedKey<T> key, T value) {
  req = req.addAttr(key.asScala(), value);
  return this;
}
origin: be.objectify/deadbolt-java_2.11

  @Override
  public CompletionStage<F.Tuple<Optional<Result>, Http.RequestHeader>> apply(final DeadboltHandler deadboltHandler,
                                     final Http.RequestHeader requestHeader,
                                     final Optional<String> content)
  {
    final CompletionStage<Optional<Result>> promise;
    if (cacheBeforeAuthCheckPerRequestEnabled)
    {
      final TypedKey<Boolean> deadboltHandlerCacheId = this.typedKeyCache.computeIfAbsent(deadboltHandler.getId(), k -> TypedKey.create("deadbolt.java.cache-before-auth-check." + k));
      if (requestHeader.attrs().containsKey(deadboltHandlerCacheId))
      {
        return CompletableFuture.completedFuture(F.Tuple(Optional.empty(), requestHeader));
      }
      else
      {
        return deadboltHandler.beforeAuthCheck(requestHeader, content)
                     .thenApply(beforeAuthCheckOption -> beforeAuthCheckOption.map(r -> F.Tuple(Optional.of(r), requestHeader)).orElse(F.Tuple(Optional.empty(), requestHeader.addAttr(deadboltHandlerCacheId, true))));
      }
    }
    return deadboltHandler.beforeAuthCheck(requestHeader, content).thenApply(beforeAuthCheckOption -> beforeAuthCheckOption.map(r -> F.Tuple(Optional.of(r), requestHeader)).orElseGet(() -> F.Tuple(Optional.empty(), requestHeader)));
  }
}
origin: com.typesafe.play/play_2.12

/**
 * Creates a TypedKey with the given name.
 *
 * @param displayName The name to display when printing this key.
 * @param <A> The type of value this key is associated with.
 * @return A fresh key.
 */
public static <A> TypedKey<A> create(String displayName) {
  return new TypedKey<>(TypedKey$.MODULE$.apply(displayName));
}
origin: com.typesafe.play/play

/**
 * Add an attribute to the request.
 *
 * @param key The key of the attribute to add.
 * @param value The value of the attribute to add.
 * @param <T> The type of the attribute to add.
 * @return the request builder with extra attribute
 */
public <T> RequestBuilder attr(TypedKey<T> key, T value) {
  req = req.addAttr(key.asScala(), value);
  return this;
}
origin: be.objectify/deadbolt-java_2.12

  @Override
  public CompletionStage<F.Tuple<Optional<Result>, Http.RequestHeader>> apply(final DeadboltHandler deadboltHandler,
                                     final Http.RequestHeader requestHeader,
                                     final Optional<String> content)
  {
    final CompletionStage<Optional<Result>> promise;
    if (cacheBeforeAuthCheckPerRequestEnabled)
    {
      final TypedKey<Boolean> deadboltHandlerCacheId = this.typedKeyCache.computeIfAbsent(deadboltHandler.getId(), k -> TypedKey.create("deadbolt.java.cache-before-auth-check." + k));
      if (requestHeader.attrs().containsKey(deadboltHandlerCacheId))
      {
        return CompletableFuture.completedFuture(F.Tuple(Optional.empty(), requestHeader));
      }
      else
      {
        return deadboltHandler.beforeAuthCheck(requestHeader, content)
                     .thenApply(beforeAuthCheckOption -> beforeAuthCheckOption.map(r -> F.Tuple(Optional.of(r), requestHeader)).orElse(F.Tuple(Optional.empty(), requestHeader.addAttr(deadboltHandlerCacheId, true))));
      }
    }
    return deadboltHandler.beforeAuthCheck(requestHeader, content).thenApply(beforeAuthCheckOption -> beforeAuthCheckOption.map(r -> F.Tuple(Optional.of(r), requestHeader)).orElseGet(() -> F.Tuple(Optional.empty(), requestHeader)));
  }
}
origin: com.typesafe.play/play

/**
 * Creates a TypedKey without a name.
 *
 * @param <A> The type of value this key is associated with.
 * @return A fresh key.
 */
public static <A> TypedKey<A> create() {
  return new TypedKey<>(TypedKey$.MODULE$.apply());
}
origin: com.typesafe.play/play_2.12

/**
 * Check if the map contains a value with the given key.
 *
 * @param key The key to check for.
 * @return True if the value is present, false otherwise.
 */
public boolean containsKey(TypedKey<?> key) {
  return underlying.contains(key.asScala());
}
origin: com.typesafe.play/play_2.11

/**
 * Creates a TypedKey without a name.
 *
 * @param <A> The type of value this key is associated with.
 * @return A fresh key.
 */
public static <A> TypedKey<A> create() {
  return new TypedKey<>(TypedKey$.MODULE$.apply());
}
origin: com.typesafe.play/play

/**
 * Check if the map contains a value with the given key.
 *
 * @param key The key to check for.
 * @return True if the value is present, false otherwise.
 */
public boolean containsKey(TypedKey<?> key) {
  return underlying.contains(key.asScala());
}
origin: com.typesafe.play/play_2.11

/**
 * @param id the id to be used
 * @return the builder instance
 */
public RequestBuilder id(Long id) {
  attr(new TypedKey<>(RequestAttrKey.Id()), id);
  return this;
}
origin: com.typesafe.play/play_2.12

/**
 * Get a value from the map, throwing an exception if it is not present.
 *
 * @param key The key for the value to retrieve.
 * @param <A> The type of value to retrieve.
 * @return The value, if it is present in the map.
 * @throws java.util.NoSuchElementException If the value isn't present in the map.
 */
public <A> A get(TypedKey<A> key) {
  return underlying.apply(key.asScala());
}
origin: com.typesafe.play/play

/**
 * @param id the id to be used
 * @return the builder instance
 */
public RequestBuilder id(Long id) {
  attr(new TypedKey<>(RequestAttrKey.Id()), id);
  return this;
}
play.libs.typedmapTypedKey

Javadoc

A TypedKey is a key that can be used to get and set values in a TypedMap or any object with typed keys. This class uses reference equality for comparisons, so each new instance is different key.

Most used methods

  • <init>
  • asScala
  • create
    Creates a TypedKey with the given name.

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setRequestProperty (URLConnection)
  • getExternalFilesDir (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • JOptionPane (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • 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