Java 类org.apache.commons.collections4.map.CaseInsensitiveMap 实例源码

项目:AwesomeJavaLibraryExamples    文件:ExampleNonNullCaseInsensitiveMap.java   
public static void main(String[] args)
{
   Map<String, String> map = PredicatedMap.predicatedMap(new CaseInsensitiveMap<String, String>(), NotNullPredicate.notNullPredicate(), NotNullPredicate.notNullPredicate());

   map.put("one", "A");

   System.out.println(map);
   System.out.printf("using oNe as the key to get the value from the map: %s\n", map.get("oNe"));
   System.out.println("Going to put a null key on the map");

   try
   {
      map.put(null, "B");
   }
   catch(Exception e) //I don't like that this process throws an exception.  I'd much rather it just not put a null key in.
   {
      System.out.println(e.getMessage());
   }

   //so to fix this I implemented my own using the abstractions provided by Commons Collections 4
   Map<String, String> map2 = new FilteringPredicatedMap<>();

   map2.put("one", "A");
   map2.put(null, "B");
   map2.put("three", null);
   map2.put("four", "D");

   System.out.println(map2);

   Map<String, String> map3 = new FilteringPredicatedMap<>(new TreeMap<>(), (i -> i != null && i.equals("one")), FilteringPredicatedMap.nullPredicateInstance());

   map3.put("one", "A");
   map3.put(null, "B");
   map3.put("three", null);
   map3.put("four", "D");

   System.out.println(map3);
}
项目:sherlock    文件:AbstractResultSetAdapter.java   
private Map<String, Integer> generateColumnLabelIndexMap() throws SQLException {
    ResultSetMetaData resultSetMetaData = resultSets.get(0).getMetaData();
    Map<String, Integer> result = new CaseInsensitiveMap<String, Integer>(resultSetMetaData.getColumnCount());
    for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
        result.put(resultSetMetaData.getColumnLabel(i), i);
    }
    return result;
}
项目:JDA    文件:EntityBuilder.java   
public AuditLogEntry createAuditLogEntry(GuildImpl guild, JSONObject entryJson, JSONObject userJson)
{
    final long targetId = Helpers.optLong(entryJson, "target_id", 0);
    final long id = entryJson.getLong("id");
    final int typeKey = entryJson.getInt("action_type");
    final JSONArray changes = entryJson.isNull("changes") ? null : entryJson.getJSONArray("changes");
    final JSONObject options = entryJson.isNull("options") ? null : entryJson.getJSONObject("options");
    final String reason = entryJson.optString("reason", null);

    final UserImpl user = (UserImpl) createFakeUser(userJson, false);
    final Set<AuditLogChange> changesList;
    final ActionType type = ActionType.from(typeKey);

    if (changes != null)
    {
        changesList = new HashSet<>(changes.length());
        for (int i = 0; i < changes.length(); i++)
        {
            final JSONObject object = changes.getJSONObject(i);
            AuditLogChange change = createAuditLogChange(object);
            changesList.add(change);
        }
    }
    else
    {
        changesList = Collections.emptySet();
    }

    CaseInsensitiveMap<String, AuditLogChange> changeMap = new CaseInsensitiveMap<>(changeToMap(changesList));
    CaseInsensitiveMap<String, Object> optionMap = options != null
            ? new CaseInsensitiveMap<>(options.toMap()) : null;

    return new AuditLogEntry(type, id, targetId, guild, user, reason, changeMap, optionMap);
}
项目:JDA    文件:AuditableRestAction.java   
@Override
protected CaseInsensitiveMap<String, String> finalizeHeaders()
{
    CaseInsensitiveMap<String, String> headers = super.finalizeHeaders();

    if (reason == null || reason.isEmpty())
        return headers;

    if (headers == null)
        headers = new CaseInsensitiveMap<>();

    headers.put("X-Audit-Log-Reason", uriEncode(reason));

    return headers;
}
项目:JDA    文件:Request.java   
public Request(RestAction<T> restAction, Consumer<T> onSuccess, Consumer<Throwable> onFailure, boolean shouldQueue, RequestBody body, Object rawBody, Route.CompiledRoute route, CaseInsensitiveMap<String, String> headers)
{
    this.restAction = restAction;
    this.onSuccess = onSuccess;
    this.onFailure = onFailure;
    this.shouldQueue = shouldQueue;
    this.body = body;
    this.rawBody = rawBody;
    this.route = route;
    this.headers = headers;

    this.api = (JDAImpl) restAction.getJDA();
}
项目:JDA    文件:RestAction.java   
/**
 * Submits a Request for execution.
 *
 * <p><b>This method is asynchronous</b>
 *
 * @param  success
 *         The success callback that will be called at a convenient time
 *         for the API. (can be null)
 * @param  failure
 *         The failure callback that will be called if the Request
 *         encounters an exception at its execution point.
 */
