Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright 2014-2015, Inc. or its affiliates. All Rights Reserved.
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
  * or in the "license" file accompanying this file. This file is distributed
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
 import java.util.Map;

Used to provide additional/supplemental material description (typically on a per-request basis and for more advanced use-case) to supplement the one stored in S3 for crypto material retrieval.
 public class ExtraMaterialsDescription {
     public static final ExtraMaterialsDescription NONE =
         new ExtraMaterialsDescription(.);

Used to resolve conflicts when merging the additional material description to the core material description.
     public static enum ConflictResolution {
Fail fast upon conflicting keys.
Take precedence upon conflicting keys.
To be overridden upon conflicting keys.
Supplemental material descriptions which are unmodifiable.
     private final Map<String,Stringextra;
Resolution behavior when there are overlapping entries. Defaults to ExtraMaterialsDescription.ConflictResolution.FAIL_FAST.
     private final ConflictResolution resolve;
     public ExtraMaterialsDescription(Map<String,Stringmatdesc) {
     public ExtraMaterialsDescription(Map<StringStringmatdesc,
             ConflictResolution resolve) {
         if (matdesc == null || resolve == null)
             throw new IllegalArgumentException();
         this. = Collections.unmodifiableMap(
             new HashMap<StringString>(matdesc));
         this. = resolve;

Returns the extra material description; never null.
     public Map<StringStringgetMaterialDescription() {
         return ;

Returns the conflict resolution strategy; neve null.
         return ;

Combine this supplemental material descriptions with those specified in the "core" parameter. This method has no side effect.

core the core material descriptions to be supplemented; assumed to be unmodifiable.
the merged material descriptions; never null. The returned map is always unmodifiable, assuming the passed in core material descriptions are unmodifiable.
java.lang.IllegalArgumentException if this supplemental material descriptions contains conflicting entries
java.lang.UnsupportedOperationException if the conflict resolution strategy is not supported
     public Map<StringStringmergeInto(Map<StringStringcore) {
         if (.size() == 0)
            return core;    // no supplemental descriptions
        if (core == null || core.size() == 0)
            return ;   // only core descriptions
        switch() {
            case : {
                final int total = core.size() + .size();
                Map<StringStringmerged = new HashMap<String,String>(core);
                if (total != merged.size()) {
                    throw new IllegalArgumentException(
                        "The supplemental material descriptions contains conflicting entries");
                return Collections.unmodifiableMap(merged);
            case : {
                Map<String,Stringmerged = new HashMap<String,String>();
                return Collections.unmodifiableMap(merged);
            case : {
                Map<String,Stringmerged = new HashMap<String,String>(core);
                return Collections.unmodifiableMap(merged);
                throw new UnsupportedOperationException();
New to GrepCode? Check out our FAQ X