-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide optimized resource / filter / capability / requirement / capa…
…bility set git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1829639 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
21 changed files
with
3,186 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 0 additions & 104 deletions
104
bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LazyHashMap.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LazyStringMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.bundlerepository.impl; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.felix.utils.collections.StringArrayMap; | ||
|
||
/** | ||
* A map that can delay the computation of certain values up until the moment that they | ||
* are actually needed. Useful for expensive to compute values such as the SHA-256. | ||
* This map does <b>not</b> support {@code null} values. | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class LazyStringMap<V> extends StringArrayMap<V> | ||
{ | ||
public LazyStringMap(Map<String, ? extends V> map) { | ||
super(map); | ||
} | ||
|
||
public LazyStringMap() { | ||
} | ||
|
||
public LazyStringMap(int capacity) { | ||
super(capacity); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public V get(Object key) | ||
{ | ||
V val = super.get(key); | ||
if (val instanceof LazyValue) { | ||
val = ((LazyValue<V>) val).compute(); | ||
if (val == null) { | ||
throw new NullPointerException("Lazy computed values may not be null"); | ||
} | ||
put((String) key, val); | ||
} | ||
return val; | ||
} | ||
|
||
public void putLazy(String key, LazyValue<V> lazy) { | ||
super.doPut(key, lazy); | ||
} | ||
|
||
public interface LazyValue<V> | ||
{ | ||
V compute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.