public void queue(Consumer<T> success, Consumer<Throwable> failure)
{
    Route.CompiledRoute route = finalizeRoute();
    Checks.notNull(route, "Route");
    RequestBody data = finalizeData();
    CaseInsensitiveMap<String, String> headers = finalizeHeaders();
    if (success == null)
        success = DEFAULT_SUCCESS;
    if (failure == null)
        failure = DEFAULT_FAILURE;
    api.getRequester().request(new Request<>(this, success, failure, true, data, rawData, route, headers));
}
项目:find    文件:UserConfiguration.java   
@Bean
public GrantedAuthoritiesMapper grantedAuthoritiesMapper() {
    final Map<String, String> rolesMap = new CaseInsensitiveMap<>();

    rolesMap.put(FindCommunityRole.USER.value(), FindRole.USER.toString());
    rolesMap.put(FindCommunityRole.ADMIN.value(), FindRole.ADMIN.toString());

    if (enableBi) {
        rolesMap.put(FindCommunityRole.BI.value(), FindRole.BI.toString());
    }

    return new OneToOneOrZeroSimpleAuthorityMapper(Collections.unmodifiableMap(rolesMap));
}
项目:pinenut    文件:CaseInsensitiveMapTest.java   
public static void main(String[] args) {
  Map<String, String> map = new CaseInsensitiveMap<>();

  map.put("ONE", "one");
  map.put("one", "one");

  System.out.println(map.size());
}
项目:domino-jna    文件:NotesLookupResultBufferDecoder.java   
/**
 * Converts the values to a Java {@link Map}
 * 
 * @param decodeLMBCS true to convert {@link LMBCSString} objects and lists to Java Strings
 * @return data as map
 */
public Map<String,Object> asMap(boolean decodeLMBCS) {
    Map<String,Object> data = new CaseInsensitiveMap<String, Object>();
    int itemCount = getItemsCount();
    for (int i=0; i<itemCount; i++) {
        Object val = getItemValue(i);

        if (val instanceof LMBCSString) {
            if (decodeLMBCS) {
                data.put(m_itemNames[i], ((LMBCSString)val).getValue());
            }
            else {
                data.put(m_itemNames[i], val);
            }
        }
        else if (val instanceof List) {
            if (decodeLMBCS) {
                //check for LMBCS strings
                List valAsList = (List) val;
                boolean hasLMBCS = false;

                for (int j=0; j<valAsList.size(); j++) {
                    if (valAsList.get(j) instanceof LMBCSString) {
                        hasLMBCS = true;
                        break;
                    }
                }

                if (hasLMBCS) {
                    List<Object> convList = new ArrayList<Object>(valAsList.size());
                    for (int j=0; j<valAsList.size(); j++) {
                        Object currObj = valAsList.get(j);
                        if (currObj instanceof LMBCSString) {
                            convList.add(((LMBCSString)currObj).getValue());
                        }
                        else {
                            convList.add(currObj);
                        }
                    }
                    data.put(m_itemNames[i], convList);
                }
                else {
                    data.put(m_itemNames[i], val);
                }
            }
            else {
                data.put(m_itemNames[i], val);
            }
        }
        else {
            data.put(m_itemNames[i], val);
        }
    }
    return data;
}
项目:JDA    文件:RestFuture.java   
public RestFuture(final RestAction<T> restAction, final boolean shouldQueue, final RequestBody data, final Object rawData, final Route.CompiledRoute route, final CaseInsensitiveMap<String, String> headers)
{
    this.request = new Request<>(restAction, this::complete, this::completeExceptionally, shouldQueue, data, rawData, route, headers);
    ((JDAImpl) restAction.getJDA()).getRequester().request(this.request);
}
项目:JDA    文件:Request.java   
public CaseInsensitiveMap<String, String> getHeaders()
{
    return headers;
}
项目:AwesomeJavaLibraryExamples    文件:ExampleCaseInsensitiveMap.java   
public static void main(String[] args)
{
   CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<>();

   map.put("one", "A");

   System.out.println(map);

   System.out.printf("using oNe as the key to get the value from the map: %s\n", map.get("oNe"));
}
项目:JDA    文件:RestAction.java   
/**
 * Submits a Request for execution and provides a {@link net.dv8tion.jda.core.requests.RequestFuture RequestFuture}
 * representing its completion task.
 * <br>Cancelling the returned Future will result in the cancellation of the Request!
 *
 * <p>Note: The usage of {@link java.util.concurrent.CompletionStage#toCompletableFuture() CompletionStage.toCompletableFuture()} is not supported.
 *
 * @param  shouldQueue
 *         Whether the Request should automatically handle rate limitations. (default true)
 *
 * @return Never-null {@link net.dv8tion.jda.core.requests.RequestFuture RequestFuture} task representing the completion promise
 */
public RequestFuture<T> submit(boolean shouldQueue)
{
    Route.CompiledRoute route = finalizeRoute();
    Checks.notNull(route, "Route");
    RequestBody data = finalizeData();
    CaseInsensitiveMap<String, String> headers = finalizeHeaders();
    return new RestFuture<>(this, shouldQueue, data, rawData, route, headers);
}
项目:JDA    文件:RestAction.java   
protected CaseInsensitiveMap<String, String> finalizeHeaders() { return null; }