congrats Icon
New! Announcing our next generation AI code completions
Read here
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

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • getSharedPreferences (Context)
  • setContentView (Activity)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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